diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-11-09 13:04:14 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-11-09 13:04:14 +0100 |
commit | e9a84ae8f28b98981b5af247731cc3c8949a0544 (patch) | |
tree | f92282c843a0f83e38a202aaac2b742ea29860bb /play.js | |
parent | fd2f3f6d70d1641c435a37a6f06d67fb04d22bb1 (diff) | |
download | maria-e9a84ae8f28b98981b5af247731cc3c8949a0544.tar.gz |
fix display of conquest/victory/retroactive marker stacking
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 28 |
1 files changed, 25 insertions, 3 deletions
@@ -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 |