summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-04-10 11:47:00 +0200
committerTor Andersson <tor@ccxvii.net>2024-04-10 11:49:43 +0200
commitfebe6f5a96f1d9c05a4d7f4eef75bf6240425ec0 (patch)
treec7458e9069db451687521162bb8d1ba64f474830 /rules.js
parent83425aeb8cf2f10015491721c4c46375f262d600 (diff)
downloadcrusader-rex-febe6f5a96f1d9c05a4d7f4eef75bf6240425ec0.tar.gz
Skip combat round when relief arrive after main defenders sailed away.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/rules.js b/rules.js
index 7b5d704..0b68ade 100644
--- a/rules.js
+++ b/rules.js
@@ -2442,6 +2442,19 @@ function goto_combat_round(new_combat_round) {
let was_contested = is_contested_battle_field()
+ // If a relief force attacks besieging forces outside a castle,
+ // but the besieged forces sail away and abandon the castle,
+ // skip the first combat round to let the battle proceed from
+ // when the reserves arrive.
+ if (game.combat_round === 1 && !is_under_siege(game.where)) {
+ if (!was_contested && is_contested_town(game.where)) {
+ if (count_friendly_in_field_excluding_reserves(game.where) === 0) {
+ log("Combat round skipped because main attack sailed away.")
+ game.combat_round = 2
+ }
+ }
+ }
+
// If the main attack regroups away from a new siege while reinforcements
// are on the way, we need to skip the first combat round.
if (game.combat_round === 1 && is_under_siege(game.where)) {