summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js29
1 files changed, 15 insertions, 14 deletions
diff --git a/play.js b/play.js
index 00a436a..afb6b2a 100644
--- a/play.js
+++ b/play.js
@@ -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';
}