summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-11-03 18:42:28 +0100
committerTor Andersson <tor@ccxvii.net>2024-11-03 18:42:28 +0100
commit4d2c2725385b7f929ba33015888ec10aaa81edbb (patch)
tree750a587baaa44a6532e1fab59a8168fc282ec476
parentdc5f239a7a4fef1547aae175b1d1a0105b748ca9 (diff)
downloadfriedrich-4d2c2725385b7f929ba33015888ec10aaa81edbb.tar.gz
Fix bad re-entry check that allowed entering on top of a supply train.HEADmaster
-rw-r--r--rules.js12
1 files 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