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.ts | |
parent | 23beb82e0344d895106351fe6d98f40c8ee50dc5 (diff) | |
download | land-and-freedom-b952d532d4b84c136e3c3a6893a63b0ed5b5ece3.tar.gz |
peek at fascist card event effect
Diffstat (limited to 'play.ts')
-rw-r--r-- | play.ts | 34 |
1 files changed, 19 insertions, 15 deletions
@@ -1,6 +1,6 @@ 'use strict'; -import { StaticData, View } from './types'; +import { CardId, StaticData, View } from './types'; declare function action_button(action: string, text: string): void; // declare function register_action(element: HTMLElement, type: string, s: number): void; @@ -69,6 +69,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'), @@ -329,6 +330,17 @@ function on_init() { }); } +function place_cards(e: HTMLElement, cards: CardId[]) { + 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'); + } + } +} + // @ts-ignore function on_update() { console.log('on_update', view); @@ -371,13 +383,11 @@ function on_update() { ); } - 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) { @@ -418,13 +428,7 @@ 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]); - } - } + // ui.turn_info.replaceChildren(); // console.log('played_card', view.played_card); |