diff options
Diffstat (limited to 'rules.ts')
-rw-r--r-- | rules.ts | 119 |
1 files changed, 59 insertions, 60 deletions
@@ -20,6 +20,9 @@ import { SeqNode, States, View, + FascistId, + ClosestToDefeat, + ClosestToVictory, } from './types'; import data, { @@ -76,11 +79,11 @@ var view = {} as View; // = null const role_ids: FactionId[] = [ANARCHISTS_ID, COMMUNISTS_ID, MODERATES_ID]; -const faction_player_map: Record<FactionId, Player> = { - a: ANARCHIST, - c: COMMUNIST, - m: MODERATE, -}; +const faction_player_map: Record<FactionId, Player> = [ + ANARCHIST, + COMMUNIST, + MODERATE, +]; const player_faction_map: Record<Player, FactionId> = { [ANARCHIST]: ANARCHISTS_ID, @@ -88,14 +91,14 @@ const player_faction_map: Record<Player, FactionId> = { [MODERATE]: MODERATES_ID, }; -const front_names: Record<string, string> = { - a: 'Aragon Front', - m: 'Madrid Front', - n: 'Northern Front', - s: 'Southern Front', - d: 'the Front closest to Defeat', - v: 'the Front closest to Victory', -}; +const front_names = [ + 'Aragon Front', + 'Madrid Front', + 'Northern Front', + 'Southern Front', + 'the Front closest to Defeat', + 'the Front closest to Victory', +]; const bonus_names: string[] = ['Morale Bonus', 'Teamwork Bonus']; @@ -585,12 +588,12 @@ export function setup(seed: number, _scenario: string, options: Record<string,bo bag_of_glory: [ANARCHISTS_ID, COMMUNISTS_ID, MODERATES_ID], bonuses: [ON, ON], current_events: [], - discard: { - a: [], - c: [], - m: [], - f: [], - }, + discard: [ + [], + [], + [], + [], + ], engine: [], faction_turn: null, fronts: [ @@ -617,42 +620,38 @@ export function setup(seed: number, _scenario: string, options: Record<string,bo ], glory: [], first_player: null, - hands: { - a: [], - c: [], - m: [], - }, + hands: [ + [], + [], + [], + ], hero_points: { - a: 2, - c: 2, - m: 0, - pool: 14, + factions: [2, 2, 0], + pool: 14 }, initiative: MODERATES_ID, medallions: { - a: [], - c: [], - m: [], + factions: [[],[],[]], pool: [], }, played_card: null, player_order: [MODERATE], - selected_cards: { - a: [], - c: [], - m: [], - }, - tableaus: { - a: [], - c: [], - m: [], - }, + selected_cards: [ + [], + [], + [], + ], + tableaus: [ + [], + [], + [], + ], tracks: [5, 5, 6, 3, 3], - trash: { - a: [], - c: [], - m: [], - }, + trash: [ + [], + [], + [], + ], triggered_track_effects: [], log: [], undo: [], @@ -1470,11 +1469,11 @@ states.draw_glory = { game.glory.push(faction); - game.glory_current_year = game.glory_current_year = { - a: false, - c: false, - m: false, - }; + game.glory_current_year = game.glory_current_year = [ + false, + false, + false, + ]; game.glory_current_year[faction] = true; @@ -1824,7 +1823,7 @@ states.peek_fascist_cards = { game.top_of_events_deck = c; for (const ec of game.fascist_cards) { if (ec !== c) { - game.discard.f.push(ec); + game.discard[FASCIST_ID].push(ec); } } delete game.fascist_cards; @@ -2708,11 +2707,11 @@ function end_of_year() { const glory_to_draw = [0, 1, 2, 5]; - game.glory_current_year = { - a: false, - c: false, - m: false, - }; + game.glory_current_year = [ + false, + false, + false, + ]; const player_order = get_player_order(); @@ -3423,7 +3422,7 @@ function lose_hero_points(faction: FactionId, value: number) { // #region FRONTS -function get_fronts_closest_to(target: 'd' | 'v'): FrontId[] { +function get_fronts_closest_to(target: ClosestToDefeat | ClosestToVictory): FrontId[] { const values = Object.values(game.fronts).reduce( (accrued: number[], current: Front) => { if (current.status === null) { @@ -3441,7 +3440,7 @@ function get_fronts_closest_to(target: 'd' | 'v'): FrontId[] { } const targetValue = - target === 'd' ? Math.min(...values) : Math.max(...values); + target === CLOSEST_TO_DEFEAT ? Math.min(...values) : Math.max(...values); return game.fronts.findIndex( (front) => front.value === targetValue ) as unknown as FrontId[]; @@ -3674,7 +3673,7 @@ function make_list(first: number, last: number): number[] { return list; } -function list_deck(id: FactionId | 'f') { +function list_deck(id: FactionId | FascistId) { const deck = []; const card_list: CardId[] = id === FASCIST_ID ? fascist_decks[game.year] : faction_cards[id]; |