diff options
author | Frans Bongers <fransbongers@franss-mbp.home> | 2024-12-30 12:30:26 +0100 |
---|---|---|
committer | Frans Bongers <fransbongers@franss-mbp.home> | 2024-12-30 12:30:26 +0100 |
commit | b952d532d4b84c136e3c3a6893a63b0ed5b5ece3 (patch) | |
tree | f7667fdb7f8e771c7b63fccc6760b5cb37a95376 /play.js | |
parent | 23beb82e0344d895106351fe6d98f40c8ee50dc5 (diff) | |
download | land-and-freedom-b952d532d4b84c136e3c3a6893a63b0ed5b5ece3.tar.gz |
peek at fascist card event effect
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -55,6 +55,7 @@ const ui = { hero_points: document.getElementById('pool_hero_points'), }, }, + selectable_cards: document.getElementById('selectable_cards'), tableaus: { a: document.getElementById('tableau_a'), c: document.getElementById('tableau_c'), @@ -257,6 +258,16 @@ function on_init() { register_action(ui.fronts[front_id].front, 'front', front_id); }); } +function place_cards(e, cards) { + e.replaceChildren(); + for (let c of cards) { + ui.cards[c].classList.remove('selected'); + e.appendChild(ui.cards[c]); + if (view.selected_cards.includes(c)) { + ui.cards[c].classList.add('selected'); + } + } +} function on_update() { console.log('on_update', view); on_init(); @@ -282,13 +293,10 @@ function on_update() { for (let bonus_id of Object.keys(view.bonuses)) { ui.bonuses[bonus_id].setAttribute('data-bonus-on', view.bonuses[bonus_id] + 0); } - ui.hand.replaceChildren(); - for (let c of view.hand) { - ui.cards[c].classList.remove('selected'); - ui.hand.appendChild(ui.cards[c]); - if (view.selected_cards.includes(c)) { - ui.cards[c].classList.add('selected'); - } + place_cards(ui.hand, view.hand); + place_cards(ui.selectable_cards, view.selectable_cards); + for (let faction_id of FACTIONS) { + place_cards(ui.tableaus[faction_id], view.tableaus[faction_id]); } for (let i = 0; i < view.tracks.length; ++i) { ui.standees[i].style.left = LAYOUT_TRACKS[i][view.tracks[i]][0] + 'px'; @@ -319,13 +327,6 @@ function on_update() { } ui.roles[view.initiative].medallions.appendChild(ui.initiative_token); ui.initiative_token.setAttribute('data-year', view.year); - for (let faction_id of FACTIONS) { - ui.tableaus[faction_id].replaceChildren(); - for (let c of view.tableaus[faction_id]) { - ui.cards[c].classList.remove('selected'); - ui.tableaus[faction_id].appendChild(ui.cards[c]); - } - } if (view.played_card === null) { ui.turn_info.style.display = 'none'; } |