From 1738326b21f02a1a4cd246b85026bc3f846511df Mon Sep 17 00:00:00 2001 From: Frans Bongers Date: Wed, 19 Mar 2025 22:09:20 +0100 Subject: refactor: FactionId to number --- rules.ts | 119 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 59 insertions(+), 60 deletions(-) (limited to 'rules.ts') diff --git a/rules.ts b/rules.ts index 1e2ff94..2b858c7 100644 --- a/rules.ts +++ b/rules.ts @@ -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 = { - a: ANARCHIST, - c: COMMUNIST, - m: MODERATE, -}; +const faction_player_map: Record = [ + ANARCHIST, + COMMUNIST, + MODERATE, +]; const player_faction_map: Record = { [ANARCHIST]: ANARCHISTS_ID, @@ -88,14 +91,14 @@ const player_faction_map: Record = { [MODERATE]: MODERATES_ID, }; -const front_names: Record = { - 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 { 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]; -- cgit v1.2.3