summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/rules.js b/rules.js
index f8689d2..b004507 100644
--- a/rules.js
+++ b/rules.js
@@ -1780,10 +1780,6 @@ function search_own_supply_line_rec(path, here, ssrc, sline, sdist) {
let side = to_side(here, next, s)
- // must move closer (because we only search supply line for withdrawal purposes)
- if (sdist[next] > sdist[here] && side !== BARDIA_FT_CAPUZZO)
- continue
-
// must follow supply line
if (sline[side] === 0)
continue
@@ -2146,6 +2142,10 @@ function unit_has_supply_line(who) {
return false
}
+function is_move_closer(sdist, from, to, side) {
+ return side === BARDIA_FT_CAPUZZO || sdist[to] <= sdist[from]
+}
+
function can_unit_withdraw(who) {
let result = false
if (unit_has_supply_line(who)) {
@@ -2157,7 +2157,7 @@ function can_unit_withdraw(who) {
for_each_adjacent_hex(from, to => {
let side = to_side_id(from, to)
if (side_limit[side] > 0 && !has_enemy_unit(to))
- if (own_supply_line[side] && sdist[to] <= sdist[from])
+ if (own_supply_line[side] && is_move_closer(sdist, from, to, side))
result = true
})
}
@@ -2175,7 +2175,7 @@ function can_unit_disengage_and_withdraw(who) {
for_each_adjacent_hex(from, to => {
let side = to_side_id(from, to)
if (side_limit[side] > 0 && !is_enemy_hexside(side) && !has_undisrupted_enemy_unit(to))
- if (own_supply_line[side] && sdist[to] <= sdist[from])
+ if (own_supply_line[side] && is_move_closer(sdist, from, to, side))
result = true
})
}