From 243c18f8eb1309e03834f49508451c882c703792 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 15 Apr 2023 11:22:21 +0200 Subject: Fix off-by-one in infiltration move termination check. --- rules.js | 12 +++++++----- 1 file 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 } -- cgit v1.2.3