From 14b8222d7059df64234bd92ee627b6f6b4ff051d Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 6 Dec 2024 00:05:14 +0100 Subject: Remove from combat generals that move home when Saxony becomes neutral. --- rules.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 647c996..71ac755 100644 --- a/rules.js +++ b/rules.js @@ -3734,6 +3734,12 @@ function end_recruit() { /* COMBAT (CHOOSE TARGETS) */ +function remove_from_combat(p) { + let s = game.pos[p] + if (game.combat) + game.combat = map_filter(game.combat, (atk, def) => atk !== s && def !== s) +} + function goto_combat() { let from = [] let to = [] @@ -5627,6 +5633,8 @@ states.saxony_return_foreign_where = { gen_action_space(s) }, space(s) { + if (is_general(game.selected)) + remove_from_combat(game.selected) log(">P" + game.selected + " to S" + s) enter_piece_at(game.selected, s) game.selected = -1 @@ -5654,6 +5662,8 @@ states.saxony_return_home = { view.actions.next = 1 }, piece(p) { + if (is_general(p)) + remove_from_combat(p) let s = setup_piece_position[p] game.pos[p] = s log(">P" + p + " to S" + s) @@ -5699,6 +5709,7 @@ states.saxony_move_general = { gen_action_space(s) }, space(s) { + remove_from_combat(game.selected) log(">P" + game.selected + " to S" + s) enter_piece_at(game.selected, s) end_saxony_neutral() @@ -5977,7 +5988,7 @@ states.silesia_enter_prussian_train = { states.silesia_done = { inactive: "annex Silesia", prompt() { - prompt("Silesian annexation done.") + prompt("Silesian annexion done.") view.actions.next = 1 }, next() { -- cgit v1.2.3