From f4009f4b7ce0ba26ad4ff224b4f285fb43e166a0 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 23 Mar 2025 12:00:33 +0100 Subject: The all seeing eye sees your trash and discard piles. --- images/all-seeing-eye.svg | 1 + play.html | 14 ++++++++++---- play.js | 23 ++++++++++++++++++++--- rules.js | 7 +++++-- rules.ts | 10 ++++++---- types.d.ts | 7 +++---- 6 files changed, 45 insertions(+), 17 deletions(-) create mode 100644 images/all-seeing-eye.svg diff --git a/images/all-seeing-eye.svg b/images/all-seeing-eye.svg new file mode 100644 index 0000000..9dd9976 --- /dev/null +++ b/images/all-seeing-eye.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/play.html b/play.html index 393b9c7..b3995e1 100644 --- a/play.html +++ b/play.html @@ -32,6 +32,7 @@ + @@ -53,14 +54,19 @@
-
+
+
Hand
+
+
+ +
Trash
-
-
Hand
-
+
+
Discard
+
diff --git a/play.js b/play.js index 4456972..91ef6c4 100644 --- a/play.js +++ b/play.js @@ -16,6 +16,9 @@ const ui = { fascist_cards: document.getElementById("fascist_cards"), trash: document.getElementById("trash"), + trash_panel: document.getElementById("trash_panel"), + discard: document.getElementById("discard"), + discard_panel: document.getElementById("discard_panel"), hand: document.getElementById("hand"), player_areas: document.getElementById("player_areas"), @@ -87,6 +90,13 @@ function toggle_pieces() { // eslint-disable-line no-unused-vars ui.map_container.classList.toggle("hide") } +let trash_toggle = ui.trash_panel.classList.contains("hide") +function toggle_trash() { + trash_toggle = !trash_toggle + ui.trash_panel.classList.toggle("hide", trash_toggle) + ui.discard_panel.classList.toggle("hide", trash_toggle) +} + let animation_register = [] function register_animation(e) { @@ -475,13 +485,20 @@ function on_update() { // eslint-disable-line no-unused-vars ui.fascist_cards.replaceChildren() place_cards(ui.fascist_cards, view.fascist_cards) - ui.trash.replaceChildren() - place_cards(ui.trash, view.trash) - ui.hand_panel.classList = "panel " + faction_class[player] ui.hand.replaceChildren() place_cards(ui.hand, view.hand) + ui.trash.replaceChildren() + place_cards(ui.trash, view.trash) + if (view.actions && view.actions.trash) + ui.trash_panel.classList.remove("hide") + else + ui.trash_panel.classList.toggle("hide", trash_toggle) + + ui.discard.replaceChildren() + place_cards(ui.discard, view.discard) + ui.tableaus[0].replaceChildren() ui.tableaus[1].replaceChildren() ui.tableaus[2].replaceChildren() diff --git a/rules.js b/rules.js index ecfbf6f..01443d6 100644 --- a/rules.js +++ b/rules.js @@ -342,7 +342,6 @@ function game_view(state, current) { first_player: game.first_player, fronts: game.fronts, glory: game.glory, - hand: faction === null ? [] : game.hands[faction], hero_points: game.hero_points, initiative: game.initiative, medallions: game.medallions, @@ -358,6 +357,11 @@ function game_view(state, current) { year: game.year, fascist: game.fascist, }; + if (faction !== null) { + view.hand = game.hands[faction]; + view.discard = game.discard[faction]; + view.trash = game.trash[faction]; + } if (!game.hidden_bag) view.bag_of_glory = game.bag_of_glory; if (game.state === 'game_over') { @@ -1777,7 +1781,6 @@ states.return_card = { const faction = get_active_faction(); gen_spend_hero_points(); view.prompt = 'Return a card to your hand.'; - view.trash = game.trash[faction]; let possible = false; for (let c of game.trash[faction]) { if (c !== game.played_card) { diff --git a/rules.ts b/rules.ts index 672da09..3945b71 100644 --- a/rules.ts +++ b/rules.ts @@ -528,9 +528,6 @@ function game_view(state: Game, current: Player | 'Observer') { first_player: game.first_player, fronts: game.fronts, glory: game.glory, - hand: faction === null ? [] : game.hands[faction], - // discard: faction === null ? [] : game.discard[faction], - // trash: faction === null ? [] : game.trash[faction], // deck: faction === null ? [] : list_deck(faction), hero_points: game.hero_points, initiative: game.initiative, @@ -549,6 +546,12 @@ function game_view(state: Game, current: Player | 'Observer') { fascist: game.fascist, }; + if (faction !== null) { + view.hand = game.hands[faction]; + view.discard = game.discard[faction]; + view.trash = game.trash[faction]; + } + if (!game.hidden_bag) view.bag_of_glory = game.bag_of_glory; @@ -2171,7 +2174,6 @@ states.return_card = { const faction = get_active_faction(); gen_spend_hero_points(); view.prompt = 'Return a card to your hand.'; - view.trash = game.trash[faction]; let possible = false; for (let c of game.trash[faction]) { if (c !== game.played_card) { diff --git a/types.d.ts b/types.d.ts index 3afee29..3d61fbd 100644 --- a/types.d.ts +++ b/types.d.ts @@ -105,11 +105,10 @@ export interface View { first_player: Game['first_player']; fronts: Game['fronts']; glory: Game['glory']; - hand: number[]; - // discard: number[]; - // deck: number[]; - fascist_cards?: number[]; + hand?: number[]; trash?: number[]; + discard?: number[]; + fascist_cards?: number[]; hero_points: Game['hero_points']; initiative: Game['initiative']; medallions: Game['medallions']; -- cgit v1.2.3