From d40f4d5eae30fd292ef0bffac7b6479291d5550a Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 17 Oct 2024 16:31:50 +0200 Subject: forbid illegal cross-map retreats --- rules.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 5461392..ab7b143 100644 --- a/rules.js +++ b/rules.js @@ -2202,6 +2202,17 @@ function search_retreat_distance(from, range) { return seen } +function is_illegal_cross_map_retreat(from, to) { + if ((is_flanders_space(from) && is_bohemia_space(to)) || (is_flanders_space(to) && is_bohemia_space(from))) { + for (let p of game.selected) { + let pow = piece_power[p] + if (pow !== P_FRANCE && pow !== P_AUSTRIA) + return true + } + } + return false +} + // search all possible retreat paths of given length function search_retreat_possible_dfs(result, seen, here, range) { for (let next of data.cities.adjacent[here]) { @@ -2209,6 +2220,8 @@ function search_retreat_possible_dfs(result, seen, here, range) { continue if (has_any_piece(next)) continue + if (is_illegal_cross_map_retreat(here, next)) + continue if (range === 1) { set_add(result, next) } else { -- cgit v1.2.3