summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.js12
-rw-r--r--ui.js72
2 files changed, 28 insertions, 56 deletions
diff --git a/data.js b/data.js
index 0255d5a..7ab693b 100644
--- a/data.js
+++ b/data.js
@@ -129,8 +129,8 @@ const TOWNS = {
"France":{"x":140,"y":573},
"England":{"x":140,"y":873},
"Sea":{"x":320,"y":900},
- "FP":{"x":50,"y":2150},
- "SP":{"x":125,"y":2150},
+ "FP":{"x":15,"y":573+21+66},
+ "SP":{"x":1275-15,"y":573+21+66},
"Dead":{"x":50,"y":80},
};
@@ -264,10 +264,10 @@ const PORTS = [];
TOWNS[name].wrap = wrap;
}
- town('Y', 0.0, 0.0, 30, "Pool", "FP", 0, "pool");
- town('Y', 0.0, 0.0, 30, "Pool", "SP", 0, "pool");
- town('Y', 1.0, 1.0, 30, "Pool", "Dead", 0, "pool");
- town('Y', 1.0, 1.0, 30, "Pool", "Sea", 0, "pool");
+ town('Y', 0.5, 1.0, 50, "Pool", "FP", 0, "pool");
+ town('Y', 0.5, 1.0, 50, "Pool", "SP", 0, "pool");
+ town('Y', 1.0, 1.0, 3, "Pool", "Dead", 0, "pool");
+ town('Y', 1.0, 1.0, 1, "Pool", "Sea", 0, "pool");
town('Y', 1.0, 0.5, 3, "Staging", "England", 3, "staging");
town('Y', 1.0, 0.5, 3, "Staging", "France", 3, "staging");
diff --git a/ui.js b/ui.js
index f5de84a..73604dd 100644
--- a/ui.js
+++ b/ui.js
@@ -364,7 +364,7 @@ function layout_blocks_spread(town, north, south) {
let wrap = TOWNS[town].wrap;
let rows = [];
- if (north.length + south.length > wrap * 2) {
+ if ((north.length > wrap || south.length > wrap) || (north.length + south.length <= 3)) {
north = north.concat(south);
south = [];
}
@@ -381,6 +381,9 @@ function layout_blocks_spread(town, north, south) {
wrap_row(north);
wrap_row(south);
+ if (TOWNS[town].layout_minor > 0.5)
+ rows.reverse();
+
for (let r = 0; r < rows.length; ++r) {
let cols = rows[r];
for (let c = 0; c < cols.length; ++c)
@@ -388,47 +391,6 @@ function layout_blocks_spread(town, north, south) {
}
}
-function layout_blocks_spread_old(town, secret, known) {
- let wrap = TOWNS[town].wrap;
- let s = secret.length;
- let k = known.length;
- let n = s + k;
- let row, rows = [];
- let i = 0;
-
- function new_line() {
- rows.push(row = []);
- i = 0;
- }
-
- new_line();
-
- while (secret.length > 0) {
- if (i == wrap)
- new_line();
- row.push(secret.shift());
- ++i;
- }
-
- // Break early if secret and known fit in exactly two rows, and more than three blocks total
- if (s > 0 && s <= wrap && k > 0 && k <= wrap && n > 3)
- new_line();
-
- while (known.length > 0) {
- if (i == wrap)
- new_line();
- row.push(known.shift());
- ++i;
- }
-
- if (TOWNS[town].layout_minor > 0.5)
- rows.reverse();
-
- for (let j = 0; j < rows.length; ++j)
- for (i = 0; i < rows[j].length; ++i)
- position_block(town, j, rows.length, i, rows[j].length, rows[j][i]);
-}
-
function position_block(town, row, n_rows, col, n_cols, element) {
let space = TOWNS[town];
let block_size = 60+6;
@@ -556,20 +518,30 @@ function update_map() {
jihad = " jihad";
element.classList = info.owner + " block" + moved + besieging + jihad;
}
- if (town == F_POOL || town == S_POOL)
- layout[F_POOL].north.push(element);
- else if (town == DEAD)
- layout[DEAD].north.push(element);
- else if (info.owner == FRANKS)
- layout[town].north.push(element);
- else
- layout[town].south.push(element);
+ if (town != DEAD) {
+ if (info.owner == FRANKS)
+ layout[town].north.push(element);
+ else
+ layout[town].south.push(element);
+ }
show_block(element);
} else {
hide_block(element);
}
}
+ for (let b in game.location) {
+ let info = BLOCKS[b];
+ let element = ui.blocks[b];
+ let town = game.location[b];
+ if (town == DEAD) {
+ if (info.owner == FRANKS)
+ layout[F_POOL].north.unshift(element);
+ else
+ layout[S_POOL].south.unshift(element);
+ }
+ }
+
for (let town in TOWNS)
layout_blocks(town, layout[town].north, layout[town].south);