diff options
Diffstat (limited to 'rules.ts')
-rw-r--r-- | rules.ts | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -145,7 +145,7 @@ function gen_action_card(card_id: CardId) { gen_action('card', card_id); } -function gen_action_front(front_id: string) { +function gen_action_front(front_id: FrontId) { gen_action('front', front_id); } @@ -593,28 +593,28 @@ export function setup(seed: number, _scenario: string, options: Record<string,bo }, engine: [], faction_turn: null, - fronts: { - a: { + fronts: [ + { value: -2, contributions: [], status: null, }, - m: { + { value: -2, contributions: [], status: null, }, - n: { + { value: -2, contributions: [], status: null, }, - s: { + { value: -2, contributions: [], status: null, }, - }, + ], glory: [], first_player: null, hands: { @@ -2932,7 +2932,10 @@ function resolve_final_bid() { resolve_active_and_proceed(); } -function get_fronts_to_add_to(target: string, not: FrontId[] = []): FrontId[] { +function get_fronts_to_add_to( + target: string | number, + not: FrontId[] = [] +): FrontId[] { if (target === CLOSEST_TO_DEFEAT || target === CLOSEST_TO_VICTORY) { return get_fronts_closest_to(target); } else if (target === ANY) { @@ -3181,7 +3184,7 @@ function defeat_on_a_front(front_id: FrontId) { log_br() // Check game end - if (front_id === 'm' || get_defeated_front_count() == 2) { + if (front_id === MADRID || get_defeated_front_count() == 2) { game_over('Fascist', 'All players lose the game!'); return; } @@ -3439,9 +3442,9 @@ function get_fronts_closest_to(target: 'd' | 'v'): FrontId[] { const targetValue = target === 'd' ? Math.min(...values) : Math.max(...values); - return Object.keys(game.fronts).filter( - (frontId) => game.fronts[frontId].value === targetValue - ) as FrontId[]; + return game.fronts.findIndex( + (front) => front.value === targetValue + ) as unknown as FrontId[]; } // #endregion |