summaryrefslogtreecommitdiff
path: root/ui.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-06-20 12:38:03 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:19:38 +0100
commit3e5c1379b6a230b8ce1d771b31858d9f93f6e46a (patch)
tree65c8ac1f123f55e8da1b64b14eefd6682f8523f8 /ui.js
parent9ecbee1517966c892c60ddc2310e03d57b0de413 (diff)
downloadcrusader-rex-3e5c1379b6a230b8ce1d771b31858d9f93f6e46a.tar.gz
crusader: Add "plural" info to block data for better messages.
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js41
1 files changed, 37 insertions, 4 deletions
diff --git a/ui.js b/ui.js
index d72e440..aff3787 100644
--- a/ui.js
+++ b/ui.js
@@ -4,8 +4,9 @@ const FRANK = "Frank";
const SARACEN = "Saracen";
const ASSASSINS = "Assassins";
const ENEMY = { Saracen: "Frank", Frank: "Saracen" }
-const POOL = "Pool";
const DEAD = "Dead";
+const F_POOL = "FP";
+const S_POOL = "SP";
let label_layout = window.localStorage['crusader-rex/label-layout'] || 'spread';
@@ -331,13 +332,43 @@ function update_steps(b, steps, element) {
}
function layout_blocks(location, secret, known) {
- if (label_layout == 'spread' || (location == POOL || location == DEAD))
+ if (label_layout == 'spread' || (location == S_POOL || location == F_POOL || location == DEAD))
layout_blocks_spread(location, secret, known);
else
layout_blocks_stacked(location, secret, known);
}
-function layout_blocks_spread(town, secret, known) {
+// function position_block(town, row, n_rows, col, n_cols, element) {
+
+function layout_blocks_spread(town, north, south) {
+ let wrap = TOWNS[town].wrap;
+ let rows = [];
+
+ if (north.length + south.length > wrap * 3) {
+ north = north.concat(south);
+ south = [];
+ }
+
+ function wrap_row(input) {
+ while (input.length > wrap) {
+ rows.push(input.slice(0, wrap));
+ input = input.slice(wrap);
+ }
+ if (input.length > 0)
+ rows.push(input);
+ }
+
+ wrap_row(north);
+ wrap_row(south);
+
+ for (let r = 0; r < rows.length; ++r) {
+ let cols = rows[r];
+ for (let c = 0; c < cols.length; ++c)
+ position_block(town, r, rows.length, c, cols.length, cols[c]);
+ }
+}
+
+function layout_blocks_spread_old(town, secret, known) {
let wrap = TOWNS[town].wrap;
let s = secret.length;
let k = known.length;
@@ -465,6 +496,8 @@ function update_map() {
let town = game.location[b];
if (town in TOWNS) {
let moved = game.moved[b] ? " moved" : "";
+ let castle = game.castle[b] ? " castle" : "";
+ // TODO: show besieging blocks too!
if (info.owner == player || info.owner == ASSASSINS) {
let image = " known block_" + info.image;
let steps = " r" + (info.steps - game.steps[b]);
@@ -493,7 +526,7 @@ function update_map() {
for (let where of game.actions.town)
ui.towns[where].classList.add('highlight');
if (game.muster)
- ui.towns[game.where].classList.add('muster');
+ ui.towns[game.muster].classList.add('muster');
if (!game.battle) {
if (game.actions && game.actions.block)