summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js39
1 files changed, 33 insertions, 6 deletions
diff --git a/play.js b/play.js
index f9f2c75..9ab21b3 100644
--- a/play.js
+++ b/play.js
@@ -24,6 +24,8 @@ const SS_BENGHAZI = 3
const SS_TOBRUK = 4
const SS_OASIS = 5
+const DEPLOY = 1
+
const ARMOR = 0
const INFANTRY = 1
const ANTITANK = 2
@@ -159,7 +161,7 @@ function unit_lost_steps(u) {
}
function unit_steps(u) {
- return unit_start_steps[u] - unit_lost_steps(u)
+ return unit_max_steps[u] - unit_lost_steps(u)
}
function is_unit_moved(u) {
@@ -240,12 +242,16 @@ function is_hex_selected(hex) {
return set_has(view.selected_hexes, hex)
}
-function focus_stack(stack) {
+function is_setup_hex(hex) {
+ return hex === DEPLOY
+}
+
+function focus_stack(stack, hex) {
if (ui.focus !== stack) {
- console.log("FOCUS STACK", stack)
+ console.log("FOCUS STACK", stack, hex)
ui.focus = stack
update_map()
- return stack.length <= 1
+ return stack.length <= 1 || hex === hexdeploy + view.month
}
return true
}
@@ -284,7 +290,7 @@ function on_click_unit(evt) {
if (evt.button === 0) {
hide_supply()
evt.stopPropagation()
- if (focus_stack(evt.target.stack))
+ if (focus_stack(evt.target.stack, evt.target.hex))
send_action('unit', evt.target.unit)
}
}
@@ -615,6 +621,12 @@ function update_map() {
let hex = unit_hex(u)
if (hex >= hexdeploy + view.month + 10)
hex = 0
+ if (hex === hexdeploy + view.month) {
+ if (player === "Axis" && !is_axis_unit(u))
+ hex = 0
+ if (player === "Allied" && !is_allied_unit(u))
+ hex = 0
+ }
if (view.month <= 10 && hex === MALTA)
hex = 0
if (hex) {
@@ -622,6 +634,7 @@ function update_map() {
ui.units_holder.appendChild(e)
stack[hex].push(u)
e.stack = stack[hex]
+ e.hex = hex
} else {
e.remove()
}
@@ -629,6 +642,7 @@ 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("show", true)
ui.months[i].classList.toggle("now", i === view.month)
}
@@ -657,6 +671,11 @@ function update_map() {
let start_y = ui.hex_y[hex]
let wrap = 6
+ if (hex === hexdeploy + view.month) {
+ start_x = 1095
+ start_y = 25 + 8
+ }
+
if (stack[hex] === ui.focus) {
let height = Math.min(wrap, stack[hex].length) * 56
if (start_y + height + 25 > 960)
@@ -668,7 +687,15 @@ function update_map() {
let e = ui.units[u]
let x, y, z
- if (stack[hex] === ui.focus) {
+ if (hex === hexdeploy + view.month) {
+ if (view.month == 8)
+ wrap = 14
+ else
+ wrap = 12
+ x = start_x - 25 + ((i % wrap) | 0) * 56
+ y = start_y - 25 + ((i / wrap) | 0) * 56
+ z = 101
+ } else if (stack[hex] === ui.focus) {
if (start_x > 2000)
x = start_x - 25 - ((i / wrap) | 0) * 56
else