diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-10-17 01:21:11 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-10-17 01:21:11 +0200 |
commit | e654baad3c06b56b6076688b11bfb0e6ef9ea84f (patch) | |
tree | 5de881a380e96199660c5b925441153efa782697 | |
parent | a9b211ca1e938b56acf24d16a9b9aa68fe5ad67d (diff) | |
download | maria-e654baad3c06b56b6076688b11bfb0e6ef9ea84f.tar.gz |
Only French and Austrian pieces may move from Flanders to Bohemia and vv.
-rw-r--r-- | rules.js | 33 |
1 files changed, 17 insertions, 16 deletions
@@ -1061,7 +1061,7 @@ function can_train_move_anywhere(p) { 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(p, to)) + if (can_move_general_to(from, to)) return true return false } @@ -1158,26 +1158,25 @@ function can_move_train_to(to) { return !has_any_piece(to) } -function can_move_general_in_theory(_p, to) { - if (has_friendly_supply_train(to)) - return false - if (has_non_cooperative_general(to)) - return false - if (has_enemy_supply_train(to)) - return false - if (count_generals(to) >= 2) - return false - return true +function is_illegal_cross_map_move(from, to) { + return ( + game.power !== P_FRANCE && game.power !== P_AUSTRIA && ( + (is_flanders_space(from) && is_bohemia_space(to)) || + (is_flanders_space(to) && is_bohemia_space(from)) + ) + ) } -function can_move_general_to(to) { +function can_move_general_to(from, to) { + if (is_illegal_cross_map_move(from, to)) + return false if (has_friendly_supply_train(to)) return false if (has_non_cooperative_general(to)) return false if (has_enemy_supply_train(to)) return false - if (game.selected.length + count_generals(to) > 2) + if (count_generals(to) >= 2) return false return true } @@ -1335,12 +1334,12 @@ states.move_general = { if (game.count < movement_range() + game.main) for (let next of data.cities.main_roads[here]) - if (can_move_general_to(next)) + if (can_move_general_to(here, next)) gen_action_space_or_piece(next) if (game.count < movement_range()) for (let next of data.cities.roads[here]) - if (can_move_general_to(next)) + if (can_move_general_to(here, next)) gen_action_space_or_piece(next) }, take() { @@ -1400,10 +1399,12 @@ function search_force_march(came_from, start) { continue if (is_enemy_controlled_fortress(next)) continue - if (has_any_piece(next)) + if (has_enemy_piece(next)) continue if (is_adjacent_to_enemy_piece(next)) continue + if (!can_move_general_to(here, next)) + continue if (came_from) map_set(came_from, next, here) set_add(seen, next) |