summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-10-02 21:36:42 +0200
committerTor Andersson <tor@ccxvii.net>2024-10-02 21:36:42 +0200
commit4723be258d8bdac747cc54f8eab7e66a663c88f9 (patch)
tree8152c64908cb685dfa1981bb70fad2e826ea9838 /rules.js
parent24611a0d96685296c0704c54e1abfccd608ff739 (diff)
downloadwashingtons-war-4723be258d8bdac747cc54f8eab7e66a663c88f9.tar.gz
Simcoe rangers errata: both PC within range of same general.HEADmaster
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js66
1 files 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)
}