summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-02-28 19:29:07 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 11:54:52 +0100
commit5e5182f8add08874664257e6367299df8176e01b (patch)
treeaa4dec7c4bec66e0e968183994db4c88733b6f18 /rules.js
parentd3b268f9ac46b65f783178a6a96653a858601812 (diff)
downloadwilderness-war-5e5182f8add08874664257e6367299df8176e01b.tar.gz
Bring out the withdrawn after failed attack on fort.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/rules.js b/rules.js
index 7cfe13d..3b0a58f 100644
--- a/rules.js
+++ b/rules.js
@@ -4579,7 +4579,6 @@ function determine_winner_battle() {
log("");
-
// 7.8: Determine winner
let atk_eliminated = count_attacking_units() === 0;
let def_eliminated = count_unbesieged_enemy_units_in_space(where) === 0;
@@ -4604,6 +4603,12 @@ function determine_winner_battle() {
victor = game.battle.defender;
}
+ log("");
+ if (victor === game.battle.attacker)
+ log("ATTACKER WON");
+ else
+ log("DEFENDER WON");
+
if (victor === game.battle.attacker && game.battle.atk_worth_vp) {
if (victor === FRANCE)
award_french_vp(1);
@@ -4625,10 +4630,8 @@ function determine_winner_battle() {
// Raid battle vs militia
if (game.raid && game.raid.where > 0) {
if (victor === game.battle.attacker) {
- log("ATTACKER WON RAID BATTLE VS MILITIA");
goto_raid_events();
} else {
- log("DEFENDER WON RAID BATTLE VS MILITIA");
if (game.battle.atk_pcs.length > 0)
retreat_attacker(game.raid.where, game.raid.from[game.raid.where] | 0);
else
@@ -4638,10 +4641,6 @@ function determine_winner_battle() {
}
// Normal battle
- if (victor === game.battle.attacker)
- log("ATTACKER WON");
- else
- log("DEFENDER WON");
// 6.712 - Infiltrator must always retreat from fort/fortress even if they win
if (game.move.infiltrated && has_unbesieged_enemy_fort_or_fortress(game.battle.where))
@@ -4659,6 +4658,14 @@ function determine_winner_battle() {
}
}
} else {
+ /* If attacker must retreat, unbesieged defenders who withdrew inside can come out. */
+ if (!is_space_besieged(where)) {
+ console.log("not besieged, attacker lost, coming out!");
+ for (let p = first_piece; p <= last_piece; ++p)
+ if (is_piece_in_space(p, where) && is_piece_inside(p))
+ set_piece_outside(p);
+ }
+
if (game.battle.atk_pcs.length > 0) {
unstack_force(moving_piece());
retreat_attacker(game.battle.where, moving_piece_came_from());