summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-10-27 23:47:37 +0100
committerTor Andersson <tor@ccxvii.net>2024-10-27 23:47:37 +0100
commitfb15209e66c5365c5df2d9fe1993ab319fd8eab6 (patch)
tree99ad2008455dcda1d2d242eb879ae69d06299101 /play.js
parentaba1092cc2e5eb0edef4862c228c29e5f974f982 (diff)
downloadmaria-fb15209e66c5365c5df2d9fe1993ab319fd8eab6.tar.gz
add power control markers in player list
Diffstat (limited to 'play.js')
-rw-r--r--play.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/play.js b/play.js
index 96a1242..0e35b5d 100644
--- a/play.js
+++ b/play.js
@@ -39,6 +39,10 @@ function action_menu(menu, action_list) {
x |= action_menu_item(action)
}
+const R_LOUIS_XV = "Louis XV"
+const R_FREDERICK = "Frederick"
+const R_MARIA_THERESA = "Maria Theresa"
+
/* DATA (SHARED) */
const deck_name = [ "red", "green", "blue", "yellow" ]
@@ -603,6 +607,21 @@ function make_political_back(deck) {
return e
}
+function make_badge(power) {
+ let e = document.createElement("div")
+ e.className = "role_marker " + power
+ return e
+}
+
+const power_badge = [
+ make_badge("france"),
+ make_badge("prussia"),
+ make_badge("pragmatic"),
+ make_badge("austria"),
+ make_badge("bavaria"),
+ make_badge("saxony"),
+]
+
function on_init() {
ui.pieces = [
create_piece("piece", 0, "piece cylinder france france_1"),
@@ -1129,6 +1148,40 @@ function update_favicon() {
}
}
+function is_saxony_prussian() {
+ return view.saxony <= 2
+}
+
+function player_from_power(pow) {
+ switch (pow) {
+ case P_FRANCE:
+ return R_LOUIS_XV
+ case P_PRUSSIA:
+ return R_FREDERICK
+ case P_PRAGMATIC:
+ return R_FREDERICK
+ case P_AUSTRIA:
+ return R_MARIA_THERESA
+ case P_SAXONY:
+ if (is_saxony_prussian())
+ return R_FREDERICK
+ else
+ return R_MARIA_THERESA
+ case P_BAVARIA:
+ return R_LOUIS_XV
+ }
+ return "NONE"
+}
+
+function update_player_power_list(role) {
+ if (roles[role]) {
+ roles[role].stat.replaceChildren()
+ for (let pow of all_powers)
+ if (player_from_power(pow) === role)
+ roles[role].stat.appendChild(power_badge[pow])
+ }
+}
+
function cmp_tc(a, b) {
let ax = (to_suit(a) << 7) + (to_value(a) << 3) + to_deck(a)
let bx = (to_suit(b) << 7) + (to_value(b) << 3) + to_deck(b)
@@ -1179,6 +1232,10 @@ function on_update() {
ui.header.classList.toggle("pragmatic", view.power === P_PRAGMATIC)
ui.header.classList.toggle("austria", view.power === P_AUSTRIA)
+ update_player_power_list(R_MARIA_THERESA)
+ update_player_power_list(R_FREDERICK)
+ update_player_power_list(R_LOUIS_XV)
+
used_victory.fill(0)
used_elector.fill(0)
used_retro.fill(0)