summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-09-22 11:13:47 +0200
committerTor Andersson <tor@ccxvii.net>2023-09-22 11:25:47 +0200
commit34205ff9fdd2492efe8b213fe31e63d98666012b (patch)
tree219d8d688a000a87bfe8c6a2dbbb21fe9ee46d0f
parent764402218b053188ef7005635f1e87fc63f62977 (diff)
downloadandean-abyss-34205ff9fdd2492efe8b213fe31e63d98666012b.tar.gz
Fix bug and tighten up code that checks if you must Assault + Air Lift.
-rw-r--r--rules.js37
1 files changed, 35 insertions, 2 deletions
diff --git a/rules.js b/rules.js
index d26cff5..e3ca589 100644
--- a/rules.js
+++ b/rules.js
@@ -3723,12 +3723,22 @@ function vm_free_assault_cartels() {
goto_assault_space()
}
+function must_air_lift_to_assault(state) {
+ if (state === "assault" && game.op.spaces.length === 0) {
+ for (let s = first_space; s <= last_space; ++s)
+ if (can_assault_in_space(s, 0))
+ return false
+ return true
+ }
+ return false
+}
+
function can_assault() {
if (game.sa && can_air_lift()) {
for (let s = first_space; s <= last_space; ++s)
if (has_assault_target(s, 0))
return true
- return true
+ return false
}
for (let s = first_space; s <= last_space; ++s)
if (can_assault_in_space(s, 0))
@@ -4744,7 +4754,13 @@ function gen_special_activity(faction, action, enable) {
function gen_govt_special_activity() {
if (game.sa) {
- // TODO: if Assault and no valid assault targets, only allow air lift!
+ if (must_air_lift_to_assault(game.state)) {
+ // if Assault and no valid assault targets, only allow air lift!
+ view.actions.air_lift = can_air_lift() ? 1 : 0
+ view.actions.eradicate = 0
+ view.actions.air_strike = 0
+ return
+ }
view.actions.air_lift = can_air_lift() ? 1 : 0
view.actions.eradicate = can_eradicate() ? 1 : 0
view.actions.air_strike = can_air_strike() ? 1 : 0
@@ -4830,6 +4846,16 @@ states.air_lift_to = {
view.prompt = "Air Lift: Select destination space."
view.where = game.sa.from
let manpad = has_momentum(MOM_MISIL_ANTIAEREO)
+
+ if (must_air_lift_to_assault(game.sa.save)) {
+ // if Assault and no valid assault targets, only allow air lift to assault enabling spaces!
+ for (let s = first_space; s <= last_space; ++s)
+ if (s !== game.sa.from && can_air_lift_to(manpad, s))
+ if (has_assault_target(s))
+ gen_action_space(s)
+ return
+ }
+
for (let s = first_space; s <= last_space; ++s)
if (s !== game.sa.from && can_air_lift_to(manpad, s))
gen_action_space(s)
@@ -4854,6 +4880,13 @@ states.air_lift_move = {
view.prompt = `Air Lift: Move Troops from ${space_name[game.sa.from]} to ${space_name[game.sa.to]}.`
view.where = game.sa.to
gen_piece_in_space(game.sa.from, GOVT, TROOPS)
+
+ if (game.sa.count < 1 && must_air_lift_to_assault(game.sa.save)) {
+ // if Assault and no valid assault targets, only allow air lift to assault enabling spaces!
+ view.actions.end_air_lift = 0
+ return
+ }
+
view.actions.end_air_lift = 1
},
piece(p) {