From 4723be258d8bdac747cc54f8eab7e66a663c88f9 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 2 Oct 2024 21:36:42 +0200 Subject: Simcoe rangers errata: both PC within range of same general. --- rules.js | 66 ++++++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/rules.js b/rules.js index 261d41d..4d8467b 100644 --- a/rules.js +++ b/rules.js @@ -3549,45 +3549,71 @@ states.remove_american_pc_from_non_port = { events.remove_american_pc_within_two_spaces_of_a_british_general = function (card) { game.count = card.count - game.state = "remove_american_pc_within_two_spaces_of_a_british_general" + game.state = "remove_american_pc_within_two_spaces_of_a_british_general_1" } -function gen_remove_american_pc_within_two_spaces_of_a_british_general() { - let candidates = [] - for (let g of BRITISH_GENERALS) { - let a = location_of_general(g) - if (is_map_space(a)) { - set_add(candidates, a) - for (let b of SPACES[a].adjacent) { - set_add(candidates, b) - for (let c of SPACES[b].adjacent) { - set_add(candidates, c) - } - } - } +function can_remove_american_pc_within_two_spaces_of_a_british_general(g) { + let a = location_of_general(g) + if (!is_map_space(a)) + return false + if (has_american_pc(a) && has_no_american_unit(a)) + return true + for (let b of SPACES[a].adjacent) { + if (has_american_pc(b) && has_no_american_unit(b)) + return true + for (let c of SPACES[b].adjacent) + if (has_american_pc(c) && has_no_american_unit(c)) + return true + } + return false +} + +function gen_remove_american_pc_within_two_spaces_of_a_british_general(g) { + let a = location_of_general(g) + let candidates = [ a ] + for (let b of SPACES[a].adjacent) { + set_add(candidates, b) + for (let c of SPACES[b].adjacent) + set_add(candidates, c) } for (let space of candidates) if (has_american_pc(space) && has_no_american_unit(space)) gen_action_space(space) } -states.remove_american_pc_within_two_spaces_of_a_british_general = { +states.remove_american_pc_within_two_spaces_of_a_british_general_1 = { inactive: "to execute event", prompt() { - view.prompt = "Remove American PC markers within two spaces of a British general. " + game.count + " left." - gen_remove_american_pc_within_two_spaces_of_a_british_general() + view.prompt = "Remove American PC markers within two spaces of a British general." + for (let g of BRITISH_GENERALS) + if (can_remove_american_pc_within_two_spaces_of_a_british_general(g)) + gen_action_general(g) + gen_event_pass() + }, + general(g) { + push_undo() + game.who = g + game.state = "remove_american_pc_within_two_spaces_of_a_british_general_2" + }, +} + +states.remove_american_pc_within_two_spaces_of_a_british_general_2 = { + inactive: "to execute event", + prompt() { + view.prompt = "Remove American PC markers within two spaces of " + general_name(game.who) + ". " + game.count + " left." + gen_remove_american_pc_within_two_spaces_of_a_british_general(game.who) gen_event_pass() }, space(where) { push_undo() remove_pc(where) if (--game.count === 0) { - delete game.where + delete game.who end_strategy_card() } }, pass() { - delete game.where + delete game.who end_strategy_card_now() }, } @@ -4736,7 +4762,7 @@ function gen_action_card(action, c) { } function gen_event_pass() { - if (!view.actions.space) + if (!view.actions.space && !view.actions.general) view.actions.pass = 1 // TODO: else confirm_pass (if enacting events are optional) } -- cgit v1.2.3