summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-07-28 18:49:04 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 13:11:26 +0100
commit6d47047daf88fef9f2cda7f060d33e571a88893f (patch)
treea1c24d0b719815bedfa468a7bfe45549b6729c15 /play.js
parent1f3e8f7fcc6c283bfe31240475cdff3d5fc6b7fd (diff)
downloadrommel-in-the-desert-6d47047daf88fef9f2cda7f060d33e571a88893f.tar.gz
Malta and reinforcement tracks.
Diffstat (limited to 'play.js')
-rw-r--r--play.js24
1 files changed, 19 insertions, 5 deletions
diff --git a/play.js b/play.js
index 78e1b3a..3faba75 100644
--- a/play.js
+++ b/play.js
@@ -11,7 +11,8 @@ const sqrt = Math.sqrt
const class_name = [ "armor", "infantry", "anti-tank", "artillery" ]
// refit and queue hexes
-const hex_special = [ 48, 49, 102, 127 ]
+const MALTA = 4
+const hex_special = [ 48, 49, 102, 127, MALTA ]
const ARMOR = 0
const INFANTRY = 1
@@ -355,6 +356,7 @@ const HIGHWAY = 4
const map_w = 25
const map_h = 9
+const hexdeploy = map_w * map_h
let hexnext = [ 1, map_w, map_w-1, -1, -map_w, -(map_w-1) ]
@@ -455,10 +457,14 @@ function build_hexes() {
}
}
- for (let month = 1; month <= 20; ++month) {
+ 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
}
+ 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
+ }
document.getElementById("mapsvg").getElementById("grid").setAttribute("d", path.join(" "))
@@ -525,6 +531,10 @@ function update_map() {
for (let u = 0; u < units.length; ++u) {
let e = ui.units[u]
let hex = unit_hex(u)
+ if (view.month <= 10 && hex > hexdeploy + 10)
+ hex = 0
+ if (view.month <= 10 && hex === MALTA)
+ hex = 0
if (hex) {
if (!ui.onmap.contains(e))
ui.onmap.appendChild(e)
@@ -538,9 +548,10 @@ function update_map() {
for (let hex = 0; hex < stack.length; ++hex) {
let start_x = ui.hex_x[hex]
let start_y = ui.hex_y[hex]
+ let wrap = 6
if (stack[hex] === ui.focus) {
- let height = stack[hex].length * 56
+ let height = Math.min(wrap, stack[hex].length) * 56
if (start_y + height + 25 > 960)
start_y = 960 - height + 25
}
@@ -551,8 +562,11 @@ function update_map() {
let x, y, z
if (stack[hex] === ui.focus) {
- x = start_x - 25
- y = start_y - 25 + i * 56
+ if (start_x > 2000)
+ x = start_x - 25 - ((i / wrap) | 0) * 56
+ else
+ x = start_x - 25 + ((i / wrap) | 0) * 56
+ y = start_y - 25 + (i % wrap) * 56
z = 100
} else {
if (stack[hex].length <= 1) {