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.js | |
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.js')
-rw-r--r-- | rules.js | 42 |
1 files changed, 39 insertions, 3 deletions
@@ -69,11 +69,47 @@ function gen_action_front(front_id) { function gen_action_medallion(medallion_id) { 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(data_1.ARCHIVES_MEDALLION_ID, faction) && game.triggered_track_effects.length > 0) + return true; + if (can_use_medallion(data_1.VOLUNTEERS_MEDALLION_ID, faction)) + return true; + if (hero_points >= 2) { + if (game.bonuses[0] === data_1.OFF) + return true; + if (game.bonuses[1] === data_1.OFF) + return true; + if (can_move_track_up(data_1.FOREIGN_AID)) + return true; + if (can_move_track_up(data_1.SOVIET_SUPPORT)) + return true; + if (hero_points >= 3) { + if (can_move_track_up(data_1.COLLECTIVIZATION)) + return true; + if (can_move_track_up(data_1.LIBERTY)) + return true; + if (hero_points >= 4) { + if (can_move_track_up(data_1.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; + } } } const multiactive_states = ['choose_card', 'end_of_year_discard', 'choose_final_bid']; |