summaryrefslogtreecommitdiff
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
parent7ca587623a2c3cc684eac2c7c9ce59eb4e1dc2f3 (diff)
downloadrommel-in-the-desert-084fd073d873ae6d4ac4a8947cf232d575dc0c9c.tar.gz
End fire button.
-rw-r--r--play.html6
-rw-r--r--play.js1
-rw-r--r--rules.js62
3 files changed, 45 insertions, 24 deletions
diff --git a/play.html b/play.html
index 8866d36..fc55ec3 100644
--- a/play.html
+++ b/play.html
@@ -349,6 +349,11 @@ svg .side.allied_control {
stroke-dashoffset: -8;
}
+body.Allied svg .side.axis_control { stroke: black; }
+body.Allied svg .side.allied_control { stroke: none; }
+body.Axis svg .side.axis_control { stroke: none; }
+body.Axis svg .side.allied_control { stroke: black; }
+
/* SUPPLY LINES */
svg .hex.axis_supply {
@@ -627,6 +632,7 @@ svg .side.allied_supply.axis_supply {
<button id="battle_antitank_button" onclick="send_action('antitank')">Anti-tank</button>
<button id="battle_artillery_button" onclick="send_action('artillery')">Artillery</button>
<button id="battle_end_hits_button" onclick="send_action('end_hits')">Done</button>
+ <button id="battle_end_fire_button" onclick="send_action('end_fire')">Done</button>
</div>
<div id="battle_message"></div>
</div>
diff --git a/play.js b/play.js
index 4a56239..0c06c1a 100644
--- a/play.js
+++ b/play.js
@@ -785,6 +785,7 @@ function update_battle() {
battle_button("battle_antitank_button", "antitank")
battle_button("battle_artillery_button", "artillery")
battle_button("battle_end_hits_button", "end_hits")
+ battle_button("battle_end_fire_button", "end_fire")
}
function update_pursuit() {
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 = {