diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-10-30 00:45:54 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-10-30 00:53:56 +0100 |
commit | b9aced407fd405cdc46df7d5dde9968909724b3d (patch) | |
tree | 5af03727f193510b3f02cc0bbfe5821670b3ff0f /play.js | |
parent | b81278195d8184e77fe778c325a74aa865562792 (diff) | |
download | maria-b9aced407fd405cdc46df7d5dde9968909724b3d.tar.gz |
Introductory game.
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 164 |
1 files changed, 89 insertions, 75 deletions
@@ -1168,7 +1168,9 @@ function player_from_power(pow) { case P_PRUSSIA: return R_FREDERICK case P_PRAGMATIC: - return R_FREDERICK + if (view.pol_deck) + return R_FREDERICK + return "NONE" case P_AUSTRIA: return R_MARIA_THERESA case P_SAXONY: @@ -1233,6 +1235,36 @@ function show_tc(c) { return ui.tc[c] } +function update_political() { + ui.pol_tracks.replaceChildren() + layout_political_marker(ui.saxony, view.saxony, 0) + layout_political_marker(ui.russia, view.russia, 1) + layout_political_marker(ui.italy, view.italy, 2) + + ui.pc_deck.replaceChildren() + for (let e of ui.political_back[view.pol_deck]) + ui.pc_deck.appendChild(e) + if (view.flags & F_IMPERIAL_ELECTION) + ui.pc_deck.appendChild(ui.political[24]) + + for (let pc = 0; pc < 25; ++pc) + ui.political[pc].classList.toggle("selected", pc === view.pc) + + for (let pow of all_major_powers) { + ui.pc_placed[pow].replaceChildren() + for (let tc of view.face_up[pow]) + ui.pc_placed[pow].appendChild(show_tc(tc)) + for (let tc of view.face_down[pow]) + ui.pc_placed[pow].appendChild(show_tc(tc)) + } + + ui.pc_show.replaceChildren() + if (view.political) { + for (let pc of view.political) + ui.pc_show.appendChild(ui.political[pc]) + } +} + function on_update() { ui.header.classList.toggle("france", view.power === P_FRANCE) ui.header.classList.toggle("bavaria", view.power === P_BAVARIA) @@ -1252,6 +1284,10 @@ function on_update() { back.fill(0) sort_power_panel(true) + if (!view.pol_deck) { + ui.power_panel[P_PRAGMATIC].style.display = "none" + ui.power_panel[6].style.display = "none" + } for (let p = 0; p < 20; ++p) layout_general(p, view.pos[p]) @@ -1292,33 +1328,8 @@ function on_update() { ui.hand[view.power].appendChild(ui.tc[c]) } - ui.pol_tracks.replaceChildren() - layout_political_marker(ui.saxony, view.saxony, 0) - layout_political_marker(ui.russia, view.russia, 1) - layout_political_marker(ui.italy, view.italy, 2) - - ui.pc_deck.replaceChildren() - for (let e of ui.political_back[view.pol_deck]) - ui.pc_deck.appendChild(e) - if (view.flags & F_IMPERIAL_ELECTION) - ui.pc_deck.appendChild(ui.political[24]) - - for (let pc = 0; pc < 25; ++pc) - ui.political[pc].classList.toggle("selected", pc === view.pc) - - for (let pow of all_major_powers) { - ui.pc_placed[pow].replaceChildren() - for (let tc of view.face_up[pow]) - ui.pc_placed[pow].appendChild(show_tc(tc)) - for (let tc of view.face_down[pow]) - ui.pc_placed[pow].appendChild(show_tc(tc)) - } - - ui.pc_show.replaceChildren() - if (view.political) { - for (let pc of view.political) - ui.pc_show.appendChild(ui.political[pc]) - } + if (view.pol_deck) + update_political() for (let deck = 0; deck < 4; ++deck) { ui.discard[deck].replaceChildren() @@ -1330,58 +1341,61 @@ function on_update() { 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_electoral_college(0, P_PRAGMATIC) - for (let i = 0; i < all_electoral_colleges.length; ++i) { - for (let pow of all_powers) - if (is_power_controlled_fortress(pow, all_electoral_colleges[i])) - layout_electoral_college(i+1, pow) - } + if (view.pol_deck) { + for (let i = 0; i < view.elector.length; i += 2) + layout_elector(view.elector[i], view.elector[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) - - // 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 ++ + layout_electoral_college(0, P_PRAGMATIC) + for (let i = 0; i < all_electoral_colleges.length; ++i) { + for (let pow of all_powers) + if (is_power_controlled_fortress(pow, all_electoral_colleges[i])) + layout_electoral_college(i+1, pow) + } + + 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) + + // 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) } - 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() |