summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-11-09 00:24:50 +0100
committerTor Andersson <tor@ccxvii.net>2023-11-09 00:56:25 +0100
commita3bc99a00c42062008439fb4b9cfbd5ccd22bc40 (patch)
treef7ca49456e4dd634b1b74881c6764e7e9ecb8ff5
parent4dce25a6945973d3706a47c74ec9417e80db388c (diff)
downloadalgeria-a3bc99a00c42062008439fb4b9cfbd5ccd22bc40.tar.gz
Streamline Suez Crisis.
-rw-r--r--rules.js45
1 files changed, 19 insertions, 26 deletions
diff --git a/rules.js b/rules.js
index 3730440..0c352ef 100644
--- a/rules.js
+++ b/rules.js
@@ -2079,12 +2079,11 @@ function goto_suez_crisis() {
log("Crisis G" + roll)
- game.selected = []
-
let num_el_x = count_friendly_units_on_map_of_type(EL_X)
let to_remove = Math.min(roll, num_el_x)
if (to_remove) {
game.events.gov_remove_num = to_remove
+ game.summary = []
game.state = "event_gov_suez_crisis_select_units"
} else {
log("No French elite units to remove.")
@@ -2095,40 +2094,34 @@ function goto_suez_crisis() {
states.event_gov_suez_crisis_select_units = {
inactive: "to do Suez Crisis",
prompt() {
- view.prompt = `Suez Crisis: Select ${game.events.gov_remove_num} French elite unit(s) to remove from the map.`
-
- let target = 0
- for (let u of game.selected) {
- if (unit_type(u) === EL_X) target += 1
- }
-
- for_each_friendly_unit_on_map(u => {
- if (unit_type(u) === EL_X && (target < game.events.gov_remove_num || set_has(game.selected, u)))
- gen_action_unit(u)
- })
-
- if (target >= game.events.gov_remove_num) {
+ if (game.events.gov_remove_num > 0) {
+ view.prompt = `Suez Crisis: Remove ${game.events.gov_remove_num} French elite unit(s).`
+ for_each_friendly_unit_on_map(u => {
+ if (unit_type(u) === EL_X)
+ gen_action_unit(u)
+ })
+ } else {
+ view.prompt = `Suez Crisis: Done.`
gen_action("done")
}
},
unit(u) {
- set_toggle(game.selected, u)
- },
- done() {
- let list = game.selected
- game.selected = []
+ push_undo()
// they will return in the Random Event Phase of the next turn automatically
// - they do not need to be mobilized again but do need to be activated.
// The units may be re-mobilized at least one turn later.
if (!game.events.gov_return)
game.events.gov_return = []
- log_unit_list("Removed (will return)", list)
- for (let u of list) {
- let loc = unit_loc(u)
- remove_unit(u, ELIMINATED)
- map_set(game.events.gov_return, u, loc)
- }
+ map_set(game.events.gov_return, u, unit_loc(u))
+
+ add_unit_summary(game.summary, u)
+ game.events.gov_remove_num -= 1
+ remove_unit(u, ELIMINATED)
+ },
+ done() {
+ log_unit_summary("Removed (will return)", game.summary)
+ game.summary = null
delete game.events.gov_remove_num
end_random_event()
}