diff options
author | Tor Andersson <tor@ccxvii.net> | 2025-03-10 00:18:26 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2025-03-10 23:10:47 +0100 |
commit | d810213990bf433a2efa24440bcd7cb1699e6448 (patch) | |
tree | 048c9aa390339542719fe44aac10a5ea1bca6181 | |
parent | ebe9d5b86b2fe547395524f6414d47c2e4448771 (diff) | |
download | land-and-freedom-d810213990bf433a2efa24440bcd7cb1699e6448.tar.gz |
Add hidden bag of glory option.
-rw-r--r-- | create.html | 4 | ||||
-rw-r--r-- | play.css | 20 | ||||
-rw-r--r-- | play.html | 6 | ||||
-rw-r--r-- | play.js | 10 | ||||
-rw-r--r-- | rules.js | 8 | ||||
-rw-r--r-- | rules.ts | 15 | ||||
-rw-r--r-- | types.d.ts | 6 |
7 files changed, 52 insertions, 17 deletions
diff --git a/create.html b/create.html index e69de29..7572c50 100644 --- a/create.html +++ b/create.html @@ -0,0 +1,4 @@ +<p> +<label> +<input type="checkbox" checked value="true" name="hidden_bag">Hidden Bag of Glory contents.</span> +</label> @@ -80,7 +80,6 @@ body header.fascist.your_turn { background-color: hsl(30, 35%, 65%); } .panel { padding: 4px; max-width: calc(1650px - 8px); - min-height: 281px; margin: 24px auto; border: 1px solid black; box-shadow: 2px 2px 4px #0004; @@ -99,6 +98,24 @@ body header.fascist.your_turn { background-color: hsl(30, 35%, 65%); } flex-wrap: wrap; gap: 16px; padding: 12px; + min-height: 281px; +} + +#bag_of_glory { + min-height: fit-content; + display: grid; + grid-template-columns: repeat(6, 51px); + grid-template-rows: repeat(3, 51px); + gap: 7px; +} + +#bag_of_glory_panel { + max-width: fit-content; + background-color: tan; +} + +#bag_of_glory_panel .panel_header { + background-color: wheat; } /* SPACES */ @@ -179,7 +196,6 @@ body header.fascist.your_turn { background-color: hsl(30, 35%, 65%); } padding: 0 0 12px 24px; gap: 8px; align-items: center; - } /* TOKENS */ @@ -76,6 +76,12 @@ <div id="tokens_m" class="token_pool"></div> </div> </div> + + <div id="bag_of_glory_panel" class="panel"> + <div class="panel_header">Bag of Glory</div> + <div id="bag_of_glory" class="panel_body"></div> + </div> + </main> <footer id="status"></footer> @@ -31,6 +31,7 @@ const ui = { c: document.getElementById("tokens_c"), m: document.getElementById("tokens_m"), }, + bag_of_glory: document.getElementById("bag_of_glory"), // spaces tracks_x: [], @@ -514,6 +515,15 @@ function on_update() { // eslint-disable-line no-unused-vars ui.glory_container[i].appendChild(e) } + ui.bag_of_glory.replaceChildren() + if (Array.isArray(view.bag_of_glory)) { + for (x of view.bag_of_glory) { + e = document.createElement("div") + e.className = "red token player " + faction_class[x] + ui.bag_of_glory.appendChild(e) + } + } + action_button("add_to_front", "+1 to a Front") action_button("d_liberty", "Decrease Liberty") action_button("soviet_support", "Soviet Support") @@ -348,8 +348,6 @@ function game_view(state, current) { view = { log: game.log, prompt: null, - bag_of_glory: game.bag_of_glory, - bag_of_glory_count: game.bag_of_glory.length, bonuses: game.bonuses, current_events: game.current_events, first_player: game.first_player, @@ -371,6 +369,8 @@ function game_view(state, current) { year: game.year, fascist: game.fascist, }; + if (!game.hidden_bag) + view.bag_of_glory = game.bag_of_glory; if (game.state === 'game_over') { view.prompt = game.victory; } @@ -391,7 +391,7 @@ function game_view(state, current) { } return view; } -function setup(seed, _scenario, _options) { +function setup(seed, _scenario, options) { game = { seed: seed, state: null, @@ -479,6 +479,8 @@ function setup(seed, _scenario, _options) { fascist: 0, card_played: 0, }; + if (options.hidden_bag) + game.hidden_bag = 1; game.player_order.push(exports.roles[random(2)]); game.player_order.push(game.player_order[1] === data_1.ANARCHIST ? data_1.COMMUNIST : data_1.ANARCHIST); draw_medallions(); @@ -517,16 +517,9 @@ function game_view(state: Game, current: Player | 'Observer') { current === OBSERVER ? null : player_faction_map[current]; view = { - // active: game.active, - // engine: game.engine, // TODO: remove log: game.log, prompt: null, - // state: game.state, - bag_of_glory: game.bag_of_glory, - bag_of_glory_count: game.bag_of_glory.length, bonuses: game.bonuses, - // current, - // current_player_faction: faction, current_events: game.current_events, first_player: game.first_player, fronts: game.fronts, @@ -552,6 +545,9 @@ function game_view(state: Game, current: Player | 'Observer') { fascist: game.fascist, }; + if (!game.hidden_bag) + view.bag_of_glory = game.bag_of_glory; + if (game.state === 'game_over') { view.prompt = game.victory; } else if ( @@ -576,7 +572,7 @@ function game_view(state: Game, current: Player | 'Observer') { // #region SETUP -export function setup(seed: number, _scenario: string, _options: unknown) { +export function setup(seed: number, _scenario: string, options: Record<string,boolean>) { // game.seed = seed; game = { seed: seed, @@ -666,6 +662,9 @@ export function setup(seed: number, _scenario: string, _options: unknown) { card_played: 0, }; + if (options.hidden_bag) + game.hidden_bag = 1; + // Randomly choose second player game.player_order.push(roles[random(2)]); // Remaining role is 3rd player @@ -74,6 +74,7 @@ export interface Game { glory_current_year?: Record<FactionId, boolean> | null; fascist: 0 | 1; card_played: 0 | 1; + hidden_bag?: 0 | 1; } export interface View { @@ -81,11 +82,8 @@ export interface View { prompt: string | null; actions?: any; victory?: string; - // current: Player | 'Observer'; - // current_player_faction: FactionId | null; selected_cards: number[]; - bag_of_glory: Game['bag_of_glory']; // TODO: remove - bag_of_glory_count: number; + bag_of_glory?: Game['bag_of_glory']; bonuses: Game['bonuses']; current_events: CardId[]; first_player: Game['first_player']; |