From dcc99c931b22873cfbcec3f7848be1b691e6e76c Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 11 Feb 2024 14:08:39 +0100 Subject: Fix Wales forbidden to enemy intercept. --- rules.js | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/rules.js b/rules.js index b0588b5..0b47c40 100644 --- a/rules.js +++ b/rules.js @@ -6156,6 +6156,13 @@ function is_wales_forbidden(loc) { return false } +function is_wales_forbidden_to_enemy(loc) { + if (game.active !== LANCASTER && is_event_in_play(EVENT_YORK_OWAIN_GLYNDWR) && data.locales[loc].region === "Wales") + return true + return false +} + + function can_march_to(to) { if (is_wales_forbidden(to)) return false @@ -6307,21 +6314,26 @@ function end_march() { // === Interception === +function can_intercept_to(to) { + // TODO: forbid lancaster intercept into york moving to york, and vice versa + if (is_truce_in_effect()) + return false + if (is_wales_forbidden_to_enemy(to)) + return false + return true +} + function goto_intercept() { - if (!is_truce_in_effect()) { - let here = get_lord_locale(game.command) + let here = get_lord_locale(game.command) + if (can_intercept_to(here)) { for (let next of data.locales[here].not_paths) { - // TODO: forbid lancaster intercept into york moving to york, and vice versa if (has_enemy_lord(next)) { - // FIXME: wales forbidden _here_ rather than _next_ ??? - if (!is_wales_forbidden(next)) { - clear_undo() - game.state = "intercept" - set_active_enemy() - game.intercept_group = [] - game.who = NOBODY - return - } + clear_undo() + game.state = "intercept" + set_active_enemy() + game.intercept_group = [] + game.who = NOBODY + return } } } -- cgit v1.2.3