diff options
author | Tor Andersson <tor@ccxvii.net> | 2025-04-08 01:53:04 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2025-04-08 01:53:04 +0200 |
commit | 35c015787f4226af029d7fd727e2c7193853bf90 (patch) | |
tree | 1f42b3a72d060392947168a8c79f68778d55496d /rules.ts | |
parent | 8ef50da1a723ad59c008c5adbb41ee43de9c359b (diff) | |
download | land-and-freedom-35c015787f4226af029d7fd727e2c7193853bf90.tar.gz |
check if hero points can be spent before showing the "Use HP" button.
Diffstat (limited to 'rules.ts')
-rw-r--r-- | rules.ts | 43 |
1 files changed, 39 insertions, 4 deletions
@@ -159,12 +159,47 @@ function gen_action_medallion(medallion_id: number) { gen_action('medallion', medallion_id); } +function can_spend_any_hero_points(faction) { + let hero_points = game.hero_points[faction]; + if (hero_points >= 1) { + if (can_draw_any_hand_cards(faction)) + return true; + if (can_use_medallion(ARCHIVES_MEDALLION_ID, faction) && game.triggered_track_effects.length > 0) + return true; + if (can_use_medallion(VOLUNTEERS_MEDALLION_ID, faction)) + return true; + if (hero_points >= 2) { + if (game.bonuses[0] === OFF) + return true; + if (game.bonuses[1] === OFF) + return true; + if (can_move_track_up(FOREIGN_AID)) + return true; + if (can_move_track_up(SOVIET_SUPPORT)) + return true; + if (hero_points >= 3) { + if (can_move_track_up(COLLECTIVIZATION)) + return true; + if (can_move_track_up(LIBERTY)) + return true; + if (hero_points >= 4) { + if (can_move_track_up(GOVERNMENT)) + return true; + } + } + } + } + return false; +} + function gen_spend_hero_points() { const faction = get_active_faction(); - const can_spend_hp = - game.faction_turn === faction && game.hero_points[faction] > 0; - if (can_spend_hp) { - gen_action('spend_hp'); + if (game.faction_turn === faction) { + if (can_spend_any_hero_points(faction)) { + view.actions['spend_hp'] = 1; + } else { + view.actions['spend_hp'] = 0; + } } } |