diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-04-09 11:03:19 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-05-03 18:48:16 +0200 |
commit | 5ba38f1ad5522ce943f869b2a8e72412ad0a92b7 (patch) | |
tree | 2027ff780b52e753f573fba327885e6fd66a6823 | |
parent | c839704fed8ab20b813005824ef4c61c1eeed7b2 (diff) | |
download | andean-abyss-5ba38f1ad5522ce943f869b2a8e72412ad0a92b7.tar.gz |
can govt special activities.
-rw-r--r-- | rules.js | 96 |
1 files changed, 70 insertions, 26 deletions
@@ -2358,9 +2358,8 @@ states.train = { view.prompt = "Train: Select City or Department to place cubes." if (game.sa) { - // TODO: can_air_lift, can_eradicate - view.actions.air_lift = 1 - view.actions.eradicate = 1 + view.actions.air_lift = can_air_lift() ? 1 : 0 + view.actions.eradicate = can_eradicate() ? 1 : 0 } // Any Departments or Cities @@ -4136,13 +4135,9 @@ function gen_special(faction, action, enable) { function gen_govt_special_activity() { if (game.sa) { - // TODO: can_air_lift, can_air_strike, can_eradicate - view.actions.air_lift = 1 - view.actions.eradicate = 1 - if (has_momentum(MOM_PLAN_COLOMBIA)) - view.actions.air_strike = 0 - else - view.actions.air_strike = 1 + 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 } } @@ -4180,14 +4175,37 @@ function goto_air_lift() { game.sa.count = 1 } +function can_air_lift() { + let manpad = has_momentum(MOM_MISIL_ANTIAEREO) + for (let from = first_space; from <= last_space; ++from) + if (can_air_lift_from(manpad, from)) + for (let to = first_space; to <= last_space; ++to) + if (to !== from && can_air_lift_to(manpad, to)) + return true + return false +} + +function can_air_lift_from(manpad, s) { + if (has_piece(s, GOVT, TROOPS)) + if (!manpad || !has_any_guerrilla(s)) + return true + return false +} + +function can_air_lift_to(manpad, s) { + if (can_stack_piece(s, GOVT, TROOPS)) + if (!manpad || !has_any_guerrilla(s)) + return true + return false +} + states.air_lift_from = { prompt() { view.prompt = "Air Lift: Select origin space." let manpad = has_momentum(MOM_MISIL_ANTIAEREO) for (let s = first_space; s <= last_space; ++s) - if (has_piece(s, GOVT, TROOPS)) - if (!manpad || !has_any_guerrilla(s)) - gen_action_space(s) + if (can_air_lift_from(manpad, s)) + gen_action_space(s) }, space(s) { push_undo() @@ -4202,9 +4220,8 @@ states.air_lift_to = { view.where = game.sa.from let manpad = has_momentum(MOM_MISIL_ANTIAEREO) for (let s = first_space; s <= last_space; ++s) - if (s !== game.sa.from && can_stack_any(s, GOVT)) - if (!manpad || !has_any_guerrilla(s)) - gen_action_space(s) + if (s !== game.sa.from && can_air_lift_to(manpad, s)) + gen_action_space(s) }, space(s) { push_undo() @@ -4247,6 +4264,23 @@ function goto_air_strike() { game.state = "air_strike" } +function can_air_strike() { + if (has_momentum(MOM_PLAN_COLOMBIA)) + return false + let manpad = has_momentum(MOM_MISIL_ANTIAEREO) + for (let s = first_space; s <= last_space; ++s) + if (can_air_strike_in_space(manpad, s)) + return true + return false +} + +function can_air_strike_in_space(manpad, s) { + if (!manpad || !has_any_guerrilla(s)) + if (has_exposed_piece(s, FARC) || has_exposed_piece(s, AUC) || has_exposed_piece(s, CARTELS)) + return true + return false +} + states.air_strike = { prompt() { view.prompt = "Air Strike: Destroy exposed Insurgent unit." @@ -4289,6 +4323,21 @@ function goto_eradicate() { } } +function can_eradicate() { + let manpad = has_momentum(MOM_MISIL_ANTIAEREO) + for (let s = first_dept; s <= last_dept; ++s) + if (can_eradicate_in_space(manpad, s)) + return true + return false +} + +function can_eradicate_in_space(manpad, s) { + if (!manpad || !has_any_guerrilla(s)) + if (has_piece(s, CARTELS, GUERRILLA) || has_piece(s, CARTELS, BASE)) + return true + return false +} + states.eradicate_aid = { prompt() { view.prompt = "Eradicate: Aid +4." @@ -4306,9 +4355,8 @@ states.eradicate = { view.prompt = "Eradicate: Destroy rural Cartels Bases." let manpad = has_momentum(MOM_MISIL_ANTIAEREO) for (let s = first_dept; s <= last_dept; ++s) - if (has_piece(s, CARTELS, GUERRILLA) || has_piece(s, CARTELS, BASE)) - if (!manpad || !has_any_guerrilla(s)) - gen_action_space(s) + if (can_eradicate_in_space(manpad, s)) + gen_action_space(s) }, space(s) { push_undo() @@ -6719,13 +6767,9 @@ function vm_free_attack_terror() { game.state = "vm_free_attack_terror" } states.vm_free_govt_special_activity = { prompt() { event_prompt(`Free Special Activity.`) - // TODO: can_air_lift, can_air_strike, can_eradicate - view.actions.air_lift = 1 - if (has_momentum(MOM_PLAN_COLOMBIA)) - view.actions.air_strike = 0 - else - view.actions.air_strike = 1 - view.actions.eradicate = 1 + 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 }, air_lift: vm_free_air_lift, air_strike: vm_free_air_strike, |