summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js25
1 files changed, 21 insertions, 4 deletions
diff --git a/play.js b/play.js
index 6c4fe02..dd7874e 100644
--- a/play.js
+++ b/play.js
@@ -8,6 +8,13 @@ const svgNS = "http://www.w3.org/2000/svg"
const round = Math.round
const sqrt = Math.sqrt
+const class_name = [ "armor", "infantry", "anti-tank", "artillery" ]
+
+const ARMOR = 0
+const INFANTRY = 1
+const ANTITANK = 2
+const ARTILLERY = 3
+
function set_has(set, item) {
let a = 0
let b = set.length - 1
@@ -48,6 +55,8 @@ let ui = {
battle_message: document.getElementById("battle_message"),
battle_line_1: document.getElementById("battle_line_1"),
battle_line_2: document.getElementById("battle_line_2"),
+ battle_line_3: document.getElementById("battle_line_3"),
+ battle_line_4: document.getElementById("battle_line_4"),
onmap: document.getElementById("units"),
focus: null,
}
@@ -87,6 +96,10 @@ function is_unit_selected(unit) {
return !!(view.selected && view.selected.includes(unit))
}
+function is_artillery_unit(u) {
+ return units[u].class === ARTILLERY
+}
+
function is_allied_unit(u) {
return units[u].nationality === 'allied'
}
@@ -462,11 +475,15 @@ function update_battle() {
ui.battle_header.textContent = hex_name[view.battle]
ui.battle_message.textContent = view.flash
if (player === ALLIED) {
- update_battle_line(ui.battle_line_1, is_axis_unit)
- update_battle_line(ui.battle_line_2, is_allied_unit)
+ update_battle_line(ui.battle_line_1, u => is_axis_unit(u) && is_artillery_unit(u))
+ update_battle_line(ui.battle_line_2, u => is_axis_unit(u) && !is_artillery_unit(u))
+ update_battle_line(ui.battle_line_3, u => is_allied_unit(u) && !is_artillery_unit(u))
+ update_battle_line(ui.battle_line_4, u => is_allied_unit(u) && is_artillery_unit(u))
} else {
- update_battle_line(ui.battle_line_1, is_allied_unit)
- update_battle_line(ui.battle_line_2, is_axis_unit)
+ update_battle_line(ui.battle_line_1, u => is_allied_unit(u) && is_artillery_unit(u))
+ update_battle_line(ui.battle_line_2, u => is_allied_unit(u) && !is_artillery_unit(u))
+ update_battle_line(ui.battle_line_3, u => is_axis_unit(u) && !is_artillery_unit(u))
+ update_battle_line(ui.battle_line_4, u => is_axis_unit(u) && is_artillery_unit(u))
}
target_button("armor")
target_button("infantry")