summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.js17
-rw-r--r--rules.js18
2 files changed, 23 insertions, 12 deletions
diff --git a/play.js b/play.js
index 01d0de9..67521de 100644
--- a/play.js
+++ b/play.js
@@ -7,11 +7,11 @@ const SCALE = 1.8033333333333332
const DEPLOY = 1
const ELIMINATED = 2
-const UG = 0
-const OPS = 1
-const PTL = 2
-const OC = 3
-const BOXES = [UG, OPS, PTL, OC]
+// const UG = 0
+// const OPS = 1
+// const PTL = 2
+// const OC = 3
+// const BOXES = [UG, OPS, PTL, OC]
const area_count = 31
const unit_count = 120
@@ -127,7 +127,7 @@ const UNIT_DISPERSED_SHIFT = 2
const UNIT_DISPERSED_MASK = 1 << UNIT_DISPERSED_SHIFT
const UNIT_BOX_SHIFT = 3
-const UNIT_BOX_MASK = 2 << UNIT_BOX_SHIFT
+const UNIT_BOX_MASK = 3 << UNIT_BOX_SHIFT
const UNIT_LOC_SHIFT = 5
const UNIT_LOC_MASK = 255 << UNIT_LOC_SHIFT
@@ -312,7 +312,6 @@ function on_init() {
let area_id = data.areas[i].id
let type = data.areas[i].type
if (type) {
- console.log("create area", i, area_id)
create_area(i, area_id, type)
// Unit Boxes
@@ -357,6 +356,7 @@ function update_map() {
for (let u = 0; u < unit_count; ++u) {
let e = ui.units[u]
let loc = unit_loc(u)
+ e.dataset.loc = loc
if (loc) {
if (loc === DEPLOY) {
@@ -369,8 +369,7 @@ function update_map() {
if (!ui.eliminated.contains(e))
ui.eliminated.appendChild(e)
} else {
- let box_id = BOXES[unit_box(u)]
- console.log("box", u, loc, box_id)
+ let box_id = unit_box(u)
if (!ui.boxes[loc * 4 + box_id].contains(e))
ui.boxes[loc * 4 + box_id].appendChild(e)
}
diff --git a/rules.js b/rules.js
index 7a179c0..25e4c3d 100644
--- a/rules.js
+++ b/rules.js
@@ -46,6 +46,14 @@ var first_enemy_unit, last_enemy_unit
// #region PLAYER STATE
+function set_next_player() {
+ if (game.phasing === GOV_NAME)
+ game.phasing = FLN_NAME
+ else
+ game.phasing = GOV_NAME
+}
+
+
function set_active_player() {
clear_undo()
if (game.active !== game.phasing) {
@@ -295,7 +303,7 @@ const UNIT_DISPERSED_SHIFT = 2
const UNIT_DISPERSED_MASK = 1 << UNIT_DISPERSED_SHIFT
const UNIT_BOX_SHIFT = 3
-const UNIT_BOX_MASK = 2 << UNIT_BOX_SHIFT
+const UNIT_BOX_MASK = 3 << UNIT_BOX_SHIFT
const UNIT_LOC_SHIFT = 5
const UNIT_LOC_MASK = 255 << UNIT_LOC_SHIFT
@@ -335,7 +343,6 @@ function unit_box(u) {
}
function set_unit_box(u, x) {
- console.log("set_unit_box", u, x)
game.units[u] = (game.units[u] & ~UNIT_BOX_MASK) | (x << UNIT_BOX_SHIFT)
}
@@ -481,6 +488,7 @@ exports.view = function(state, player) {
log: game.log,
prompt: null,
scenario: game.scenario,
+ active: game.active,
phasing: game.phasing,
turn: game.turn,
@@ -773,7 +781,9 @@ states.scenario_setup = {
}
function end_scenario_setup() {
- set_enemy_player()
+ set_next_player()
+ set_active_player()
+
if (has_friendly_unit_in_loc(DEPLOY)) {
goto_scenario_setup()
} else {
@@ -957,10 +967,12 @@ function goto_jean_paul_sartre() {
}
function end_random_event() {
+ game.phasing = GOV_NAME
goto_reinforcement_phase()
}
function goto_reinforcement_phase() {
+ set_active_player()
game.state = "reinforcement"
}