From 7ee88861864e35f894bd45877a7f997715193252 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 21 Jan 2024 21:12:26 +0100 Subject: Fix bug when recapturing fortress with leader captured inside. --- rules.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rules.js b/rules.js index 947f71a..bd820ab 100644 --- a/rules.js +++ b/rules.js @@ -1864,6 +1864,7 @@ function capture_enemy_fortress(s) { function recapture_french_fortress(s) { log(`France recaptured fortress at %${s}.`) + set_all_pieces_outside(s) set_delete(game.british.fortresses, s) set_add(game.french.fortresses, s) award_french_vp(3) @@ -1871,6 +1872,7 @@ function recapture_french_fortress(s) { function recapture_british_fortress(s) { log(`Britain recaptured fortress at %${s}.`) + set_all_pieces_outside(s) set_delete(game.french.fortresses, s) set_add(game.british.fortresses, s) award_british_vp(3) @@ -1921,14 +1923,18 @@ function is_fort_or_fortress_vacant_of_besieging_units(s) { return !has_french_units(s) } +function set_all_pieces_outside(s) { + for (let p = 1; p <= last_piece; ++p) + if (is_piece_in_space(p, s)) + set_piece_outside(p) +} + function lift_sieges_and_amphib() { // Lift sieges for_each_siege(s => { if (is_fort_or_fortress_vacant_of_besieging_units(s)) { log(`Lifted siege at %${s}.`) - for (let p = 1; p <= last_piece; ++p) - if (is_piece_in_space(p, s)) - set_piece_outside(p) + set_all_pieces_outside(s) delete game.sieges[s] } }) -- cgit v1.2.3