From 4d2c2725385b7f929ba33015888ec10aaa81edbb Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 3 Nov 2024 18:42:28 +0100 Subject: Fix bad re-entry check that allowed entering on top of a supply train. --- rules.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rules.js b/rules.js index 6280bbe..e73d709 100644 --- a/rules.js +++ b/rules.js @@ -230,7 +230,8 @@ const all_power_trains = [ const TRAIN_IA = 32 const all_pieces = [ ...all_power_generals.flat(), ...all_power_trains.flat() ] -const all_generals = [ ...all_power_generals.flat() ] +const all_generals = all_power_generals.flat() +const all_trains = all_power_trains.flat() const all_prussia_trains = [ ...all_power_trains[P_PRUSSIA], @@ -751,6 +752,13 @@ function has_any_piece(to) { return false } +function has_any_supply_train(to) { + for (let p of all_trains) + if (game.pos[p] === to) + return true + return false +} + function has_friendly_supply_train(to) { for (let p of all_friendly_trains[game.power]) if (game.pos[p] === to) @@ -1910,7 +1918,7 @@ function has_available_depot() { } function can_re_enter_general(to) { - if (has_friendly_supply_train(to)) + if (has_any_supply_train(to)) return false if (has_any_other_general(to)) return false -- cgit v1.2.3