summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-08-06 16:52:18 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 13:11:26 +0100
commit084fd073d873ae6d4ac4a8947cf232d575dc0c9c (patch)
treedd5a3a28ba7add57495a2d02de4680da54b9cbdf /rules.js
parent7ca587623a2c3cc684eac2c7c9ce59eb4e1dc2f3 (diff)
downloadrommel-in-the-desert-084fd073d873ae6d4ac4a8947cf232d575dc0c9c.tar.gz
End fire button.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js62
1 files changed, 38 insertions, 24 deletions
diff --git a/rules.js b/rules.js
index 6a8a636..3d7b7c1 100644
--- a/rules.js
+++ b/rules.js
@@ -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 = {