From 7ed5936e81547858673806c9092ff0b370a9e656 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 19 Mar 2025 23:11:44 +0100 Subject: Put pool after factions in medallions and hero_points lists. --- rules.ts | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'rules.ts') diff --git a/rules.ts b/rules.ts index 2b858c7..0e50af6 100644 --- a/rules.ts +++ b/rules.ts @@ -77,6 +77,8 @@ const states = {} as States; let game = {} as Game; // = null var view = {} as View; // = null +const POOL_ID = 3; + const role_ids: FactionId[] = [ANARCHISTS_ID, COMMUNISTS_ID, MODERATES_ID]; const faction_player_map: Record = [ @@ -111,11 +113,13 @@ const { const bonuses = [MORALE_BONUS, TEAMWORK_BONUS]; -const faction_cards = { - [ANARCHISTS_ID]: make_list(37, 54) as CardId[], - [COMMUNISTS_ID]: make_list(19, 36) as CardId[], - [MODERATES_ID]: make_list(1, 18) as CardId[], -}; +const faction_cards = [ + make_list(37, 54) as CardId[], + make_list(19, 36) as CardId[], + make_list(1, 18) as CardId[], +]; + +console.log(faction_cards) const fascist_decks = { 1: make_list(55, 72) as CardId[], @@ -625,15 +629,9 @@ export function setup(seed: number, _scenario: string, options: Record m !== null)) { + if (!game.medallions[POOL_ID].some((m) => m !== null)) { gen_action('skip'); } }, @@ -1379,9 +1377,9 @@ states.choose_medallion = { logp(`earned ${medallion.name}`); - const index = game.medallions.pool.indexOf(m); + const index = game.medallions[POOL_ID].indexOf(m); - game.medallions.pool[index] = null; + game.medallions[POOL_ID][index] = null; switch (m) { case 0: @@ -1557,7 +1555,7 @@ states.hero_points = { gen_action('lose_hp'); return; } - if (game.hero_points.pool > 0) { + if (game.hero_points[POOL_ID] > 0) { view.prompt = value > 1 ? `Fascist Test: Gain ${value} Hero points.` : 'Fascist Test: Gain 1 Hero point.'; gen_action('gain_hp'); @@ -2778,7 +2776,7 @@ function gain_hero_points( value: number, skip_abilities = false // Used to prevent gaining of extra hero points when taking them from another player ) { - if (game.hero_points.pool === 0) { + if (game.hero_points[POOL_ID] === 0) { return; } if ( @@ -2802,8 +2800,8 @@ function gain_hero_points( (ability) => ability !== COMMUNIST_EXTRA_HERO_POINT ); } - const gain = Math.min(game.hero_points.pool, value); - game.hero_points.pool -= gain; + const gain = Math.min(game.hero_points[POOL_ID], value); + game.hero_points[POOL_ID] -= gain; game.hero_points[faction_id] += gain; logi(`${get_player(faction_id)} +${gain} HP`); } @@ -3070,7 +3068,7 @@ function move_track_to(track_id: number, new_value: number) { function pay_hero_points(faction: FactionId, amount: number) { game.hero_points[faction] -= amount; - game.hero_points.pool += amount; + game.hero_points[POOL_ID] += amount; } function can_use_medallion(medallion_id: number, faction?: FactionId) { @@ -3412,7 +3410,7 @@ function draw_fascist_card(): CardId { function lose_hero_points(faction: FactionId, value: number) { const points_lost = Math.min(game.hero_points[faction], Math.abs(value)); - game.hero_points.pool += points_lost; + game.hero_points[POOL_ID] += points_lost; game.hero_points[faction] -= points_lost; if (points_lost !== 0) logi(`${get_player(faction)} -${points_lost} HP`); @@ -3701,7 +3699,7 @@ function draw_medallions() { let i = random(medallion_ids.length); let r = medallion_ids[i] as CardId; set_delete(medallion_ids, r); - game.medallions.pool.push(r); + game.medallions[POOL_ID].push(r); logi("M" + r) } } -- cgit v1.2.3