summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js34
1 files changed, 29 insertions, 5 deletions
diff --git a/play.js b/play.js
index 5715d70..a424ad8 100644
--- a/play.js
+++ b/play.js
@@ -72,6 +72,8 @@ let ui = {
units: [],
battle_units: [],
cards: [],
+ minefields: [],
+ months: [],
axis_supply: document.getElementById("axis_supply"),
allied_supply: document.getElementById("allied_supply"),
turn_info: document.getElementById("turn_info"),
@@ -103,7 +105,8 @@ let ui = {
pursuit_line_1: document.getElementById("pursuit_line_1"),
pursuit_line_2: document.getElementById("pursuit_line_2"),
- onmap: document.getElementById("units"),
+ units_holder: document.getElementById("units"),
+ minefields_holder: document.getElementById("minefields"),
focus: null,
loaded: false,
}
@@ -524,10 +527,12 @@ function build_hexes() {
for (let month = 1; month <= 10; ++month) {
ui.hex_y[map_w * map_h + month] = 24 + 37
ui.hex_x[map_w * map_h + month] = 1840 + 37 + (month-1) * 81
+ ui.months[month] = document.getElementById("month" + month)
}
for (let month = 11; month <= 20; ++month) {
ui.hex_y[map_w * map_h + month] = 24 + 37 // + 81
ui.hex_x[map_w * map_h + month] = 1840 + 37 + (month-11) * 81
+ ui.months[month] = document.getElementById("month" + month)
}
document.getElementById("mapsvg").getElementById("grid").setAttribute("d", path.join(" "))
@@ -597,13 +602,13 @@ function update_map() {
for (let u = 0; u < unit_count; ++u) {
let e = ui.units[u]
let hex = unit_hex(u)
- if (view.month <= 10 && hex > hexdeploy + 10)
+ if (hex >= hexdeploy + view.month + 10)
hex = 0
if (view.month <= 10 && hex === MALTA)
hex = 0
if (hex) {
- if (!ui.onmap.contains(e))
- ui.onmap.appendChild(e)
+ if (!ui.units_holder.contains(e))
+ ui.units_holder.appendChild(e)
stack[hex].push(u)
e.stack = stack[hex]
} else {
@@ -611,6 +616,25 @@ function update_map() {
}
}
+ for (let i = 1; i <= 20; ++i) {
+ ui.months[i].classList.toggle("show", (i >= view.start && i <= view.end) && (i < view.month + 10))
+ ui.months[i].classList.toggle("now", i === view.month)
+ }
+
+ for (let i = ui.minefields.length; i < view.minefields.length; ++i) {
+ let elt = ui.minefields[i] = document.createElement("div")
+ elt.className = "minefield"
+ ui.minefields_holder.appendChild(elt)
+ }
+ for (let i = view.minefields.length; i < ui.minefields.length; ++i) {
+ ui.minefields[i].remove()
+ }
+ for (let i = 0; i < view.minefields.length; ++i) {
+ let hex = view.minefields[i]
+ ui.minefields[i].style.left = (ui.hex_x[hex] - 40) + "px"
+ ui.minefields[i].style.top = (ui.hex_y[hex] + 4) + "px"
+ }
+
for (let hex = 0; hex < stack.length; ++hex) {
let start_x = ui.hex_x[hex]
let start_y = ui.hex_y[hex]
@@ -797,7 +821,7 @@ function on_update() {
ui.axis_supply.textContent = view.axis_hand
ui.allied_supply.textContent = view.allied_hand
- ui.turn_info.textContent = `Month: ${view.month}\nSupply Commitment: ${view.commit}`
+ ui.turn_info.textContent = `Month: ${view.month} / ${view.end}\nSupply Commitment: ${view.commit}`
for (let i = 0; i < 28; ++i)
ui.cards[i].classList.toggle("action", !!(view.actions && view.actions.real_card))