From ce2ee94f3c26a83cbf0ce6fe523f90ee05fd409f Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 25 Sep 2024 23:50:04 +0200 Subject: Rule 8.12: defending leaders inside fort do not take part in battle. --- rules.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3