diff options
-rw-r--r-- | rules.js | 42 | ||||
-rw-r--r-- | rules.ts | 43 |
2 files changed, 78 insertions, 7 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']; @@ -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; + } } } |