summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-11-04 22:22:14 +0100
committerTor Andersson <tor@ccxvii.net>2023-11-09 00:55:49 +0100
commit1af5b8753993f05a340c1fc287010281a68437b3 (patch)
treee36d8e5d7694f662d5f7545bb224b3afd599ee3a
parent9cfd7ae191d983927efff75f7a981239514ba40c (diff)
downloadalgeria-1af5b8753993f05a340c1fc287010281a68437b3.tar.gz
Take combat losses by clicking on unit to reduce/eliminate.
-rw-r--r--rules.js54
1 files changed, 46 insertions, 8 deletions
diff --git a/rules.js b/rules.js
index f83598c..d4f96e9 100644
--- a/rules.js
+++ b/rules.js
@@ -4032,20 +4032,58 @@ function reduce_fln_unit(from_type, to_type) {
continue_combat_after_fln_losses()
}
+function eliminate_fln_unit_2(u) {
+ push_undo()
+ eliminate_unit(u)
+ set_delete(game.combat.fln_units, u)
+ game.combat.distribute_fln_hits -= 1
+ if (!game.combat.distribute_fln_hits || !game.combat.fln_units.length)
+ continue_combat_after_fln_losses()
+}
+
+function reduce_fln_unit_2(u, to_type) {
+ push_undo()
+ let n = reduce_unit(u, to_type)
+ set_add(game.combat.fln_units, n)
+ set_delete(game.combat.fln_units, u)
+ game.combat.distribute_fln_hits -= 1
+ if (!game.combat.distribute_fln_hits || !game.combat.fln_units.length)
+ continue_combat_after_fln_losses()
+}
+
states.fln_combat_fln_losses = {
inactive: "to distribute combat losses",
prompt() {
view.prompt = `Distribute ${game.combat.distribute_fln_hits} hit(s) as losses.`
// each 'hit' on FLN units eliminates one Cadre or Band, or reduces a Front to a Cadre, or reduces a Failek to a Band (FLN player chooses how to distribute his losses).
- if (has_fln_combat_unit(CADRE))
- gen_action("eliminate_cadre")
- if (has_fln_combat_unit(BAND))
- gen_action("eliminate_band")
- if (has_fln_combat_unit(FRONT))
- gen_action("reduce_front")
- if (has_fln_combat_unit(FAILEK))
- gen_action("reduce_failek")
+ if (0) {
+ if (has_fln_combat_unit(CADRE))
+ gen_action("eliminate_cadre")
+ if (has_fln_combat_unit(BAND))
+ gen_action("eliminate_band")
+ if (has_fln_combat_unit(FRONT))
+ gen_action("reduce_front")
+ if (has_fln_combat_unit(FAILEK))
+ gen_action("reduce_failek")
+ } else {
+ for (let u of game.combat.fln_units)
+ gen_action_unit(u)
+ }
+ },
+ unit(u) {
+ switch (unit_type(u)) {
+ case FRONT:
+ reduce_fln_unit_2(u, CADRE)
+ break
+ case FAILEK:
+ reduce_fln_unit_2(u, BAND)
+ break
+ case BAND:
+ case CADRE:
+ eliminate_fln_unit_2(u)
+ break
+ }
},
eliminate_cadre() {
eliminate_fln_unit(CADRE)