diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 62 |
1 files changed, 38 insertions, 24 deletions
@@ -12,9 +12,6 @@ // TODO: log summaries (deploy, rebuild, move, etc) // TODO: put initial deployment stack somewhere more accessible (spread out along the top?) -// UI: pause after all fires (in case 0 hits the dialog disappears fast) - -// TODO: black hit outline in battles ("steploss/bad" action) and skip "apply 0 hits" step // TODO: undo push/clear // ERRATA: forbid single-group regroup moves or convert to group moves after the fact, @@ -3946,16 +3943,18 @@ function apply_battle_fire(tc) { // clamp to available hit points game.hits[tc] = min(game.hits[tc], hp[tc]) - // end when no more units to fire or all targets destroyed - let done = true - if (game.hits[0] < hp[0] || game.hits[1] < hp[1] || game.hits[2] < hp[2] || game.hits[3] < hp[3]) { - for_each_undisrupted_friendly_unit_in_hex(game.battle, u => { - if (!is_unit_fired(u) && !is_unit_retreating(u)) - done = false - }) - } - if (done) { - goto_hits() + if (false) { + // end when no more units to fire or all targets destroyed + let done = true + if (game.hits[0] < hp[0] || game.hits[1] < hp[1] || game.hits[2] < hp[2] || game.hits[3] < hp[3]) { + for_each_undisrupted_friendly_unit_in_hex(game.battle, u => { + if (!is_unit_fired(u) && !is_unit_retreating(u)) + done = false + }) + } + if (done) { + goto_hits() + } } } @@ -3984,20 +3983,29 @@ function goto_hits() { function gen_battle_fire() { let arty = false - for_each_undisrupted_friendly_unit_in_hex(game.battle, u => { - if (is_artillery_unit(u) && !is_unit_retreating(u)) { - if (!is_unit_fired(u)) { - gen_action_unit(u) - arty = true - } - } - }) - if (!arty) { + let done = true + let hp = count_hp_in_battle() + if (game.hits[0] < hp[0] || game.hits[1] < hp[1] || game.hits[2] < hp[2] || game.hits[3] < hp[3]) { for_each_undisrupted_friendly_unit_in_hex(game.battle, u => { - if (!is_unit_fired(u) && !is_unit_retreating(u)) - gen_action_unit(u) + if (is_artillery_unit(u) && !is_unit_retreating(u)) { + if (!is_unit_fired(u)) { + gen_action_unit(u) + arty = true + done = false + } + } }) + if (!arty) { + for_each_undisrupted_friendly_unit_in_hex(game.battle, u => { + if (!is_unit_fired(u) && !is_unit_retreating(u)) { + gen_action_unit(u) + done = false + } + }) + } } + if (done) + gen_action('end_fire') } function gen_battle_target() { @@ -4128,6 +4136,9 @@ states.battle_fire = { artillery() { apply_battle_fire(ARTILLERY) }, + end_fire() { + goto_hits() + }, } states.battle_hits = { @@ -4186,6 +4197,9 @@ states.probe_fire = { artillery() { apply_battle_fire(ARTILLERY) }, + end_fire() { + goto_hits() + }, } states.probe_hits = { |