summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-11-09 13:04:14 +0100
committerTor Andersson <tor@ccxvii.net>2024-11-09 13:04:14 +0100
commite9a84ae8f28b98981b5af247731cc3c8949a0544 (patch)
treef92282c843a0f83e38a202aaac2b742ea29860bb
parentfd2f3f6d70d1641c435a37a6f06d67fb04d22bb1 (diff)
downloadmaria-e9a84ae8f28b98981b5af247731cc3c8949a0544.tar.gz
fix display of conquest/victory/retroactive marker stacking
-rw-r--r--play.html4
-rw-r--r--play.js28
2 files changed, 27 insertions, 5 deletions
diff --git a/play.html b/play.html
index bd8cb5b..683ff54 100644
--- a/play.html
+++ b/play.html
@@ -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>
diff --git a/play.js b/play.js
index 9ad4ede..6f7f17e 100644
--- a/play.js
+++ b/play.js
@@ -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