summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-07-13 13:14:42 +0200
committerTor Andersson <tor@ccxvii.net>2023-02-18 11:54:52 +0100
commit6a29729abc39ba5e2c9e333d3fcfe7ed0c9bc833 (patch)
treea1de9810af10136b54208338d110a6d0e67b21a8 /rules.js
parent1885656ef66700c4ad50cc71450ddf41fcde0b5d (diff)
downloadwilderness-war-6a29729abc39ba5e2c9e333d3fcfe7ed0c9bc833.tar.gz
Retreat lone leaders who are left behind at a siege when moving out.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/rules.js b/rules.js
index 4ebef45..d660311 100644
--- a/rules.js
+++ b/rules.js
@@ -3691,6 +3691,16 @@ function gen_intercept() {
}
function goto_intercept() {
+ // Abandoned lone leader at formerly besieged fortification with enemy units...
+ let from = moving_piece_came_from()
+ if (has_unbesieged_friendly_leader(from) && !has_unbesieged_friendly_units(from)) {
+ if (has_unbesieged_enemy_units(from)) {
+ game.state = 'retreat_lone_leader'
+ game.retreat = { from: from, reason: 'abandon' }
+ return
+ }
+ }
+
if (can_be_intercepted()) {
game.move.intercepting = 0
set_active_enemy()
@@ -5343,7 +5353,7 @@ function can_defender_retreat_from_to(p, from, to) {
if (has_unbesieged_enemy_fortifications(to))
return false
if (game.move && moving_piece_came_from() === to)
- if (!game.retreat || game.retreat.reason !== 'friendly_move')
+ if (!game.retreat || game.retreat.reason !== 'friendly_move' || game.retreat.reason !== 'abandon')
return false
if (force_has_drilled_troops(p)) {
if (is_cultivated(to) || has_friendly_fortifications(to))
@@ -5637,6 +5647,10 @@ function resume_retreat_lone_leader(from) {
delete game.retreat
resume_move()
break
+ case 'abandon':
+ delete game.retreat
+ goto_intercept()
+ break
}
}
}