diff options
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 27 |
1 files changed, 22 insertions, 5 deletions
@@ -132,6 +132,9 @@ function is_no_place_governor(province) { function get_support(province) { return view.support[province] } +function get_rival_emperor_location(id) { + return view.rival_emperors[id] +} function get_barbarian_location(id) { return view.barbarians[id] & 63 } @@ -562,11 +565,13 @@ const LAYOUT_PATTERN = [ let ui = { cards: [], + event_cards: [], militia: [], body: document.querySelector("body"), header: document.querySelector("header"), hand: document.getElementById("hand"), draw: document.getElementById("draw"), + active_event: document.getElementById("active_event"), discard: document.getElementById("discard"), played: document.getElementById("played"), market: document.getElementById("market"), @@ -728,7 +733,11 @@ function is_action(action, arg) { function on_init() { for (let c = 0; c < CARD_INDEX.length; ++c) { let name = CARD_INFO[CARD_INDEX[c]].name - ui.cards[c] = create("div", { className: "card influence_" + name.toLowerCase(), my_action: "card", my_id: c }) + ui.cards[c] = create("div", { className: "card influence influence_" + name.toLowerCase(), my_action: "card", my_id: c }) + } + + for (let e = 0; e <= 15; ++e) { + ui.event_cards[e] = create("div", { className: "card event event_" + e }) } for (let i = 0; i < 33; ++i) @@ -1056,6 +1065,16 @@ function on_update() { } } + for (let re = 0; re < 3; ++re) { + let loc = get_rival_emperor_location(re) + if (loc === UNAVAILABLE) + hide(ui.rival_emperors[re]) + else { + show(ui.rival_emperors[re]) + layout_stack(-1, [ ui.rival_emperors[re] ], loc, false, 8, 8) + } + } + for (let region = 0; region < 21; ++region) { ui.regions[region].classList.toggle("selected", view.selected_region === region) } @@ -1196,10 +1215,8 @@ function on_update() { ui.dice[3].className = "dice white d" + view.dice[3] layout_barbarian_dice(ui.dice[2], ui.dice[3], view.crisis) - if (view.events) { - for (let c of view.events) - ui.played.appendChild(ui.cards[c]) - } + ui.active_event.replaceChildren() + ui.active_event.appendChild(ui.event_cards[view.event]) ui.played.replaceChildren() if (view.played) { |