summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js71
1 files changed, 50 insertions, 21 deletions
diff --git a/rules.js b/rules.js
index 3b1b8e9..89ae075 100644
--- a/rules.js
+++ b/rules.js
@@ -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) {