summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js92
1 files changed, 50 insertions, 42 deletions
diff --git a/rules.js b/rules.js
index 0f44ca3..b4d0819 100644
--- a/rules.js
+++ b/rules.js
@@ -3703,15 +3703,34 @@ function do_event(c) {
immediately
*/
-function goto_george_washington_captured() {
- game.state = "george_washington_captured"
- game.save = game.active
+function init_george_washington_captured(next_state, done_state) {
game.active = P_BRITAIN
+ game.state = next_state
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"
+ game.state = done_state
+}
+
+function goto_george_washington_captured() {
+ game.save = game.active
+ init_george_washington_captured("george_washington_captured", "george_washington_captured_done")
+}
+
+function goto_george_washington_captured_during_move() {
+ init_george_washington_captured("george_washington_captured_during_move", "george_washington_captured_during_move_done")
+}
+
+function action_george_washington_captured_space(s) {
+ push_undo()
+ remove_pc(s)
+ set_delete(game.colonies, SPACES[s].colony)
+ if (--game.count === 0) {
+ delete game.colonies
+ return true
+ }
+ return false
}
states.george_washington_captured = {
@@ -3720,16 +3739,24 @@ states.george_washington_captured = {
view.prompt = "George Washington captured! Remove American PC markers. " + game.count + " left."
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)
+ space(s) {
+ if (action_george_washington_captured_space(s))
game.state = "george_washington_captured_done"
},
}
+states.george_washington_captured_during_move = {
+ inactive: "to remove PC markers",
+ prompt() {
+ view.prompt = "George Washington captured! Remove American PC markers. " + game.count + " left."
+ gen_remove_american_pc_in_colony(game.colonies)
+ },
+ space(s) {
+ if (action_george_washington_captured_space(s))
+ game.state = "george_washington_captured_during_move_done"
+ },
+}
+
states.george_washington_captured_done = {
inactive: "to remove PC markers",
prompt() {
@@ -3738,44 +3765,25 @@ states.george_washington_captured_done = {
},
next() {
clear_undo()
- end_george_washington_captured()
+ game.active = game.save
+ delete game.save
+ if (game.active === P_AMERICA) {
+ // skip end turn pause after britain removed washington at end of strategy card
+ end_strategy_card_now()
+ } else {
+ end_strategy_card()
+ }
},
}
-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
- end_strategy_card_now()
- } else {
- end_strategy_card()
- }
-}
-
-function goto_george_washington_captured_during_move() {
- game.state = "george_washington_captured_during_move"
- game.count = 5
- delete game.washington_captured
-}
-
-states.george_washington_captured_during_move = {
+states.george_washington_captured_during_move_done = {
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
- },
- space(where) {
- push_undo()
- remove_pc(where)
- if (--game.count === 0)
- game.state = "ops_general_move"
+ view.prompt = "George Washington captured! Remove American PC markers. Done."
+ view.actions.next = 1
},
- pass() {
+ next() {
+ // TODO: extra undo step here or not?
push_undo()
game.state = "ops_general_move"
},