From b565ed66b562d97ecaa9617e7567d3534cde5de5 Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Thu, 28 Sep 2023 15:01:15 +0200 Subject: update unit bits --- play.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'play.js') 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)) -- cgit v1.2.3