diff options
author | Frans Bongers <fransbongers@franss-mbp.home> | 2025-01-03 21:08:25 +0100 |
---|---|---|
committer | Frans Bongers <fransbongers@franss-mbp.home> | 2025-01-03 21:08:25 +0100 |
commit | ec286d358a362869ef02a263b6553ee4e527a216 (patch) | |
tree | 9600e0bc9d0663967038106cf7975e8a8b918b5c /rules.js | |
parent | 51d3c52ad03931e01a2f0c9e643f7a67286f9044 (diff) | |
download | land-and-freedom-ec286d358a362869ef02a263b6553ee4e527a216.tar.gz |
fix: player can choose order for Moral Bonus and Action Points
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 71 |
1 files changed, 50 insertions, 21 deletions
@@ -182,7 +182,6 @@ function start_of_player_turn() { resolve_active_and_proceed(); } const engine_functions = { - check_activate_icon, checkpoint, end_of_player_turn, end_of_turn, @@ -234,7 +233,7 @@ function get_active_node(engine = game.engine) { function get_active_node_args() { const node = get_active_node(game.engine); if (node.t === leaf_node || node.t === function_node) { - return node.a; + return node.a ?? {}; } return null; } @@ -1238,23 +1237,42 @@ states.player_turn = { prompt() { gen_spend_hero_points(); const faction_id = get_active_faction(); + const { use_ap, use_morale_bonus } = get_active_node_args(); const can_spend_hp = game.faction_turn === faction_id && game.hero_points[faction_id] > 0; const can_play_card = game.selected_cards[faction_id].length > 0; - view.prompt = 'Play a card or spend Hero points'; - if (!(can_play_card || can_spend_hp)) { - view.prompt = 'End turn'; - } - else if (!can_play_card && can_spend_hp) { - view.prompt = 'Spend Hero Points or end turn'; + if (can_play_card && can_spend_hp) { + view.prompt = 'Play a card or spend Hero points'; } else if (can_play_card && !can_spend_hp) { view.prompt = 'Play a card'; } + else if (can_spend_hp || use_ap || use_morale_bonus) { + const text_options = []; + if (use_ap) { + text_options.push('Action Points'); + } + if (use_morale_bonus) { + text_options.push('Morale Bonus'); + } + if (can_spend_hp) { + text_options.push('Hero points'); + } + view.prompt = `Use ${text_options.join(', ')} or end turn`; + } + else { + view.prompt = 'End turn'; + } if (can_play_card) { gen_action('play_for_ap'); gen_action('play_for_event'); } - else { + if (use_ap) { + gen_action('use_ap'); + } + if (use_morale_bonus && game.bonuses[data_1.MORALE_BONUS] === data_1.ON) { + gen_action('use_morale_bonus'); + } + if (!can_play_card && !use_ap) { gen_action('done'); } }, @@ -1269,12 +1287,11 @@ states.player_turn = { play_for_ap() { const faction = get_active_faction(); const { strength } = play_card(faction, 'play_for_ap'); - insert_before_active_node(create_seq_node([ - create_leaf_node('choose_area_ap', faction, { - strength, - }), - create_function_node('check_activate_icon'), - ])); + update_active_node_args({ + use_morale_bonus: true, + use_ap: true, + strength, + }); next(); }, play_for_event() { @@ -1283,6 +1300,24 @@ states.player_turn = { insert_before_active_node(create_effects_node(effects)); next(); }, + use_ap() { + const faction = get_active_faction(); + const { strength } = get_active_node_args(); + update_active_node_args({ + use_ap: false, + }); + insert_before_active_node(create_leaf_node('choose_area_ap', faction, { + strength, + })); + next(); + }, + use_morale_bonus() { + update_active_node_args({ + use_morale_bonus: false, + }); + insert_before_active_node(create_leaf_node('activate_icon', get_active_faction())); + next(); + }, }; states.remove_blank_marker = { inactive: 'remove a Blank marker', @@ -1741,12 +1776,6 @@ function add_glory(faction, amount, indent = false) { log_h3(text); } } -function check_activate_icon() { - if (game.bonuses[data_1.MORALE_BONUS] === data_1.ON) { - insert_after_active_node(create_leaf_node('activate_icon', get_active_faction())); - } - resolve_active_and_proceed(); -} function check_initiative() { let initiative; if (game.tracks[data_1.LIBERTY] >= 6 && game.tracks[data_1.COLLECTIVIZATION] >= 6) { |