summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-09-28 15:01:15 +0200
committerMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-09-28 15:01:15 +0200
commitb565ed66b562d97ecaa9617e7567d3534cde5de5 (patch)
tree982788b3973bac7b2ab865cb7a9da0e8ab2d1f18 /play.js
parent81a5887cf147acf9e635a9e26aeacb9efb4c2aa4 (diff)
downloadalgeria-b565ed66b562d97ecaa9617e7567d3534cde5de5.tar.gz
update unit bits
Diffstat (limited to 'play.js')
-rw-r--r--play.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/play.js b/play.js
index 38172d9..f64ec91 100644
--- a/play.js
+++ b/play.js
@@ -80,7 +80,7 @@ let ui = {
// === UNIT STATE ===
-// location (8 bits), dispersed (1 bit), airmobile (1 bit), neutralized (1 bit)
+// location (8 bits), op box (2 bits), dispersed (1 bit), airmobile (1 bit), neutralized (1 bit)
const UNIT_NEUTRALIZED_SHIFT = 0
const UNIT_NEUTRALIZED_MASK = 1 << UNIT_NEUTRALIZED_SHIFT
@@ -91,7 +91,10 @@ const UNIT_AIRMOBILE_MASK = 1 << UNIT_AIRMOBILE_SHIFT
const UNIT_DISPERSED_SHIFT = 2
const UNIT_DISPERSED_MASK = 1 << UNIT_DISPERSED_SHIFT
-const UNIT_LOC_SHIFT = 3
+const UNIT_BOX_SHIFT = 3
+const UNIT_BOX_MASK = 2 << UNIT_BOX_SHIFT
+
+const UNIT_LOC_SHIFT = 5
const UNIT_LOC_MASK = 255 << UNIT_LOC_SHIFT
function is_unit_neutralized(u) {
@@ -102,6 +105,10 @@ function unit_loc(u) {
return (view.units[u] & UNIT_LOC_MASK) >> UNIT_LOC_SHIFT
}
+function unit_box(u) {
+ return (view.units[u] & UNIT_BOX_MASK) >> UNIT_BOX_SHIFT
+}
+
function is_unit_airmobile(u) {
return (view.units[u] & UNIT_AIRMOBILE_MASK) === UNIT_AIRMOBILE_MASK
}
@@ -329,8 +336,9 @@ function update_map() {
if (!ui.eliminated.contains(e))
ui.eliminated.appendChild(e)
} else {
- if (!ui.boxes[loc].contains(e))
- ui.boxes[loc].appendChild(e)
+ let box_id = unit_box(u)
+ if (!ui.boxes[loc * 4 + box_id].contains(e))
+ ui.boxes[loc * 4 + box_id].appendChild(e)
}
update_unit(e, u)
} else {
@@ -349,7 +357,7 @@ function update_map() {
function on_update() {
on_init()
- // update_map()
+ update_map()
for (let e of action_register)
e.classList.toggle("action", is_action(e.my_action, e.my_id))