diff options
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 116 |
1 files changed, 58 insertions, 58 deletions
@@ -18,21 +18,21 @@ const ui = { hand: document.getElementById("hand"), player_areas: document.getElementById("player_areas"), - panels: { - a: document.getElementById("player_area_a"), - c: document.getElementById("player_area_c"), - m: document.getElementById("player_area_m"), - }, - tableaus: { - a: document.getElementById("tableau_a"), - c: document.getElementById("tableau_c"), - m: document.getElementById("tableau_m"), - }, - tokens: { - a: document.getElementById("tokens_a"), - c: document.getElementById("tokens_c"), - m: document.getElementById("tokens_m"), - }, + panels: [ + document.getElementById("player_area_a"), + document.getElementById("player_area_c"), + document.getElementById("player_area_m"), + ], + tableaus: [ + document.getElementById("tableau_a"), + document.getElementById("tableau_c"), + document.getElementById("tableau_m"), + ], + tokens: [ + document.getElementById("tokens_a"), + document.getElementById("tokens_c"), + document.getElementById("tokens_m"), + ], bag_of_glory: document.getElementById("bag_of_glory"), // spaces @@ -220,7 +220,7 @@ function build_bonus(b, box_name, cname) { ui.map_container.appendChild(e) } -function build_front(i, action_id, box_name) { +function build_front(i, box_name) { var [x, y, w, h] = boxes[box_name] var e @@ -253,7 +253,7 @@ function build_front(i, action_id, box_name) { e.style.left = Math.round(x-3) + "px" e.style.width = Math.round(w - 6) + "px" e.style.height = Math.round(h - 6) + "px" - register_action(e, "front", action_id) + register_action(e, "front", i) ui.map_container.appendChild(e) } @@ -265,11 +265,11 @@ function on_init() { on_init_once = true ui.roles_list = document.getElementById("roles"), - ui.roles = { - a: document.getElementById("role_Anarchist"), - c: document.getElementById("role_Communist"), - m: document.getElementById("role_Moderate"), - } + ui.roles = [ + document.getElementById("role_Anarchist"), + document.getElementById("role_Communist"), + document.getElementById("role_Moderate"), + ] build_track(0, "tr0", "Liberty", 0, 10) build_track(1, "tr1", "Collectivization", 0, 10) @@ -280,10 +280,10 @@ function on_init() { build_bonus(0, "Bonus1", "bonus_morale") build_bonus(1, "Bonus2", "bonus_teamwork") - build_front(0, "a", "Aragon") - build_front(1, "m", "Madrid") - build_front(2, "n", "Northern") - build_front(3, "s", "Southern") + build_front(0, "Aragon") + build_front(1, "Madrid") + build_front(2, "Northern") + build_front(3, "Southern") ui.medallion_container = [] for (i = 0; i < 5; ++i) { @@ -361,9 +361,9 @@ const faction_class = { "Anarchist": "anarchist", "Communist": "communist", "Moderate": "moderate", - "a": "anarchist", - "c": "communist", - "m": "moderate", + "0": "anarchist", + "1": "communist", + "2": "moderate", } function update_front(status_card, str_container, con_container, front, front_id) { @@ -478,15 +478,15 @@ function on_update() { // eslint-disable-line no-unused-vars ui.hand.replaceChildren() place_cards(ui.hand, view.hand) - ui.tableaus.a.replaceChildren() - ui.tableaus.c.replaceChildren() - ui.tableaus.m.replaceChildren() - ui.tableaus.a.appendChild(ui.cards[117]) - ui.tableaus.c.appendChild(ui.cards[116]) - ui.tableaus.m.appendChild(ui.cards[115]) - place_cards(ui.tableaus.a, view.tableaus.a) - place_cards(ui.tableaus.c, view.tableaus.c) - place_cards(ui.tableaus.m, view.tableaus.m) + ui.tableaus[0].replaceChildren() + ui.tableaus[1].replaceChildren() + ui.tableaus[2].replaceChildren() + ui.tableaus[0].appendChild(ui.cards[117]) + ui.tableaus[1].appendChild(ui.cards[116]) + ui.tableaus[2].appendChild(ui.cards[115]) + place_cards(ui.tableaus[0], view.tableaus[0]) + place_cards(ui.tableaus[1], view.tableaus[1]) + place_cards(ui.tableaus[2], view.tableaus[2]) for (i = 0; i <= 1; ++i) { ui.bonuses[i].classList.toggle("red", !!view.bonuses[i]) @@ -511,28 +511,28 @@ function on_update() { // eslint-disable-line no-unused-vars for (i = 0; i < 5; ++i) { ui.medallion_container[i].replaceChildren() - if (i < view.medallions.pool.length) { - x = view.medallions.pool[i] + if (i < view.medallions[3].length) { + x = view.medallions[3][i] if (x !== null) ui.medallion_container[i].appendChild(ui.medallions[x]) } } - ui.tokens.a.replaceChildren() - ui.tokens.c.replaceChildren() - ui.tokens.m.replaceChildren() + ui.tokens[0].replaceChildren() + ui.tokens[1].replaceChildren() + ui.tokens[2].replaceChildren() ui.tokens[view.initiative].appendChild(ui.initiative) - update_medallions(ui.tokens.a, view.medallions.a) - update_medallions(ui.tokens.c, view.medallions.c) - update_medallions(ui.tokens.m, view.medallions.m) - update_hero_points(ui.tokens.a, view.hero_points.a) - update_hero_points(ui.tokens.c, view.hero_points.c) - update_hero_points(ui.tokens.m, view.hero_points.m) - - update_front(ui.status_fronts[0], ui.str_fronts[0], ui.con_fronts[0], view.fronts.a, "a") - update_front(ui.status_fronts[1], ui.str_fronts[1], ui.con_fronts[1], view.fronts.m, "m") - update_front(ui.status_fronts[2], ui.str_fronts[2], ui.con_fronts[2], view.fronts.n, "n") - update_front(ui.status_fronts[3], ui.str_fronts[3], ui.con_fronts[3], view.fronts.s, "s") + update_medallions(ui.tokens[0], view.medallions[0]) + update_medallions(ui.tokens[1], view.medallions[1]) + update_medallions(ui.tokens[2], view.medallions[2]) + update_hero_points(ui.tokens[0], view.hero_points[0]) + update_hero_points(ui.tokens[1], view.hero_points[1]) + update_hero_points(ui.tokens[2], view.hero_points[2]) + + update_front(ui.status_fronts[0], ui.str_fronts[0], ui.con_fronts[0], view.fronts[0], "a") + update_front(ui.status_fronts[1], ui.str_fronts[1], ui.con_fronts[1], view.fronts[1], "m") + update_front(ui.status_fronts[2], ui.str_fronts[2], ui.con_fronts[2], view.fronts[2], "n") + update_front(ui.status_fronts[3], ui.str_fronts[3], ui.con_fronts[3], view.fronts[3], "s") for (e of ui.raw_glory_container) e.replaceChildren() @@ -610,10 +610,10 @@ function sub_medallion(_match, p1) { function sub_token(match) { switch (match) { - case "Ta": return `<img src="images/icons/player_anarchist.png">` - case "Tc": return `<img src="images/icons/player_communist.png">` - case "Tm": return `<img src="images/icons/player_moderate.png">` - case "Tf": return `<img src="images/icons/player_fascist.png">` + case "T0": return `<img src="images/icons/player_anarchist.png">` + case "T1": return `<img src="images/icons/player_communist.png">` + case "T2": return `<img src="images/icons/player_moderate.png">` + case "T3": return `<img src="images/icons/player_fascist.png">` case "HP": return `<img src="images/icons/hero_point.png">` } return match |