diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-11-03 18:42:28 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-11-03 18:42:28 +0100 |
commit | 4d2c2725385b7f929ba33015888ec10aaa81edbb (patch) | |
tree | 750a587baaa44a6532e1fab59a8168fc282ec476 | |
parent | dc5f239a7a4fef1547aae175b1d1a0105b748ca9 (diff) | |
download | friedrich-4d2c2725385b7f929ba33015888ec10aaa81edbb.tar.gz |
-rw-r--r-- | rules.js | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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 |