summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js31
1 files changed, 17 insertions, 14 deletions
diff --git a/play.js b/play.js
index d359eb9..ea429df 100644
--- a/play.js
+++ b/play.js
@@ -9,6 +9,9 @@ const POOL = "Pool";
const DEAD = "Dead";
const MINOR = "Minor";
+const NOBODY = -1
+const NOWHERE = 0
+
const KING_TEXT = "\u2756";
const PRETENDER_TEXT = "";
@@ -128,7 +131,7 @@ const STEP_TEXT = [ 0, "I", "II", "III", "IIII" ];
const HEIR_TEXT = [ 0, '\u00b9', '\u00b2', '\u00b3', '\u2074', '\u2075' ];
function block_name(who) {
- if (!who) return "Nobody";
+ if (who === NOBODY) return "Nobody";
let name = BLOCKS[who].name;
let long_name = LONG_NAME[name];
return long_name ? long_name : name;
@@ -136,9 +139,9 @@ function block_name(who) {
function block_owner(who) {
if (who === REBEL) {
- if (view.pretender)
+ if (view.pretender !== NOBODY)
return BLOCKS[view.pretender].owner;
- if (view.king)
+ if (view.king !== NOBODY)
return ENEMY[BLOCKS[view.king].owner];
return YORK;
}
@@ -454,7 +457,7 @@ function hide_block(element) {
}
function is_dead(who) {
- return view.location[who] === null;
+ return view.location[who] === NOWHERE;
}
function is_perma_dead(who) {
@@ -493,14 +496,14 @@ function update_map() {
let known = is_known_block(b);
// perma-dead nobles
- if (area === null && is_perma_dead(b)) {
+ if (area === NOWHERE && is_perma_dead(b)) {
area = DEAD;
moved = " moved";
known = 1;
steps = "";
}
- if (area !== null) {
+ if (area !== NOWHERE) {
if (known) {
element.classList = info.owner + " known block" + image + steps + moved;
} else {
@@ -528,16 +531,16 @@ function update_map() {
}
}
- for (let where in AREAS) {
- if (ui.areas[where]) {
- ui.areas[where].classList.remove('highlight');
- ui.areas[where].classList.remove('where');
+ for (let area in AREAS) {
+ if (ui.areas[area]) {
+ ui.areas[area].classList.remove('highlight');
+ ui.areas[area].classList.remove('where');
}
}
if (view.actions && view.actions.area)
- for (let where of view.actions.area)
- ui.areas[where].classList.add('highlight');
- if (view.where)
+ for (let area of view.actions.area)
+ ui.areas[area].classList.add('highlight');
+ if (view.where !== NOWHERE)
ui.areas[view.where].classList.add('where');
for (let b in BLOCKS) {
@@ -548,7 +551,7 @@ function update_map() {
if (view.actions && view.actions.block)
for (let b of view.actions.block)
ui.blocks[b].classList.add('highlight');
- if (view.who)
+ if (view.who !== NOBODY)
ui.blocks[view.who].classList.add('selected');
}
}