summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-12-16 00:44:59 +0100
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:19:39 +0100
commit697e5d2bca776817d5116db727164d1ed5cc6692 (patch)
tree8cf4d7a4c86ca82cdf47d797a337aa36619b6a65
parent66888ec763698f5621860596876ff20c99b796dc (diff)
downloadcrusader-rex-697e5d2bca776817d5116db727164d1ed5cc6692.tar.gz
crusader: Fix bug where storming units eliminate defending force.
The castle should swap hands and the storming should be canceled.
-rw-r--r--rules.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/rules.js b/rules.js
index eadd88b..0e33e12 100644
--- a/rules.js
+++ b/rules.js
@@ -2877,6 +2877,16 @@ function resume_siege_battle() {
return goto_regroup();
}
+ if (count_blocks_in_castle(game.where) === 0) {
+ log("Defending main force was eliminated.");
+ log(game.active + " are now the defender.");
+ game.attacker[game.where] = enemy(game.active);
+ // The new defender takes control of the empty castle
+ game.castle_owner = game.active;
+ game.storming.length = 0;
+ return next_combat_round();
+ }
+
if (game.storming.length === 0) {
game.halfhit = null;
log("Storming repulsed.");