diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-05-25 18:08:35 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-05-30 21:59:25 +0200 |
commit | da247e3d238af2c8f45e3e6be191152beb821795 (patch) | |
tree | 843807bf1be831c012308eaa3c92c5f72e99bdbb | |
parent | c4e696d5c1267da976d9b125d9c12318493a5567 (diff) | |
download | friedrich-da247e3d238af2c8f45e3e6be191152beb821795.tar.gz |
tweak movement prompt
-rw-r--r-- | rules.js | 51 |
1 files changed, 45 insertions, 6 deletions
@@ -1293,25 +1293,51 @@ function is_supreme_commander(p) { return false } +function can_train_move_anywhere(p) { + let from = game.pos[p] + for (let to of data.cities.adjacent[from]) + if (can_move_train_to(to)) + return true + return false +} + +function can_general_move_anywhere(p) { + let from = game.pos[p] + for (let to of data.cities.adjacent[from]) + if (can_move_general_in_theory(to)) + return true + return false +} + states.movement = { prompt() { - let done = true + let done_generals = true + let done_trains = true + for (let p of all_power_generals[game.power]) { if (!set_has(game.moved, p) && is_supreme_commander(p) && game.pos[p] < ELIMINATED) { - gen_action_piece(p) - done = false + if (can_general_move_anywhere(p)) { + gen_action_piece(p) + done_generals = false + } } } for (let p of all_power_trains[game.power]) { if (!set_has(game.moved, p) && game.pos[p] < ELIMINATED) { - gen_action_piece(p) - done = false + if (can_train_move_anywhere(p)) { + gen_action_piece(p) + done_trains = false + } } } - if (done) + if (done_trains && done_generals) prompt("Movement done.") + else if (done_generals && !done_trains) + prompt("Move your supply trains.") + else if (!done_generals && done_trains) + prompt("Move your generals.") else prompt("Move your generals and supply trains.") @@ -1406,6 +1432,18 @@ function can_continue_train_from(_) { return true } +function can_move_general_in_theory(to) { + if (has_friendly_supply_train(to)) + return false + if (has_any_other_general(to)) + return false + if (has_enemy_supply_train(to) && forbid_capture(to)) + return false + if (count_pieces(to) >= 3) + return false + return true +} + function can_move_general_to(to) { if (has_friendly_supply_train(to)) return false @@ -1839,6 +1877,7 @@ states.move_general_OLD = { } } } + if (game.count < movement_range() + game.major) for (let next of data.cities.major_roads[here]) if (can_move_general_to(next)) |