summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js164
1 files changed, 89 insertions, 75 deletions
diff --git a/play.js b/play.js
index 6ffb8df..cef2bdd 100644
--- a/play.js
+++ b/play.js
@@ -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()