diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 54 |
1 files changed, 33 insertions, 21 deletions
@@ -1,5 +1,7 @@ "use strict" +// TODO: log end victory conditions at scenario start + // FIXME: lift_sieges / besieged needs checking! (automatic after disband_lord, manual after move/sail, extra careful manual after battle) // FIXME: remove_legate_if_endangered needs checking! (automatic after disband_lord, manual after move/sail, manual after battle) @@ -11,6 +13,7 @@ const data = require("./data.js") const AUTOWALK = true +const AUTOSTRIKE = false const BOTH = "Both" const TEUTONS = "Teutons" @@ -8422,26 +8425,27 @@ states.assign_left_right = { function goto_strike_group() { game.state = "strike_group" - // Auto-strike if only one group - let first_striker = -1 - let first_target = -1 - let target - for (let pos of current_strike_positions()) { - if (has_strike(pos)) { - if ((pos === SA1 || pos === SA2 || pos === SA3) && is_sa_without_rg()) - target = 100 // just a unique target id - else - target = find_strike_target(pos) - if (first_target < 0) { - first_striker = pos - first_target = target - } else if (first_target !== target) { - return // more than one target! + if (AUTOSTRIKE) { + // Auto-strike if only one group + let first_striker = -1 + let first_target = -1 + let target + for (let pos of current_strike_positions()) { + if (has_strike(pos)) { + if ((pos === SA1 || pos === SA2 || pos === SA3) && is_sa_without_rg()) + target = 100 // just a unique target id + else + target = find_strike_target(pos) + if (first_target < 0) { + first_striker = pos + first_target = target + } else if (first_target !== target) { + return // more than one target! + } } } + select_strike_group(first_striker) } - - select_strike_group(first_striker) } function select_strike_group(pos) { @@ -8462,14 +8466,22 @@ states.strike_group = { return format_strike_step() + " \u2014 Strike" }, prompt() { - view.prompt = `${format_strike_step()}: Strike with a Lord.` - for (let pos of current_strike_positions()) - if (has_strike(pos)) - gen_action_lord(game.battle.array[pos]) + if (is_defender_step() && has_garrison() && !filled(D2)) { + view.prompt = `${format_strike_step()}: Strike with Garrison.` + view.actions.garrison = 1 + } else { + view.prompt = `${format_strike_step()}: Strike with a Lord.` + for (let pos of current_strike_positions()) + if (has_strike(pos)) + gen_action_lord(game.battle.array[pos]) + } }, lord(lord) { select_strike_group(get_lord_array_position(lord)) }, + garrison() { + select_strike_group(-1) + }, } // === BATTLE: TOTAL HITS (ROUND UP) === |