diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-08-27 20:27:53 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-08-27 20:27:53 +0200 |
commit | 844083a6c12cbda865be5c728e34a2943f77be92 (patch) | |
tree | 446e3958635cb46e7280476c8cc2e666eb57042e | |
parent | 5b049d653cf3f2696ecfdd4d86ed307d81180b7a (diff) | |
download | washingtons-war-844083a6c12cbda865be5c728e34a2943f77be92.tar.gz |
fix Quebec-Falmouth check for retreats
-rw-r--r-- | rules.js | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -2497,13 +2497,15 @@ function can_retreat_before_battle() { return false for (let to of SPACES[here].adjacent) - if (can_retreat_before_battle_to(to)) + if (can_retreat_before_battle_to(g, here, to)) return true return false } -function can_retreat_before_battle_to(to) { +function can_retreat_before_battle_to(g, from, to) { + if (is_quebec_falmouth_path(from, to) && g !== ARNOLD) + return false if (to === game.move.from) return false if (has_friendly_pc(to)) @@ -3037,7 +3039,9 @@ function resolve_battle() { /* RETREAT AFTER BATTLE */ -function can_defender_retreat(to, is_lone) { +function can_defender_retreat(g, from, to, is_lone) { + if (is_quebec_falmouth_path(from, to) && g !== ARNOLD) + return false if (to === game.move.from) return false if (has_enemy_pc(to)) @@ -3050,7 +3054,11 @@ function can_defender_retreat(to, is_lone) { } function can_attacker_retreat() { + let g = game.move.who + let from = game.move.to let to = game.move.from + if (is_quebec_falmouth_path(from, to) && g !== ARNOLD) + return false if (has_enemy_pc(to)) return false if (has_enemy_cu(to)) @@ -3075,14 +3083,17 @@ function gen_defender_retreat() { let here = game.move.to let is_lone = is_general_without_cu(here) let can_retreat = false + let g if (game.active === P_BRITAIN) - view.selected_general = find_british_general(here) + g = find_british_general(here) else - view.selected_general = find_american_or_french_general(here) + g = find_american_or_french_general(here) + + view.selected_general = g for (let to of SPACES[here].adjacent) { - if (can_defender_retreat(to, is_lone)) { + if (can_defender_retreat(g, here, to, is_lone)) { gen_action_space(to) can_retreat = true } |