diff options
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 80 |
1 files changed, 72 insertions, 8 deletions
@@ -34,6 +34,9 @@ const ELIMINATED_GENERAL_DX = 50 const HUSSAR_X = 2190 const HUSSAR_Y = 1630 +const VICTORY_BOX_X = [ 115, 170, 235 ] +const VICTORY_BOX_Y = [ 235, 290, 345, 401 ] + /* DATA (SHARED) */ const deck_name = [ "red", "green", "blue", "yellow" ] @@ -51,6 +54,12 @@ const P_SAXONY = 5 const power_name = [ "France", "Prussia", "Pragmatic Army", "Austria", "Bavaria", "Saxony" ] const power_class = [ "france", "prussia", "pragmatic", "austria", "bavaria", "saxony" ] +const F_EMPEROR_FRANCE = 1 +const F_EMPEROR_AUSTRIA = 2 +const F_ITALY_FRANCE = 4 +const F_ITALY_AUSTRIA = 8 +const F_SILESIA_ANNEXED = 16 + const SPADES = 0 const CLUBS = 1 const HEARTS = 2 @@ -595,6 +604,13 @@ function on_init() { ui.turn = document.createElement("div") ui.turn.className = "marker turn_marker" + ui.saxony = document.createElement("div") + ui.saxony.className = "marker political_marker_saxony" + ui.russia = document.createElement("div") + ui.russia.className = "marker political_marker_russia" + ui.italy = document.createElement("div") + ui.italy.className = "marker political_marker_italy" + ui.political = [] for (let fc = 0; fc <= 18; ++fc) ui.political[fc] = make_political_card(fc) @@ -878,6 +894,23 @@ function layout_victory(s, pow) { ui.markers_element.appendChild(e) } +function layout_victory_box(pow, col, row) { + let e = ui.victory[pow][used_victory[pow]++] + let x = VICTORY_BOX_X[row] + let y = VICTORY_BOX_Y[col] + e.style.left = (x - 16) + "px" + e.style.top = (y - 16) + "px" + ui.markers_element.appendChild(e) +} + +function layout_political_marker(e, col, row) { + let x = 190 + (col-1) * 69 + let y = 72 + row * 86 + 16 + e.style.left = (x - 16) + "px" + e.style.top = (y - 16) + "px" + ui.political_display.appendChild(e) +} + function layout_retro(s, pow) { let e = ui.retro[pow][used_retro[pow]++] let x = data.cities.x[s] @@ -1012,15 +1045,10 @@ function on_update() { ui.hand[view.power].appendChild(ui.tc[c]) } - /* ui.political_display.replaceChildren() - if (view.oo > 0) - ui.political_display.appendChild(ui.tc[view.oo]) - ui.political_display.appendChild(ui.fate[0]) - if (typeof view.fate === "object") - for (let c of view.fate) - ui.political_display.appendChild(ui.fate[c]) - */ + layout_political_marker(ui.saxony, view.saxony, 0) + layout_political_marker(ui.russia, view.russia, 1) + layout_political_marker(ui.italy, view.italy, 2) for (let deck = 0; deck < 4; ++deck) { ui.discard[deck].replaceChildren() @@ -1042,6 +1070,42 @@ function on_update() { layout_victory_pool(P_PRUSSIA, 13, 1927, 76) layout_victory_pool(P_PRAGMATIC, 8, 797, 98) + // battle vp + if (view.vp[P_PRUSSIA] > 0) layout_victory_box(P_PRUSSIA, 0, 0) + if (view.vp[P_PRUSSIA] > 1) layout_victory_box(P_PRUSSIA, 0, 1) + if (view.vp[P_PRAGMATIC] > 0) layout_victory_box(P_PRAGMATIC, 1, 0) + if (view.vp[P_PRAGMATIC] > 1) layout_victory_box(P_PRAGMATIC, 1, 1) + if (view.vp[P_FRANCE] > 0) layout_victory_box(P_FRANCE, 2, 0) + if (view.vp[P_FRANCE] > 1) layout_victory_box(P_FRANCE, 2, 1) + if (view.vp[P_AUSTRIA] > 0) layout_victory_box(P_AUSTRIA, 3, 0) + if (view.vp[P_AUSTRIA] > 1) layout_victory_box(P_AUSTRIA, 3, 1) + + if (view.flags & F_SILESIA_ANNEXED) + layout_victory_box(P_PRUSSIA, 0, 2) + + let elector_france = 0 + let elector_pragmatic = 0 + for (let i = 0; i < 8; i += 2) { + if (view.elector[i+1] === P_FRANCE) + elector_france ++ + else + elector_pragmatic ++ + } + if (elector_france >= 3) + layout_victory_box(P_FRANCE, 1, 2) + if (elector_pragmatic >= 3) + layout_victory_box(P_PRAGMATIC, 1, 2) + + if (view.flags & F_ITALY_FRANCE) + layout_victory_box(P_FRANCE, 2, 2) + if (view.flags & F_ITALY_AUSTRIA) + layout_victory_box(P_AUSTRIA, 2, 2) + + if (view.flags & F_EMPEROR_FRANCE) + layout_victory_box(P_FRANCE, 3, 2) + if (view.flags & F_EMPEROR_AUSTRIA) + layout_victory_box(P_AUSTRIA, 3, 2) + layout_turn_marker() if (view.attacker !== undefined && view.defender !== undefined) { |