summaryrefslogtreecommitdiff
path: root/data.js
diff options
context:
space:
mode:
Diffstat (limited to 'data.js')
-rw-r--r--data.js42
1 files changed, 27 insertions, 15 deletions
diff --git a/data.js b/data.js
index 137ad39..4743c37 100644
--- a/data.js
+++ b/data.js
@@ -33,10 +33,14 @@ const CARDS = {
27: { name: "1/2", move: 1, levy: 2, image: "12" },
};
-const BLOCKS = {};
+const block_index = {}
+const BLOCKS = []
+const space_index = {}
+const SPACES = []
+
const EDGES = {};
-const SPACES = {
+const SPACE_XY = {
Dead: { x: 300, y: 236 },
Levy: { x: 767, y: 1191 },
Aenos: { x: 1872, y: 463 },
@@ -119,13 +123,16 @@ const SPACES = {
(function () {
function space(axis, major_align, minor_align, wrap, name, type, value) {
- SPACES[name].type = type;
- SPACES[name].value = value | 0;
- SPACES[name].exits = [];
- SPACES[name].layout_axis = axis;
- SPACES[name].layout_major = (1 - major_align) / 2;
- SPACES[name].layout_minor = (1 - minor_align) / 2;
- SPACES[name].wrap = wrap;
+ let id = space_index[name] = SPACES.length
+ SPACES[id] = SPACE_XY[name]
+ SPACES[id].name = name;
+ SPACES[id].type = type;
+ SPACES[id].value = value | 0;
+ SPACES[id].exits = [];
+ SPACES[id].layout_axis = axis;
+ SPACES[id].layout_major = (1 - major_align) / 2;
+ SPACES[id].layout_minor = (1 - minor_align) / 2;
+ SPACES[id].wrap = wrap;
}
space('X', 0, 0, 3, "Dead", "pool");
@@ -210,9 +217,11 @@ const SPACES = {
space('X', 0, 0, 5, "Propontis", "sea");
function edge(a, b, type) {
+ a = space_index[a]
+ b = space_index[b]
if (a > b)
[a, b] = [b, a];
- let AB = a + "/" + b;
+ let AB = a * 100 + b;
EDGES[AB] = type;
SPACES[a].exits.push(b);
SPACES[b].exits.push(a);
@@ -393,10 +402,10 @@ const SPACES = {
let index = 0;
function block(owner, CR, steps, type, name, levy) {
- let id = name;
+ let sid = name;
let [initiative, firepower] = CR;
if (type !== 'leader' && type !== 'cleopatra' && type !== 'legio')
- id = owner[0] + " " + id;
+ sid = owner[0] + " " + sid;
let descr = name;
if (type !== 'leader' && type !== 'cleopatra' && type !== 'legio')
descr = owner[0] + ". " + descr;
@@ -406,14 +415,17 @@ const SPACES = {
else
descr += " (" + levy + ")";
}
+
+ let id = block_index[sid] = BLOCKS.length
BLOCKS[id] = {
owner: owner,
+ sid: sid,
name: name,
steps: steps,
initiative: initiative,
- firepower: firepower,
+ firepower: firepower | 0,
type: type,
- levy: levy,
+ levy: space_index[levy],
description: descr,
label: index++,
}
@@ -502,4 +514,4 @@ const SPACES = {
})();
if (typeof module !== 'undefined')
- module.exports = { CARDS, BLOCKS, SPACES, EDGES }
+ module.exports = { CARDS, BLOCKS, SPACES, EDGES, block_index, space_index }