diff options
Diffstat (limited to 'rules.ts')
-rw-r--r-- | rules.ts | 63 |
1 files changed, 53 insertions, 10 deletions
@@ -70,6 +70,7 @@ import data, { LIBERTY_OR_COLLECTIVIZATION, ANARCHIST_EXTRA_HERO_POINT, ARAGON, + FASCIST_ID, // StaticData, // PLAYER_WITH_MOST_HERO_POINTS, } from './data'; @@ -128,9 +129,9 @@ const faction_cards = { }; const fascist_decks = { - 1: make_list(55, 72), - 2: make_list(73, 90), - 3: make_list(91, 108), + 1: make_list(55, 72) as CardId[], + 2: make_list(73, 90) as CardId[], + 3: make_list(91, 108) as CardId[], }; export const scenarios = ['Standard']; @@ -313,6 +314,7 @@ const engine_functions: Record<string, Function> = { card35_event2, card42_event3, card45_event2, + card46_event3, card50_event2, card53_event2, card54_event1, @@ -446,6 +448,7 @@ function game_view(state: Game, player: Player) { initiative: game.initiative, medallions: game.medallions, played_card: game.played_card, + selectable_cards: game.selectable_cards, selected_cards: game.selected_cards[faction_id], tableaus: game.tableaus, tracks: game.tracks, @@ -535,6 +538,7 @@ export function setup(seed: number, _scenario: string, _options: unknown) { pool: [], }, played_card: null, + selectable_cards: [], selected_cards: { a: [], c: [], @@ -555,6 +559,7 @@ export function setup(seed: number, _scenario: string, _options: unknown) { log: [], undo: [], used_medallions: [], + top_of_events_deck: null, turn: 0, year: 0, }; @@ -607,7 +612,7 @@ function start_year() { function start_turn() { log_h1(`Year ${game.year} - Turn ${game.turn}`); - const cardId = draw_card(list_deck('fascist')); + const cardId = draw_fascist_card(); game.current_events.push(cardId); const card = cards[cardId] as EventCard; @@ -1271,6 +1276,19 @@ states.peek_fascist_cards = { inactive: 'peek at Fascist cards', prompt() { view.prompt = 'Choose one card to return to the top of the deck'; + for (const c of game.selectable_cards) { + gen_action_card(c); + } + }, + card(c: CardId) { + game.top_of_events_deck = c; + for (const ec of game.selectable_cards) { + if (ec !== c) { + game.discard.f.push(ec); + } + } + game.selectable_cards = []; + resolve_active_and_proceed(); }, }; @@ -1698,6 +1716,13 @@ function card45_event2() { resolve_active_and_proceed(); } +function card46_event3() { + for (let i = 0; i < 3; ++i) { + game.selectable_cards.push(draw_fascist_card()); + } + resolve_active_and_proceed(); +} + function card50_event2() { const value = game.tracks[COLLECTIVIZATION] >= 8 ? 3 : 2; insert_after_active_node( @@ -1869,6 +1894,11 @@ function end_of_year() { create_leaf_node('end_of_year_discard', f) ); game.engine.push(create_function_node('start_year')); + + // New deck is used for next year so clear top card + // if it was set + game.top_of_events_deck = null; + next(); } @@ -2441,6 +2471,15 @@ function draw_card(deck: CardId[]): CardId { return c; } +function draw_fascist_card(): CardId { + if (game.top_of_events_deck !== null) { + const card_id = game.top_of_events_deck; + game.top_of_events_deck = null; + return card_id; + } + return draw_card(list_deck(FASCIST_ID)); +} + function lose_hero_point(faction: FactionId, value: number) { const points_lost = Math.min(game.hero_points[faction], Math.abs(value)); game.hero_points.pool += points_lost; @@ -2656,18 +2695,22 @@ function make_list(first: number, last: number): number[] { return list; } -function list_deck(id: FactionId | 'fascist') { +function list_deck(id: FactionId | 'f') { const deck = []; - const card_list = - id === 'fascist' ? fascist_decks[game.year] : faction_cards[id]; + const card_list: CardId[] = + id === FASCIST_ID ? fascist_decks[game.year] : faction_cards[id]; card_list.forEach((card) => { if ( - id === 'fascist' && - (game.discard.f.includes(card) || game.current_events.includes(card)) + game.discard[id].includes(card) || + game.selectable_cards.includes(card) ) { return; + } + + if (id === FASCIST_ID && game.current_events.includes(card)) { + return; } else if ( - id !== 'fascist' && + id !== FASCIST_ID && (game.hands[id].includes(card) || game.discard[id].includes(card) || game.tableaus[id].includes(card) || |