summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/rules.js b/rules.js
index ab8c5c6..61dad6b 100644
--- a/rules.js
+++ b/rules.js
@@ -1653,6 +1653,15 @@ function moving_piece_came_from() {
return game.move.came_from
}
+function find_friendly_unbesieged_commanding_leader_in_space(s) {
+ let commander = 0
+ for (let p = first_friendly_leader; p <= last_friendly_leader; ++p)
+ if (is_piece_unbesieged_in_space(p, s))
+ if (!commander || leader_command(p) > leader_command(commander))
+ commander = p
+ return commander
+}
+
function find_friendly_commanding_leader_in_space(s) {
let commander = 0
for (let p = first_friendly_leader; p <= last_friendly_leader; ++p)
@@ -4997,7 +5006,11 @@ function goto_def_fire() {
log(".b Defender")
let die = game.battle.def_die = roll_die()
- let p = find_friendly_commanding_leader_in_space(game.battle.where)
+ let p = 0
+ if (game.battle.assault)
+ p = find_friendly_commanding_leader_in_space(game.battle.where)
+ else
+ p = find_friendly_unbesieged_commanding_leader_in_space(game.battle.where)
if (p) {
log(">D" + die + " + " + leader_tactics_text(p))
die += leader_tactics(p)