summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-04-15 11:22:21 +0200
committerTor Andersson <tor@ccxvii.net>2023-04-15 11:22:21 +0200
commit243c18f8eb1309e03834f49508451c882c703792 (patch)
tree59008c78401a4eee4988ab8e51d2985345ad48c7
parent9ef2ffdcd58a313230332aa07e96e7414820bccc (diff)
downloadwilderness-war-243c18f8eb1309e03834f49508451c882c703792.tar.gz
Fix off-by-one in infiltration move termination check.
-rw-r--r--rules.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/rules.js b/rules.js
index fbb1b0e..edccf06 100644
--- a/rules.js
+++ b/rules.js
@@ -1,6 +1,6 @@
"use strict"
-// TODO: "danger_space" action for moving into interception/battle
+// TODO: don't allow activating force in Halifax/captured Louisbourg without a 3-value card (nothing to do but sail)
// WONTFIX
// TODO: select leader for defense instead of automatically picking the best
@@ -3107,7 +3107,7 @@ function can_infiltrate_search(type, used, carry, from, to) {
}
// Continue looking.
- if (used < max_movement_cost(type)) {
+ if (used + 1 < max_movement_cost(type)) {
for (let next of spaces[to].exits) {
if (can_infiltrate_search(type, used + 1, carry, to, next))
return true
@@ -3186,6 +3186,8 @@ function apply_move(to) {
let who = moving_piece()
let from = moving_piece_space()
+ let maybe_infiltrated = is_lone_auxiliary(who) && can_infiltrate(from, to)
+
if (game.move.type === 'naval')
game.move.used = 9
else
@@ -3236,21 +3238,21 @@ function apply_move(to) {
game.move.infiltrated = 0
if (has_enemy_stockade(to)) {
- if (is_lone_auxiliary(who) && can_infiltrate(from, to))
+ if (maybe_infiltrated)
game.move.infiltrated = 1
else
stop_move()
}
if (has_unbesieged_enemy_fort_or_fortress(to)) {
- if (is_lone_auxiliary(who) && can_infiltrate(from, to))
+ if (maybe_infiltrated)
game.move.infiltrated = 1
else
stop_move()
}
if (has_unbesieged_enemy_units(to)) {
- if (is_lone_auxiliary(who) && can_infiltrate(from, to))
+ if (maybe_infiltrated)
game.move.infiltrated = 1
}