diff options
-rw-r--r-- | play.html | 4 | ||||
-rw-r--r-- | play.js | 28 |
2 files changed, 27 insertions, 5 deletions
@@ -38,8 +38,8 @@ <img src="images/shaking-hands.svg"> </summary> <menu> - <li id="propose_subsidy_menu" onclick="propose_subsidy()">Propose subsidy contract - <li id="cancel_subsidy_menu" onclick="cancel_subsidy()">Cancel subsidy contract + <li id="propose_subsidy_menu" onclick="propose_subsidy()">Propose subsidy + <li id="cancel_subsidy_menu" onclick="cancel_subsidy()">Cancel subsidy <li class="separator"> <li id="propose_deal_menu" onclick="propose_deal()">Propose deal </menu> @@ -4,6 +4,9 @@ /* globals data, view, action_button, action_button_with_argument, confirm_action_button, send_action, params */ +// TODO: animate_position on pieces instead of top/left transition +// TODO: animate_position on political markers instead of top/left transition + function toggle_pieces() { // Cycle between showing everything, only pieces, and nothing. let hidden_pieces = ui.pieces_element.classList.contains("hide") @@ -1475,16 +1478,19 @@ function on_update() { ui.markers_element.replaceChildren() - for (let i = 0; i < view.victory.length; i += 2) - layout_victory(view.victory[i], view.victory[i+1]) for (let i = 0; i < view.retro.length; i += 2) layout_retro(view.retro[i], view.retro[i+1]) + for (let i = 0; i < view.victory.length; i += 2) + if (!map_has(view.retro, view.victory[i])) + layout_victory(view.victory[i], view.victory[i+1]) + if (!is_intro()) { update_political() for (let i = 0; i < view.elector.length; i += 2) - layout_elector(view.elector[i], view.elector[i+1]) + if (!map_has(view.retro, view.elector[i])) + layout_elector(view.elector[i], view.elector[i+1]) layout_electoral_college(0, P_PRAGMATIC) for (let i = 0; i < all_electoral_colleges.length; ++i) { @@ -1889,6 +1895,22 @@ function set_intersect(one, two) { return set } +function map_has(map, key) { + let a = 0 + let b = (map.length >> 1) - 1 + while (a <= b) { + let m = (a + b) >> 1 + let x = map[m<<1] + if (key < x) + b = m - 1 + else if (key > x) + a = m + 1 + else + return true + } + return false +} + function map_get(map, key, missing) { let a = 0 let b = (map.length >> 1) - 1 |