summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js251
1 files changed, 124 insertions, 127 deletions
diff --git a/rules.js b/rules.js
index dc9c448..82c7a09 100644
--- a/rules.js
+++ b/rules.js
@@ -951,6 +951,127 @@ function filter_place_american_pc_in_colony(list_of_colonies) {
return result
}
+/* REMOVE GENERAL (STACKING) */
+
+function prompt_remove_general(where) {
+ view.prompt = "Remove a general to the reinforcements box."
+ if (game.active === P_BRITAIN) {
+ for (let g of BRITISH_GENERALS)
+ if (is_general_at_location(g, where))
+ gen_action_general(g)
+ } else {
+ for (let g of AMERICAN_GENERALS)
+ if (g !== WASHINGTON)
+ if (is_general_at_location(g, where))
+ gen_action_general(g)
+ }
+}
+
+function action_remove_general(g) {
+ if (game.active === P_BRITAIN)
+ move_general(g, BRITISH_REINFORCEMENTS)
+ else
+ move_general(g, AMERICAN_REINFORCEMENTS)
+}
+
+function goto_remove_general_after_move(where) {
+ game.state = "remove_general_after_move"
+ game.where = where
+}
+
+states.remove_general_after_move = {
+ inactive: "to remove a general",
+ prompt() {
+ prompt_remove_general(game.where)
+ },
+ general(g) {
+ push_undo()
+ action_remove_general(g)
+ delete game.where
+ end_strategy_card()
+ },
+}
+
+function goto_remove_general_after_intercept() {
+ game.state = "remove_general_after_intercept"
+}
+
+states.remove_general_after_intercept = {
+ inactive: "to remove a general",
+ prompt() {
+ prompt_remove_general(game.move.to)
+ },
+ general(g) {
+ push_undo()
+ action_remove_general(g)
+ game.state = "remove_general_after_intercept_confirm"
+ },
+}
+
+states.remove_general_after_intercept_confirm = {
+ inactive: "to remove a general",
+ prompt() {
+ view.prompt = "Intercept done."
+ view.actions.next = 1
+ },
+ next() {
+ clear_undo()
+ end_intercept()
+ },
+}
+
+function goto_remove_general_after_retreat_before_battle(where) {
+ if (count_friendly_generals(where) > 1) {
+ game.state = "remove_general_after_retreat_before_battle"
+ game.where = where
+ } else {
+ end_retreat_before_battle()
+ }
+}
+
+states.remove_general_after_retreat_before_battle = {
+ inactive: "to remove a general",
+ prompt() {
+ prompt_remove_general(game.where)
+ },
+ general(g) {
+ push_undo()
+ action_remove_general(g)
+ delete game.where
+ game.state = "remove_general_after_retreat_before_battle_confirm"
+ },
+}
+
+states.remove_general_after_retreat_before_battle_confirm = {
+ inactive: "to remove a general",
+ prompt() {
+ view.prompt = "Retreat done."
+ view.actions.next = 1
+ },
+ next() {
+ clear_undo()
+ end_retreat_before_battle()
+ },
+}
+
+function goto_remove_general_after_retreat(where) {
+ game.state = "remove_general_after_retreat"
+ game.where = where
+}
+
+states.remove_general_after_retreat = {
+ inactive: "to remove a general",
+ prompt() {
+ prompt_remove_general(game.where)
+ },
+ general(g) {
+ push_undo()
+ action_remove_general(g)
+ delete game.where
+ game.state = "retreat_after_battle_confirm"
+ },
+}
+
/* SETUP PHASE */
function goto_committees_of_correspondence() {
@@ -1899,101 +2020,6 @@ function gen_activate_american_general() {
gen_action_general(g)
}
-function goto_remove_general(where) {
- game.state = "remove_general"
- game.where = where
-}
-
-states.remove_general = {
- inactive: "to remove a general",
- prompt() {
- view.prompt = "Remove a general to the reinforcements box."
- gen_remove_general(game.where)
- },
- general(g) {
- push_undo()
- delete game.where
- if (game.active === P_BRITAIN)
- move_general(g, BRITISH_REINFORCEMENTS)
- else
- move_general(g, AMERICAN_REINFORCEMENTS)
- end_strategy_card()
- },
-}
-
-function goto_remove_general_after_intercept() {
- game.state = "remove_general_after_intercept"
-}
-
-states.remove_general_after_intercept = {
- inactive: "to remove a general",
- prompt() {
- view.prompt = "Remove a general to the reinforcements box."
- gen_remove_general(game.move.to)
- },
- general(g) {
- push_undo()
- if (game.active === P_BRITAIN)
- move_general(g, BRITISH_REINFORCEMENTS)
- else
- move_general(g, AMERICAN_REINFORCEMENTS)
- game.state = "remove_general_after_intercept_confirm"
- },
-}
-
-states.remove_general_after_intercept_confirm = {
- inactive: "to remove a general",
- prompt() {
- view.prompt = "Intercept done."
- view.actions.next = 1
- },
- next() {
- clear_undo()
- end_intercept()
- },
-}
-
-function goto_remove_general_after_retreat(where) {
- game.state = "remove_general_after_retreat"
- game.where = where
-}
-
-states.remove_general_after_retreat = {
- inactive: "to remove a general",
- prompt() {
- view.prompt = "Remove a general to the reinforcements box."
- gen_remove_general(game.where)
- },
- general(g) {
- push_undo()
- delete game.where
- if (game.active === P_BRITAIN)
- move_general(g, BRITISH_REINFORCEMENTS)
- else
- move_general(g, AMERICAN_REINFORCEMENTS)
- game.state = "retreat_after_battle_confirm"
- },
-}
-
-function gen_remove_general(where) {
- if (game.active === P_BRITAIN)
- return gen_remove_british_general(where)
- else
- return gen_remove_american_general(where)
-}
-
-function gen_remove_british_general(where) {
- for (let g of BRITISH_GENERALS)
- if (is_general_at_location(g, where))
- gen_action_general(g)
-}
-
-function gen_remove_american_general(where) {
- for (let g of AMERICAN_GENERALS)
- if (g !== WASHINGTON)
- if (is_general_at_location(g, where))
- gen_action_general(g)
-}
function goto_ops_general_move(g, marblehead) {
game.state = "ops_general_move"
@@ -2230,7 +2256,7 @@ function end_move(stop) {
delete game.move
if (count_friendly_generals(where) > 1)
- goto_remove_general(where)
+ goto_remove_general_after_move(where)
else {
if (end_strategy_card() && stop)
next_strategy_card()
@@ -2549,31 +2575,6 @@ states.retreat_before_battle_roll = {
},
}
-function goto_remove_general_after_retreat_before_battle(where) {
- if (count_friendly_generals(where) > 1) {
- game.state = "remove_general_after_retreat_before_battle"
- game.where = where
- } else {
- end_retreat_before_battle()
- }
-}
-
-states.remove_general_after_retreat_before_battle = {
- inactive: "to remove a general",
- prompt() {
- view.prompt = "Remove a general to the reinforcements box."
- gen_remove_general(game.where)
- },
- general(g) {
- delete game.where
- if (game.active === P_BRITAIN)
- move_general(g, BRITISH_REINFORCEMENTS)
- else
- move_general(g, AMERICAN_REINFORCEMENTS)
- end_retreat_before_battle()
- },
-}
-
function end_retreat_before_battle() {
game.active = P_BRITAIN
@@ -4054,16 +4055,12 @@ states.remove_general_rochambeau = {
inactive: "to remove a general",
prompt() {
let where = location_of_general(ROCHAMBEAU)
- view.prompt = "Remove a general to the reinforcements box."
+ prompt_remove_general(where)
view.move = { who: ROCHAMBEAU, from: where, to: where, carry_american: 0, carry_french: 5 }
- gen_remove_general(where)
},
general(g) {
push_undo()
- if (game.active === P_BRITAIN)
- move_general(g, BRITISH_REINFORCEMENTS)
- else
- move_general(g, AMERICAN_REINFORCEMENTS)
+ action_remove_general(g)
game.state = "end_place_rochambeau"
},
}