summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-09-25 23:50:04 +0200
committerTor Andersson <tor@ccxvii.net>2024-09-25 23:50:04 +0200
commitce2ee94f3c26a83cbf0ce6fe523f90ee05fd409f (patch)
tree94c55270b1dff977c6d3ee96601361bc8c224801
parentc142bc2777dec3ede8617df416bb4cd83b4525cf (diff)
downloadwilderness-war-ce2ee94f3c26a83cbf0ce6fe523f90ee05fd409f.tar.gz
Rule 8.12: defending leaders inside fort do not take part in battle.
-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)