summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-05-19 16:58:43 +0200
committerTor Andersson <tor@ccxvii.net>2023-05-19 16:58:43 +0200
commit712fdea3e8e8694996db89eff462018a11b2a133 (patch)
tree7dcd1a379e4eee3ef6bc6254304fbb25112e733a
parentf0ebf3db1d67690febf8da2fcc408354a3017aec (diff)
downloadwilderness-war-712fdea3e8e8694996db89eff462018a11b2a133.tar.gz
Handle corner cases with Surrender and no available destinations.
Allow Louisbourg as a last resort. Eliminate otherwise.
-rw-r--r--rules.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/rules.js b/rules.js
index 7f30a1b..6ddbb46 100644
--- a/rules.js
+++ b/rules.js
@@ -5950,10 +5950,14 @@ function goto_surrender_place() {
set_active_enemy()
if (has_friendly_units(game.siege_where)) {
game.state = 'surrender'
- if (game.siege_where === LOUISBOURG)
+ if (game.siege_where === LOUISBOURG) {
game.surrender = find_closest_friendly_unbesieged_fortification(QUEBEC)
- else
+ } else {
game.surrender = find_closest_friendly_unbesieged_fortification(game.siege_where)
+ if (game.surrender.length === 0)
+ if (has_unbesieged_friendly_fortifications(LOUISBOURG))
+ game.surrender.push(LOUISBOURG)
+ }
} else {
end_surrender()
}
@@ -5968,13 +5972,21 @@ states.surrender = {
view.where = game.siege_where
for (let i=0; i < game.surrender.length; ++i)
gen_action_space(game.surrender[i])
+ if (game.surrender.length === 0)
+ gen_action('eliminate')
},
space(s) {
for (let p = first_friendly_piece; p <= last_friendly_piece; ++p)
if (piece_node(p) === game.siege_where)
move_piece_to(p, s)
end_surrender()
- }
+ },
+ eliminate() {
+ for (let p = first_friendly_piece; p <= last_friendly_piece; ++p)
+ if (piece_node(p) === game.siege_where)
+ eliminate_piece(p)
+ end_surrender()
+ },
}
function end_surrender() {