summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-10-17 22:59:50 +0200
committerTor Andersson <tor@ccxvii.net>2024-10-17 23:10:06 +0200
commit0e80195d27b4eab2af57b89d6f9348cb39de19d4 (patch)
tree9deb3ff8aeafcc675d5765891bf485bffdb3b244 /play.js
parentd40f4d5eae30fd292ef0bffac7b6479291d5550a (diff)
downloadmaria-0e80195d27b4eab2af57b89d6f9348cb39de19d4.tar.gz
victory and elector conquest markers
Diffstat (limited to 'play.js')
-rw-r--r--play.js97
1 files changed, 76 insertions, 21 deletions
diff --git a/play.js b/play.js
index 0f92565..4e560aa 100644
--- a/play.js
+++ b/play.js
@@ -491,18 +491,24 @@ function on_init() {
for (let e of ui.troops)
ui.pieces_element.appendChild(e)
- /*
- ui.conquest = []
- ui.retro = []
- for (let s of all_objectives) {
- for (let pow = 0; pow < 7; ++pow) {
- if (set_has(objective1[pow], s) || set_has(objective2[pow], s)) {
- ui.conquest[s] = create_conquest("marker conquest " + power_class[pow], s)
- ui.retro[s] = create_conquest("marker retroactive " + power_class[pow], s)
- }
+ ui.victory = [ [], [], [], [], [], [] ]
+ ui.retro = [ [], [], [], [], [], [] ]
+ for (let pow of [ P_FRANCE, P_PRUSSIA, P_PRAGMATIC, P_AUSTRIA ]) {
+ ui.victory[pow] = []
+ ui.retro[pow] = []
+ for (let i = 0; i < 100; ++i) {
+ ui.victory[pow].push(create_conquest("marker victory_marker_" + power_class[pow]))
+ ui.retro[pow].push(create_conquest("marker question_marker_" + power_class[pow]))
}
}
- */
+
+ ui.elector = [ [], [], [], [], [], [] ]
+ for (let i = 0; i < 10; ++i) {
+ ui.elector[P_FRANCE].push(create_conquest("marker elector_marker_france"))
+ ui.elector[P_PRUSSIA].push(create_conquest("marker elector_marker_prussia"))
+ ui.elector[P_SAXONY].push(create_conquest("marker elector_marker_saxony"))
+ ui.elector[P_AUSTRIA].push(create_conquest("marker elector_marker_austria_pragmatic"))
+ }
ui.tc = []
make_tc_deck(0)
@@ -827,15 +833,54 @@ function layout_turn_marker() {
}
}
-function create_conquest(style, s) {
+function create_conquest(style) {
+ let e = document.createElement("div")
+ e.className = style
+ return e
+}
+
+const used_victory = [ 0, 0, 0, 0, 0, 0 ]
+const used_elector = [ 0, 0, 0, 0, 0, 0 ]
+const used_retro = [ 0, 0, 0, 0, 0, 0 ]
+
+function layout_victory(s, pow) {
+ let e = ui.victory[pow][used_victory[pow]++]
let x = data.cities.x[s]
let y = data.cities.y[s]
- let e = document.createElement("div")
- e.dataset.id = s
e.style.left = (x - 16) + "px"
e.style.top = (y - 16) + "px"
- e.className = style
- return e
+ ui.markers_element.appendChild(e)
+}
+
+function layout_retro(s, pow) {
+ let e = ui.retro[pow][used_retro[pow]++]
+ let x = data.cities.x[s]
+ let y = data.cities.y[s]
+ e.style.left = (x - 16) + "px"
+ e.style.top = (y - 16) + "px"
+ ui.markers_element.appendChild(e)
+}
+
+function layout_victory_pool(pow, max, x, y) {
+ let n = 0
+ for (let i = 0; i < view.victory.length; i += 2)
+ if (view.victory[i+1] === pow)
+ ++n
+ for (let i = 0; i < max - n; ++i) {
+ let e = ui.victory[pow][used_victory[pow]++]
+ e.style.left = (x - 16 + (i%5) * 20) + "px"
+ e.style.top = (y - 16 + (i/5|0) * 20) + "px"
+ ui.markers_element.appendChild(e)
+ }
+}
+
+function layout_elector(s, pow) {
+ let e = ui.elector[pow][used_elector[pow]++]
+ let x = data.cities.x[s]
+ let y = data.cities.y[s]
+ e.style.left = (x - 16) + "px"
+ e.style.top = (y - 16) + "px"
+ ui.markers_element.appendChild(e)
}
function update_favicon() {
@@ -890,6 +935,10 @@ function on_update() {
ui.header.classList.toggle("pragmatic", view.power === P_PRAGMATIC)
ui.header.classList.toggle("austria", view.power === P_AUSTRIA)
+ used_victory.fill(0)
+ used_elector.fill(0)
+ used_retro.fill(0)
+
sort_power_panel(true)
for (let p = 0; p < 20; ++p)
@@ -954,12 +1003,18 @@ function on_update() {
}
ui.markers_element.replaceChildren()
- /*
- for (let s of view.conquest)
- ui.markers_element.appendChild(ui.conquest[s])
- for (let s of view.retro)
- ui.markers_element.appendChild(ui.retro[s])
- */
+
+ 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.elector.length; i += 2)
+ layout_elector(view.elector[i], view.elector[i+1])
+ for (let i = 0; i < view.retro.length; i += 2)
+ layout_retro(view.retro[i], view.retro[i+1])
+
+ layout_victory_pool(P_FRANCE, 11, 83, 1560)
+ layout_victory_pool(P_AUSTRIA, 8, 2334, 1561)
+ layout_victory_pool(P_PRUSSIA, 13, 1927, 76)
+ layout_victory_pool(P_PRAGMATIC, 8, 797, 98)
layout_turn_marker()