summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.html28
-rw-r--r--play.js32
-rw-r--r--rules.js53
3 files changed, 65 insertions, 48 deletions
diff --git a/play.html b/play.html
index dd24f84..8866d36 100644
--- a/play.html
+++ b/play.html
@@ -148,6 +148,7 @@ header.your_turn { background-color: orange; }
#pursuit { background-color: #d6c4a9; background: url(texture_mountain.png); }
#pursuit_header { background-color: brown; color: gold }
#pursuit_hits { background-color: #c4ab8b; }
+#pursuit_buttons { background-color: #c4ab8b; }
#pursuit_message { background-color: #d6c4a9; }
#pursuit {
@@ -185,6 +186,16 @@ header.your_turn { background-color: orange; }
border-top: 1px solid black;
}
+#pursuit_buttons {
+ padding: 12px;
+ min-height: 28px;
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: center;
+ gap: 12px;
+ border-top: 1px solid black;
+}
+
/* TABLES */
table { border-collapse: collapse; font-size: 12px; user-select: none; }
@@ -453,6 +464,10 @@ svg .side.allied_supply.axis_supply {
box-shadow: 0 0 0 2px white;
}
+.unit.action.hit {
+ box-shadow: 0 0 0 2px black, 0 0 2px 2px black;
+}
+
.unit.selected {
box-shadow: 0 0 0 2px yellow;
}
@@ -607,10 +622,11 @@ svg .side.allied_supply.axis_supply {
<div class="battle_line" id="battle_line_3"></div>
<div class="battle_line" id="battle_line_4"></div>
<div id="battle_buttons">
- <button id="target_armor_button" onclick="send_action('armor')">Armor</button>
- <button id="target_infantry_button" onclick="send_action('infantry')">Infantry</button>
- <button id="target_antitank_button" onclick="send_action('antitank')">Anti-tank</button>
- <button id="target_artillery_button" onclick="send_action('artillery')">Artillery</button>
+ <button id="battle_armor_button" onclick="send_action('armor')">Armor</button>
+ <button id="battle_infantry_button" onclick="send_action('infantry')">Infantry</button>
+ <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>
</div>
<div id="battle_message"></div>
</div>
@@ -620,6 +636,10 @@ svg .side.allied_supply.axis_supply {
<div id="pursuit_hits">0 hits</div>
<div class="battle_line" id="pursuit_line_1"></div>
<div class="battle_line" id="pursuit_line_2"></div>
+ <div id="pursuit_buttons">
+ <button id="pursuit_end_hits_button" onclick="send_action('end_hits')">Done</button>
+ <button id="pursuit_end_fire_button" onclick="send_action('end_fire')">End fire</button>
+ </div>
<div id="pursuit_message"></div>
</div>
diff --git a/play.js b/play.js
index a8f675c..8bc2bd7 100644
--- a/play.js
+++ b/play.js
@@ -184,6 +184,10 @@ function is_unit_action(unit) {
return !!(view.actions && view.actions.unit && view.actions.unit.includes(unit))
}
+function is_unit_hit_action(unit) {
+ return !!(view.actions && view.actions.unit_hit && view.actions.unit_hit.includes(unit))
+}
+
function is_unit_selected(unit) {
if (Array.isArray(view.selected))
return view.selected.includes(unit)
@@ -288,6 +292,7 @@ function on_click_unit(evt) {
function on_click_battle_unit(evt) {
if (evt.button === 0) {
send_action('unit', evt.target.unit)
+ send_action('unit_hit', evt.target.unit)
}
}
@@ -740,7 +745,8 @@ function update_battle_line(hex, line, test) {
e.classList.toggle("r2", r === 2)
e.classList.toggle("r3", r === 3)
- e.classList.toggle("action", is_unit_action(u))
+ e.classList.toggle("action", is_unit_action(u) || is_unit_hit_action(u))
+ e.classList.toggle("hit", is_unit_hit_action(u))
e.classList.toggle("selected", is_unit_selected(u))
e.classList.toggle("disrupted", is_unit_disrupted(u))
e.classList.toggle("moved", is_unit_fired(u))
@@ -768,12 +774,13 @@ function update_battle() {
update_battle_line(view.battle, ui.battle_line_3, u => is_axis_unit(u) && !is_artillery_unit(u))
update_battle_line(view.battle, ui.battle_line_4, u => is_axis_unit(u) && is_artillery_unit(u))
}
- target_button("armor")
- target_button("infantry")
- target_button("antitank")
- target_button("artillery")
for (let i = 0; i < 4; ++i)
ui.battle_hits[i].textContent = view.hits[i]
+ battle_button("battle_armor_button", "armor")
+ battle_button("battle_infantry_button", "infantry")
+ battle_button("battle_antitank_button", "antitank")
+ battle_button("battle_artillery_button", "artillery")
+ battle_button("battle_end_hits_button", "end_hits")
}
function update_pursuit() {
@@ -792,19 +799,16 @@ function update_pursuit() {
ui.pursuit_hits.textContent = view.hits + " hit"
else
ui.pursuit_hits.textContent = view.hits + " hits"
+ battle_button("pursuit_end_hits_button", "end_hits")
+ battle_button("pursuit_end_fire_button", "end_fire")
}
-function target_button(action) {
- let button = document.getElementById("target_" + action + "_button")
- if (view.actions) {
+function battle_button(id, action) {
+ let button = document.getElementById(id)
+ if (view.actions && view.actions[action])
button.classList.remove("hide")
- if (view.actions[action])
- button.disabled = false
- else
- button.disabled = true
- } else {
+ else
button.classList.add("hide")
- }
}
function on_update() {
diff --git a/rules.js b/rules.js
index 1009f4b..11e59b5 100644
--- a/rules.js
+++ b/rules.js
@@ -17,6 +17,7 @@
// 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,
// to prevent forced march abuse.
@@ -3633,7 +3634,7 @@ states.select_active_battles = {
if (game.turn_option === 'assault')
game.state = 'select_assault_battles'
else
- game.state = 'select_battle'
+ goto_select_battle()
} else {
end_combat_phase()
}
@@ -3656,7 +3657,7 @@ states.select_assault_battles = {
},
next() {
push_undo()
- game.state = 'select_battle'
+ goto_select_battle()
}
}
@@ -3952,7 +3953,7 @@ function gen_battle_hits() {
let c = unit_class[u]
if (is_elite_unit(u)) {
if (game.hits[c] >= 2) {
- gen_action_unit(u)
+ gen_action_unit_hit(u)
done = false
}
} else {
@@ -3962,7 +3963,7 @@ function gen_battle_hits() {
// Eliminating the last non-elite must not leave an odd
// number of hits remaining.
} else {
- gen_action_unit(u)
+ gen_action_unit_hit(u)
done = false
}
}
@@ -3970,7 +3971,7 @@ function gen_battle_hits() {
}
})
if (done)
- gen_action_next()
+ gen_action('end_hits')
return done
}
@@ -4017,11 +4018,11 @@ states.battle_hits = {
view.prompt = `Battle: ${format_allocate_hits()} from Offensive Fire.`
gen_battle_hits()
},
- unit(who) {
+ unit_hit(who) {
push_undo()
apply_battle_hit(who)
},
- next() {
+ end_hits() {
clear_undo()
end_battle_hits()
},
@@ -4075,11 +4076,11 @@ states.probe_hits = {
view.prompt = `Probe: ${format_allocate_hits()} from Offensive Fire.`
gen_battle_hits()
},
- unit(who) {
+ unit_hit(who) {
push_undo()
apply_battle_hit(who)
},
- next() {
+ end_hits() {
clear_undo()
end_probe_hits()
},
@@ -4248,19 +4249,13 @@ states.pursuit_fire = {
}
})
}
- if (done)
- gen_action('end_fire')
- else
- gen_action('withhold')
+ gen_action('end_fire')
},
unit(who) {
let slowest = slowest_undisrupted_enemy_unit_speed(game.pursuit)
roll_pursuit_fire(who, (unit_speed[who] > slowest ? 2 : 1))
set_unit_fired(who)
},
- withhold() {
- goto_pursuit_hits()
- },
end_fire() {
goto_pursuit_hits()
},
@@ -4280,19 +4275,13 @@ states.rout_fire = {
}
})
}
- if (done)
- gen_action('end_fire')
- else
- gen_action('withhold')
+ gen_action('end_fire')
},
unit(who) {
let slowest = slowest_enemy_unit_speed(game.pursuit)
roll_rout_fire(who, (unit_speed[who] > slowest ? 2 : 1))
set_unit_fired(who)
},
- withhold() {
- goto_rout_hits()
- },
end_fire() {
goto_rout_hits()
},
@@ -4303,7 +4292,7 @@ function gen_pursuit_hits(normal_steps, elite_steps, iterate) {
iterate(game.pursuit, u => {
if (is_elite_unit(u)) {
if (game.hits >= 2) {
- gen_action_unit(u)
+ gen_action_unit_hit(u)
done = false
}
} else {
@@ -4313,14 +4302,14 @@ function gen_pursuit_hits(normal_steps, elite_steps, iterate) {
// Eliminating the last non-elite must not leave an odd
// number of hits remaining.
} else {
- gen_action_unit(u)
+ gen_action_unit_hit(u)
done = false
}
}
}
})
if (done)
- gen_action('next')
+ gen_action('end_hits')
}
states.pursuit_hits = {
@@ -4331,11 +4320,11 @@ states.pursuit_hits = {
let elite_steps = count_elite_steps_in_pursuit()
gen_pursuit_hits(normal_steps, elite_steps, for_each_undisrupted_friendly_unit_in_hex)
},
- unit(who) {
+ unit_hit(who) {
push_undo()
game.hits -= reduce_unit(who)
},
- next() {
+ end_hits() {
clear_undo()
end_pursuit_fire()
},
@@ -4349,11 +4338,11 @@ states.rout_hits = {
let elite_steps = count_elite_steps_in_rout()
gen_pursuit_hits(normal_steps, elite_steps, for_each_friendly_unit_in_hex)
},
- unit(who) {
+ unit_hit(who) {
push_undo()
game.hits -= reduce_unit(who)
},
- next() {
+ end_hits() {
clear_undo()
end_rout_fire()
},
@@ -5846,6 +5835,10 @@ function gen_action_unit(u) {
gen_action('unit', u)
}
+function gen_action_unit_hit(u) {
+ gen_action('unit_hit', u)
+}
+
function gen_action_hex(x) {
gen_action('hex', x)
}