From b19502415f995d1a6cd263bd641e32ef3942e3f7 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 25 Aug 2024 15:52:37 +0200 Subject: Capture of George Washington removes 5 PC - max one per colony! --- rules.js | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 579303a..53fe0a5 100644 --- a/rules.js +++ b/rules.js @@ -66,6 +66,7 @@ const AMERICAN_REINFORCEMENTS = data.space_index["American Leader Reinforcements const FRENCH_REINFORCEMENTS = data.space_index["French Reinforcements"] const NOWHERE = data.spaces.length +const ALL_COLONIES = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ] const THE_13_COLONIES = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ] const SOUTH_OF_WINTER_ATTRITION_LINE = [ 11, 12, 13 ] @@ -930,6 +931,26 @@ function filter_place_american_pc_in_colony(list_of_colonies) { return result } +function gen_remove_american_pc_in_colony(list_of_colonies) { + for (let colony of list_of_colonies) + for (let space of COLONIES[colony]) + if (has_american_pc(space) && has_no_american_unit(space)) + gen_action_space(space) +} + +function filter_remove_american_pc_in_colony(list_of_colonies) { + let result = [] + for (let colony of list_of_colonies) { + for (let space of COLONIES[colony]) { + if (has_american_pc(space) && has_no_american_unit(space)) { + result.push(colony) + break + } + } + } + return result +} + /* REMOVE GENERAL (STACKING) */ function prompt_remove_general(where) { @@ -3689,29 +3710,27 @@ function goto_george_washington_captured() { game.state = "george_washington_captured" game.save = game.active game.active = P_BRITAIN - game.count = 5 + game.colonies = filter_remove_american_pc_in_colony(ALL_COLONIES) + game.count = Math.min(5, game.colonies.length) delete game.washington_captured + if (game.count === 0) + game.state = "george_washington_captured_done" } states.george_washington_captured = { inactive: "to remove PC markers", prompt() { view.prompt = "George Washington captured! Remove American PC markers. " + game.count + " left." - for (let space of all_spaces) - if (has_american_pc(space) && has_no_american_unit(space)) - gen_action_space(space) - view.actions.pass = 1 + gen_remove_american_pc_in_colony(game.colonies) }, space(where) { push_undo() remove_pc(where) + let colony = SPACES[where].colony + set_delete(game.colonies, colony) if (--game.count === 0) game.state = "george_washington_captured_done" }, - pass() { - push_undo() - game.state = "george_washington_captured_done" - }, } states.george_washington_captured_done = { @@ -3728,6 +3747,7 @@ states.george_washington_captured_done = { function end_george_washington_captured() { game.active = game.save + delete game.colonies delete game.save if (game.active === P_AMERICA) { // skip end turn pause after britain removed washington at end of strategy card -- cgit v1.2.3