summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-10-01 18:36:07 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:08:56 +0100
commit6f327defb9832c0ed2ca99570bba0b91ffd5a36e (patch)
tree1476afefe59bf0774650b42ba96cb702ea5c9936
parent4e6abb7da87927fa4221ff5c9e5674de9d067420 (diff)
downloadjulius-caesar-6f327defb9832c0ed2ca99570bba0b91ffd5a36e.tar.gz
More tweaks.
-rw-r--r--data.js803
-rw-r--r--play.css1
-rw-r--r--play.js80
-rw-r--r--rules.js64
4 files changed, 404 insertions, 544 deletions
diff --git a/data.js b/data.js
index 4743c37..8a5b249 100644
--- a/data.js
+++ b/data.js
@@ -1,7 +1,4 @@
-"use strict";
-
-const CAESAR = "Caesar";
-const POMPEIUS = "Pompeius";
+"use strict"
const CARDS = {
1: { name: "Apollo", event: "Apollo", image: "apollo" },
@@ -31,200 +28,107 @@ const CARDS = {
25: { name: "1/3", move: 1, levy: 3, image: "13" },
26: { name: "1/2", move: 1, levy: 2, image: "12" },
27: { name: "1/2", move: 1, levy: 2, image: "12" },
-};
+}
-const block_index = {}
const BLOCKS = []
-const space_index = {}
const SPACES = []
+const EDGES = {}
-const EDGES = {};
-
-const SPACE_XY = {
- Dead: { x: 300, y: 236 },
- Levy: { x: 767, y: 1191 },
- Aenos: { x: 1872, y: 463 },
- Aleria: { x: 1000, y: 470 },
- Alexandria: { x: 2045, y: 1083 },
- Ambracia: { x: 1582, y: 600 },
- Ancyra: { x: 2195, y: 488 },
- Antiochia: { x: 2360, y: 700 },
- Appia: { x: 2043, y: 553 },
- Aquileia: { x: 1215, y: 206 },
- Asculum: { x: 1233, y: 394 },
- Asturica: { x: 232, y: 565 },
- Athenae: { x: 1739, y: 663 },
- Badias: { x: 902, y: 977 },
- Bilbilis: { x: 459, y: 585 },
- Brundisium: { x: 1441, y: 525 },
- Burdigala: { x: 495, y: 320 },
- Byzantium: { x: 1990, y: 417 },
- Caralis: { x: 990, y: 665 },
- 'Carthago Nova': { x: 479, y: 818 },
- Catabathmus: { x: 1890, y: 1080 },
- Cenabum: { x: 653, y: 133 },
- Corduba: { x: 317, y: 837 },
- Creta: { x: 1794, y: 842 },
- Cyrene: { x: 1584, y: 1044 },
- Damascus: { x: 2415, y: 870 },
- Dyrrachium: { x: 1522, y: 472 },
- Emerita: { x: 200, y: 765 },
- Ephesus: { x: 1905, y: 635 },
- Eusebia: { x: 2310, y: 556 },
- Gades: { x: 232, y: 922 },
- Genua: { x: 995, y: 313 },
- Iomnium: { x: 763, y: 860 },
- Jerusalem: { x: 2324, y: 994 },
- Lilybaeum: { x: 1172, y: 731 },
- Lugdunum: { x: 790, y: 235 },
- Massilia: { x: 795, y: 405 },
- Memphis: { x: 2105, y: 1167 },
- Messana: { x: 1290, y: 708 },
- Narbo: { x: 695, y: 455 },
- Neapolis: { x: 1298, y: 535 },
- Nicomedia: { x: 2056, y: 424 },
- Olisipo: { x: 92, y: 810 },
- Pelusium: { x: 2178, y: 1069 },
- Perga: { x: 2085, y: 700 },
- Pergamum: { x: 1913, y: 535 },
- Portus: { x: 100, y: 630 },
- Pylos: { x: 1633, y: 733 },
- Ravenna: { x: 1144, y: 286 },
- Rhegium: { x: 1357, y: 698 },
- Roma: { x: 1160, y: 450 },
- Sala: { x: 205, y: 1089 },
- Salamis: { x: 2240, y: 800 },
- Salona: { x: 1336, y: 319 },
- Serdica: { x: 1689, y: 354 },
- Siga: { x: 472, y: 987 },
- Sinope: { x: 2303, y: 339 },
- Sipontum: { x: 1325, y: 455 },
- Sirmium: { x: 1460, y: 208 },
- Syracusae: { x: 1302, y: 778 },
- Tacape: { x: 1059, y: 1019 },
- Tarraco: { x: 564, y: 599 },
- Tarsus: { x: 2285, y: 675 },
- Thessalonica: { x: 1689, y: 484 },
- Thubactus: { x: 1276, y: 1084 },
- Tingis: { x: 257, y: 1000 },
- Toletum: { x: 359, y: 712 },
- Treviri: { x: 860, y: 68 },
- Utica: { x: 1045, y: 795 },
- 'Mare Aegaeum': { x: 1830, y: 670 },
- 'Mare Aegypticum': { x: 2020, y: 905 },
- 'Mare Hadriaticum': { x: 1360, y: 390 },
- 'Mare Hispanum': { x: 835, y: 650 },
- 'Mare Internum': { x: 1485, y: 870 },
- 'Mare Tyrrhenum': { x: 1140, y: 640 },
- 'Oceanus Atlanticus': { x: 118, y: 1014 },
- 'Pontus Euxinus': { x: 2147, y: 271 },
- 'Propontis': { x: 1945, y: 468 }
-};
-
-(function () {
- function space(axis, major_align, minor_align, wrap, name, type, value) {
- 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;
+function init_data() {
+ function space(name, type, value, axis, major, minor, wrap, x, y) {
+ major = (1 - major) / 2
+ minor = (1 - minor) / 2
+ SPACES.push({name, type, value, exits: [], layout: { axis, major, minor, wrap, x, y }})
}
- space('X', 0, 0, 3, "Dead", "pool");
- space('X', 0, 0, 18, "Levy", "pool");
-
- space('Y', -1, 0, 3, "Aenos", "port");
- space('X', 0, 0, 3, "Aleria", "port");
- space('X', 0, -1, 3, "Alexandria", "major-port", 2);
- space('X', 0, 0, 3, "Ambracia", "port");
- space('X', 1, 0, 3, "Ancyra", "city");
- space('Y', 0, 1, 4, "Antiochia", "port", 1);
- space('X', 1, 0, 3, "Appia", "city");
- space('X', 1, 0, 3, "Aquileia", "port");
- space('Y', 0, 1, 3, "Asculum", "city");
- space('Y', -1, 0, 3, "Asturica", "city");
- space('Y', 0, 0, 4, "Athenae", "major-port", 1);
- space('X', -1, 1, 3, "Badias", "city");
- space('X', -1, 0, 3, "Bilbilis", "city");
- space('Y', 1, 0, 3, "Brundisium", "port");
- space('Y', 1, -1, 3, "Burdigala", "port");
- space('Y', -1, 0, 4, "Byzantium", "port", 1);
- space('Y', -1, 0, 3, "Caralis", "port");
- space('X', 1, 0, 4, "Carthago Nova", "major-port", 1);
- space('X', -1, 1, 3, "Catabathmus", "port");
- space('X', -1, 0, 3, "Cenabum", "city");
- space('X', 0, 0, 3, "Corduba", "city");
- space('X', 0, 0, 3, "Creta", "major-port");
- space('X', 0, 1, 3, "Cyrene", "port");
- space('X', -1, 0, 3, "Damascus", "city");
- space('Y', -1, 0, 3, "Dyrrachium", "port");
- space('Y', -1, 0, 3, "Emerita", "city");
- space('X', 1, 0, 4, "Ephesus", "major-port", 1);
- space('X', 1, 0, 3, "Eusebia", "city");
- space('X', 0, 0, 3, "Gades", "port");
- space('Y', -1, -1, 3, "Genua", "port");
- space('X', 0, 1, 3, "Iomnium", "port");
- space('X', 0, 0, 3, "Jerusalem", "city");
- space('Y', 1, 0, 3, "Lilybaeum", "port");
- space('X', 0, -1, 3, "Lugdunum", "city");
- space('Y', 0, 1, 4, "Massilia", "major-port", 1);
- space('X', 0, 1, 3, "Memphis", "city");
- space('Y', -1, 0, 3, "Messana", "port");
- space('X', -1, 0, 3, "Narbo", "port");
- space('X', 0, 1, 3, "Neapolis", "major-port");
- space('X', 1, 0, 3, "Nicomedia", "port");
- space('Y', 1, 0, 3, "Olisipo", "port");
- space('X', 1, 0, 3, "Pelusium", "port");
- space('Y', 1, -1, 3, "Perga", "port");
- space('X', 0, 0, 3, "Pergamum", "city");
- space('Y', 0, 0, 3, "Portus", "port");
- space('X', -1, 0, 3, "Pylos", "port");
- space('Y', -1, -1, 3, "Ravenna", "major-port");
- space('X', 1, 0, 3, "Rhegium", "port");
- space('Y', 0, -1, 4, "Roma", "port", 2);
- space('X', 1, 1, 3, "Sala", "port");
- space('X', 0, 0, 3, "Salamis", "major-port");
- space('X', 1, 0, 3, "Salona", "port");
- space('X', 0, 0, 3, "Serdica", "city");
- space('X', 0, 1, 3, "Siga", "port");
- space('X', 0, 0, 3, "Sinope", "port");
- space('X', 1, 0, 3, "Sipontum", "port");
- space('X', 1, -1, 3, "Sirmium", "city");
- space('Y', 1, 0, 4, "Syracusae", "major-port", 1);
- space('X', 0, 1, 3, "Tacape", "port");
- space('X', 1, 0, 4, "Tarraco", "port", 1);
- space('X', -1, 0, 3, "Tarsus", "port");
- space('X', 0, 0, 3, "Thessalonica", "port");
- space('X', 0, 0, 3, "Thubactus", "port");
- space('X', 0, 0, 3, "Tingis", "port");
- space('X', 0, 0, 3, "Toletum", "city");
- space('X', 1, 1, 3, "Treviri", "city");
- space('X', -1, 0, 4, "Utica", "major-port", 1);
-
- space('Y', 0, 0, 5, "Mare Aegaeum", "sea");
- space('X', 0, 0, 5, "Mare Aegypticum", "sea");
- space('X', 0, 0, 5, "Mare Hadriaticum", "sea");
- space('Y', 0, 0, 5, "Mare Hispanum", "sea");
- space('X', 0, 0, 5, "Mare Internum", "sea");
- space('X', 0, 0, 5, "Mare Tyrrhenum", "sea");
- space('Y', 0, 0, 5, "Oceanus Atlanticus", "sea");
- space('X', 0, 0, 5, "Pontus Euxinus", "sea");
- space('X', 0, 0, 5, "Propontis", "sea");
+ space("Dead", "pool", 0, "X", 0, 0, 3, 300, 236)
+ space("Levy", "pool", 0, "X", 0, 0, 18, 767, 1191)
+
+ space("Aenos", "port", 0, "Y", -1, 0, 3, 1872, 463)
+ space("Aleria", "port", 0, "X", 0, 0, 3, 1000, 470)
+ space("Alexandria", "major-port", 2, "X", 0, -1, 3, 2045, 1083)
+ space("Ambracia", "port", 0, "X", 0, 0, 3, 1582, 600)
+ space("Ancyra", "city", 0, "X", 1, 0, 3, 2195, 488)
+ space("Antiochia", "port", 1, "Y", 0, 1, 4, 2360, 700)
+ space("Appia", "city", 0, "X", 1, 0, 3, 2043, 553)
+ space("Aquileia", "port", 0, "X", 1, 0, 3, 1215, 206)
+ space("Asculum", "city", 0, "Y", 0, 1, 3, 1233, 394)
+ space("Asturica", "city", 0, "Y", -1, 0, 3, 232, 565)
+ space("Athenae", "major-port", 1, "Y", 0, 0, 4, 1739, 663)
+ space("Badias", "city", 0, "X", -1, 1, 3, 902, 977)
+ space("Bilbilis", "city", 0, "X", -1, 0, 3, 459, 585)
+ space("Brundisium", "port", 0, "Y", 1, 0, 3, 1441, 525)
+ space("Burdigala", "port", 0, "Y", 1, -1, 3, 495, 320)
+ space("Byzantium", "port", 1, "Y", -1, 0, 4, 1990, 417)
+ space("Caralis", "port", 0, "Y", -1, 0, 3, 990, 665)
+ space("Carthago Nova", "major-port", 1, "X", 1, 0, 4, 479, 818)
+ space("Catabathmus", "port", 0, "X", -1, 1, 3, 1890, 1080)
+ space("Cenabum", "city", 0, "X", -1, 0, 3, 653, 133)
+ space("Corduba", "city", 0, "X", 0, 0, 3, 317, 837)
+ space("Creta", "major-port", 0, "X", 0, 0, 3, 1794, 842)
+ space("Cyrene", "port", 0, "X", 0, 1, 3, 1584, 1044)
+ space("Damascus", "city", 0, "X", -1, 0, 3, 2415, 870)
+ space("Dyrrachium", "port", 0, "Y", -1, 0, 3, 1522, 472)
+ space("Emerita", "city", 0, "Y", -1, 0, 3, 200, 765)
+ space("Ephesus", "major-port", 1, "X", 1, 0, 4, 1905, 635)
+ space("Eusebia", "city", 0, "X", 1, 0, 3, 2310, 556)
+ space("Gades", "port", 0, "X", 0, 0, 3, 232, 922)
+ space("Genua", "port", 0, "Y", -1, -1, 3, 995, 313)
+ space("Iomnium", "port", 0, "X", 0, 1, 3, 763, 860)
+ space("Jerusalem", "city", 0, "X", 0, 0, 3, 2324, 994)
+ space("Lilybaeum", "port", 0, "Y", 1, 0, 3, 1172, 731)
+ space("Lugdunum", "city", 0, "X", 0, -1, 3, 790, 235)
+ space("Massilia", "major-port", 1, "Y", 0, 1, 4, 795, 405)
+ space("Memphis", "city", 0, "X", 0, 1, 3, 2105, 1167)
+ space("Messana", "port", 0, "Y", -1, 0, 3, 1290, 708)
+ space("Narbo", "port", 0, "X", -1, 0, 3, 695, 455)
+ space("Neapolis", "major-port", 0, "X", 0, 1, 3, 1298, 535)
+ space("Nicomedia", "port", 0, "X", 1, 0, 3, 2056, 424)
+ space("Olisipo", "port", 0, "Y", 1, 0, 3, 92, 810)
+ space("Pelusium", "port", 0, "X", 1, 0, 3, 2178, 1069)
+ space("Perga", "port", 0, "Y", 1, -1, 3, 2085, 700)
+ space("Pergamum", "city", 0, "X", 0, 0, 3, 1913, 535)
+ space("Portus", "port", 0, "Y", 0, 0, 3, 100, 630)
+ space("Pylos", "port", 0, "X", -1, 0, 3, 1633, 733)
+ space("Ravenna", "major-port", 0, "Y", -1, -1, 3, 1144, 286)
+ space("Rhegium", "port", 0, "X", 1, 0, 3, 1357, 698)
+ space("Roma", "port", 2, "Y", 0, -1, 4, 1160, 450)
+ space("Sala", "port", 0, "X", 1, 1, 3, 205, 1089)
+ space("Salamis", "major-port", 0, "X", 0, 0, 3, 2240, 800)
+ space("Salona", "port", 0, "X", 1, 0, 3, 1336, 319)
+ space("Serdica", "city", 0, "X", 0, 0, 3, 1689, 354)
+ space("Siga", "port", 0, "X", 0, 1, 3, 472, 987)
+ space("Sinope", "port", 0, "X", 0, 0, 3, 2303, 339)
+ space("Sipontum", "port", 0, "X", 1, 0, 3, 1325, 455)
+ space("Sirmium", "city", 0, "X", 1, -1, 3, 1460, 208)
+ space("Syracusae", "major-port", 1, "Y", 1, 0, 4, 1302, 778)
+ space("Tacape", "port", 0, "X", 0, 1, 3, 1059, 1019)
+ space("Tarraco", "port", 1, "X", 1, 0, 4, 564, 599)
+ space("Tarsus", "port", 0, "X", -1, 0, 3, 2285, 675)
+ space("Thessalonica", "port", 0, "X", 0, 0, 3, 1689, 484)
+ space("Thubactus", "port", 0, "X", 0, 0, 3, 1276, 1084)
+ space("Tingis", "port", 0, "X", 0, 0, 3, 257, 1000)
+ space("Toletum", "city", 0, "X", 0, 0, 3, 359, 712)
+ space("Treviri", "city", 0, "X", 1, 1, 3, 860, 68)
+ space("Utica", "major-port", 1, "X", -1, 0, 4, 1045, 795)
+
+ space("Mare Aegaeum", "sea", 0, "Y", 0, 0, 5, 1830, 670)
+ space("Mare Aegypticum", "sea", 0, "X", 0, 0, 5, 2020, 905)
+ space("Mare Hadriaticum", "sea", 0, "X", 0, 0, 5, 1360, 390)
+ space("Mare Hispanum", "sea", 0, "Y", 0, 0, 5, 835, 650)
+ space("Mare Internum", "sea", 0, "X", 0, 0, 5, 1485, 870)
+ space("Mare Tyrrhenum", "sea", 0, "X", 0, 0, 5, 1140, 640)
+ space("Oceanus Atlanticus", "sea", 0, "Y", 0, 0, 5, 118, 1014)
+ space("Pontus Euxinus", "sea", 0, "X", 0, 0, 5, 2147, 271)
+ space("Propontis", "sea", 0, "X", 0, 0, 5, 1945, 468)
function edge(a, b, type) {
- a = space_index[a]
- b = space_index[b]
- if (a > b)
- [a, b] = [b, a];
- let AB = a * 100 + b;
- EDGES[AB] = type;
- SPACES[a].exits.push(b);
- SPACES[b].exits.push(a);
+ a = SPACES.findIndex(s=>s.name===a)
+ b = SPACES.findIndex(s=>s.name===b)
+ let AB = (a > b) ? b * 100 + a : a * 100 + b
+ EDGES[AB] = type
+ SPACES[a].exits.push(b)
+ SPACES[b].exits.push(a)
}
function major(a,b) { edge(a,b, "major"); }
@@ -232,286 +136,247 @@ const SPACE_XY = {
function strait(a,b) { edge(a,b, "strait"); }
function sea(a,b) { edge(a,b, "sea"); }
- major("Alexandria", "Catabathmus");
- major("Alexandria", "Memphis");
- major("Antiochia", "Damascus");
- major("Antiochia", "Tarsus");
- major("Athenae", "Thessalonica");
- major("Aenos", "Byzantium");
- major("Aenos", "Thessalonica");
- major("Ancyra", "Appia");
- major("Ancyra", "Eusebia");
- major("Ancyra", "Nicomedia");
- major("Appia", "Ephesus");
- major("Aquileia", "Ravenna");
- major("Aquileia", "Salona");
- major("Aquileia", "Sirmium");
- major("Asculum", "Ravenna");
- major("Badias", "Utica");
- major("Bilbilis", "Burdigala");
- major("Bilbilis", "Toletum");
- major("Brundisium", "Neapolis");
- major("Burdigala", "Narbo");
- major("Carthago Nova", "Corduba");
- major("Carthago Nova", "Tarraco");
- major("Catabathmus", "Cyrene");
- major("Cenabum", "Lugdunum");
- major("Corduba", "Gades");
- major("Corduba", "Toletum");
- major("Damascus", "Jerusalem");
- major("Dyrrachium", "Thessalonica");
- major("Eusebia", "Tarsus");
- major("Genua", "Massilia");
- major("Genua", "Roma");
- major("Genua", "Ravenna");
- major("Iomnium", "Utica");
- major("Jerusalem", "Pelusium");
- major("Lugdunum", "Massilia");
- major("Massilia", "Narbo");
- major("Memphis", "Pelusium");
- major("Narbo", "Tarraco");
- major("Neapolis", "Roma");
- major("Neapolis", "Rhegium");
- major("Serdica", "Sirmium");
- major("Serdica", "Thessalonica");
- major("Tacape", "Utica");
-
- minor("Alexandria", "Pelusium");
- minor("Athenae", "Ambracia");
- minor("Athenae", "Pylos");
- minor("Aenos", "Serdica");
- minor("Ambracia", "Dyrrachium");
- minor("Ancyra", "Sinope");
- minor("Appia", "Nicomedia");
- minor("Appia", "Perga");
- minor("Asculum", "Roma");
- minor("Asculum", "Sipontum");
- minor("Asturica", "Bilbilis");
- minor("Asturica", "Emerita");
- minor("Asturica", "Portus");
- minor("Asturica", "Toletum");
- minor("Badias", "Iomnium");
- minor("Badias", "Tacape");
- minor("Bilbilis", "Tarraco");
- minor("Brundisium", "Sipontum");
- minor("Burdigala", "Cenabum");
- minor("Carthago Nova", "Gades");
- minor("Carthago Nova", "Toletum");
- minor("Cenabum", "Treviri");
- minor("Cyrene", "Thubactus");
- minor("Dyrrachium", "Salona");
- minor("Ephesus", "Perga");
- minor("Ephesus", "Pergamum");
- minor("Emerita", "Gades");
- minor("Emerita", "Olisipo");
- minor("Eusebia", "Sinope");
- minor("Gades", "Olisipo");
- minor("Genua", "Lugdunum");
- minor("Iomnium", "Siga");
- minor("Lilybaeum", "Messana");
- minor("Lilybaeum", "Syracusae");
- minor("Lugdunum", "Treviri");
- minor("Messana", "Syracusae");
- minor("Neapolis", "Sipontum");
- minor("Nicomedia", "Pergamum");
- minor("Nicomedia", "Sinope");
- minor("Olisipo", "Portus");
- minor("Perga", "Tarsus");
- minor("Roma", "Ravenna");
- minor("Sala", "Siga");
- minor("Sala", "Tingis");
- minor("Salona", "Sirmium");
- minor("Siga", "Tingis");
- minor("Tacape", "Thubactus");
-
- strait("Aenos", "Pergamum");
- strait("Byzantium", "Nicomedia");
- strait("Gades", "Tingis");
- strait("Messana", "Rhegium");
-
- sea("Alexandria", "Mare Aegypticum");
- sea("Antiochia", "Mare Aegypticum");
- sea("Athenae", "Mare Aegaeum");
- sea("Aenos", "Mare Aegaeum");
- sea("Aleria", "Mare Tyrrhenum");
- sea("Ambracia", "Mare Internum");
- sea("Aquileia", "Mare Hadriaticum");
- sea("Byzantium", "Pontus Euxinus");
- sea("Byzantium", "Propontis");
- sea("Brundisium", "Mare Hadriaticum");
- sea("Brundisium", "Mare Internum");
- sea("Burdigala", "Oceanus Atlanticus");
- sea("Carthago Nova", "Mare Hispanum");
- sea("Caralis", "Mare Hispanum");
- sea("Caralis", "Mare Tyrrhenum");
- sea("Catabathmus", "Mare Aegypticum");
- sea("Creta", "Mare Aegaeum");
- sea("Creta", "Mare Aegypticum");
- sea("Creta", "Mare Internum");
- sea("Cyrene", "Mare Internum");
- sea("Dyrrachium", "Mare Hadriaticum");
- sea("Ephesus", "Mare Aegaeum");
- sea("Gades", "Oceanus Atlanticus");
- sea("Genua", "Mare Hispanum");
- sea("Genua", "Mare Tyrrhenum");
- sea("Iomnium", "Mare Hispanum");
- sea("Lilybaeum", "Mare Internum");
- sea("Lilybaeum", "Mare Tyrrhenum");
- sea("Massilia", "Mare Hispanum");
- sea("Mare Aegaeum", "Mare Aegypticum");
- sea("Mare Aegaeum", "Mare Internum");
- sea("Mare Aegaeum", "Propontis");
- sea("Mare Aegaeum", "Thessalonica");
- sea("Mare Aegypticum", "Mare Internum");
- sea("Mare Aegypticum", "Pelusium");
- sea("Mare Aegypticum", "Perga");
- sea("Mare Aegypticum", "Salamis");
- sea("Mare Aegypticum", "Tarsus");
- sea("Mare Hadriaticum", "Mare Internum");
- sea("Mare Hadriaticum", "Ravenna");
- sea("Mare Hadriaticum", "Salona");
- sea("Mare Hadriaticum", "Sipontum");
- sea("Mare Hispanum", "Mare Tyrrhenum");
- sea("Mare Hispanum", "Narbo");
- sea("Mare Hispanum", "Oceanus Atlanticus");
- sea("Mare Hispanum", "Siga");
- sea("Mare Hispanum", "Tarraco");
- sea("Mare Hispanum", "Tingis");
- sea("Mare Hispanum", "Utica");
- sea("Mare Internum", "Mare Tyrrhenum");
- sea("Mare Internum", "Messana");
- sea("Mare Internum", "Pylos");
- sea("Mare Internum", "Rhegium");
- sea("Mare Internum", "Syracusae");
- sea("Mare Internum", "Tacape");
- sea("Mare Internum", "Thubactus");
- sea("Mare Internum", "Utica");
- sea("Mare Tyrrhenum", "Messana");
- sea("Mare Tyrrhenum", "Neapolis");
- sea("Mare Tyrrhenum", "Roma");
- sea("Mare Tyrrhenum", "Rhegium");
- sea("Mare Tyrrhenum", "Utica");
- sea("Nicomedia", "Propontis");
- sea("Oceanus Atlanticus", "Olisipo");
- sea("Oceanus Atlanticus", "Portus");
- sea("Oceanus Atlanticus", "Sala");
- sea("Oceanus Atlanticus", "Tingis");
- sea("Pontus Euxinus", "Propontis");
- sea("Pontus Euxinus", "Sinope");
-
- let index = 0;
-
- function block(owner, CR, steps, type, name, levy) {
- let sid = name;
- let [initiative, firepower] = CR;
- if (type !== 'leader' && type !== 'cleopatra' && type !== 'legio')
- sid = owner[0] + " " + sid;
- let descr = name;
- if (type !== 'leader' && type !== 'cleopatra' && type !== 'legio')
- descr = owner[0] + ". " + descr;
- if (levy) {
- if (levy === "Carthago Nova")
- descr += " (C. Nova)";
- else
- descr += " (" + levy + ")";
- }
-
- let id = block_index[sid] = BLOCKS.length
- BLOCKS[id] = {
- owner: owner,
- sid: sid,
- name: name,
- steps: steps,
- initiative: initiative,
- firepower: firepower | 0,
- type: type,
- levy: space_index[levy],
- description: descr,
- label: index++,
- }
+ major("Alexandria", "Catabathmus")
+ major("Alexandria", "Memphis")
+ major("Antiochia", "Damascus")
+ major("Antiochia", "Tarsus")
+ major("Athenae", "Thessalonica")
+ major("Aenos", "Byzantium")
+ major("Aenos", "Thessalonica")
+ major("Ancyra", "Appia")
+ major("Ancyra", "Eusebia")
+ major("Ancyra", "Nicomedia")
+ major("Appia", "Ephesus")
+ major("Aquileia", "Ravenna")
+ major("Aquileia", "Salona")
+ major("Aquileia", "Sirmium")
+ major("Asculum", "Ravenna")
+ major("Badias", "Utica")
+ major("Bilbilis", "Burdigala")
+ major("Bilbilis", "Toletum")
+ major("Brundisium", "Neapolis")
+ major("Burdigala", "Narbo")
+ major("Carthago Nova", "Corduba")
+ major("Carthago Nova", "Tarraco")
+ major("Catabathmus", "Cyrene")
+ major("Cenabum", "Lugdunum")
+ major("Corduba", "Gades")
+ major("Corduba", "Toletum")
+ major("Damascus", "Jerusalem")
+ major("Dyrrachium", "Thessalonica")
+ major("Eusebia", "Tarsus")
+ major("Genua", "Massilia")
+ major("Genua", "Roma")
+ major("Genua", "Ravenna")
+ major("Iomnium", "Utica")
+ major("Jerusalem", "Pelusium")
+ major("Lugdunum", "Massilia")
+ major("Massilia", "Narbo")
+ major("Memphis", "Pelusium")
+ major("Narbo", "Tarraco")
+ major("Neapolis", "Roma")
+ major("Neapolis", "Rhegium")
+ major("Serdica", "Sirmium")
+ major("Serdica", "Thessalonica")
+ major("Tacape", "Utica")
+
+ minor("Alexandria", "Pelusium")
+ minor("Athenae", "Ambracia")
+ minor("Athenae", "Pylos")
+ minor("Aenos", "Serdica")
+ minor("Ambracia", "Dyrrachium")
+ minor("Ancyra", "Sinope")
+ minor("Appia", "Nicomedia")
+ minor("Appia", "Perga")
+ minor("Asculum", "Roma")
+ minor("Asculum", "Sipontum")
+ minor("Asturica", "Bilbilis")
+ minor("Asturica", "Emerita")
+ minor("Asturica", "Portus")
+ minor("Asturica", "Toletum")
+ minor("Badias", "Iomnium")
+ minor("Badias", "Tacape")
+ minor("Bilbilis", "Tarraco")
+ minor("Brundisium", "Sipontum")
+ minor("Burdigala", "Cenabum")
+ minor("Carthago Nova", "Gades")
+ minor("Carthago Nova", "Toletum")
+ minor("Cenabum", "Treviri")
+ minor("Cyrene", "Thubactus")
+ minor("Dyrrachium", "Salona")
+ minor("Ephesus", "Perga")
+ minor("Ephesus", "Pergamum")
+ minor("Emerita", "Gades")
+ minor("Emerita", "Olisipo")
+ minor("Eusebia", "Sinope")
+ minor("Gades", "Olisipo")
+ minor("Genua", "Lugdunum")
+ minor("Iomnium", "Siga")
+ minor("Lilybaeum", "Messana")
+ minor("Lilybaeum", "Syracusae")
+ minor("Lugdunum", "Treviri")
+ minor("Messana", "Syracusae")
+ minor("Neapolis", "Sipontum")
+ minor("Nicomedia", "Pergamum")
+ minor("Nicomedia", "Sinope")
+ minor("Olisipo", "Portus")
+ minor("Perga", "Tarsus")
+ minor("Roma", "Ravenna")
+ minor("Sala", "Siga")
+ minor("Sala", "Tingis")
+ minor("Salona", "Sirmium")
+ minor("Siga", "Tingis")
+ minor("Tacape", "Thubactus")
+
+ strait("Aenos", "Pergamum")
+ strait("Byzantium", "Nicomedia")
+ strait("Gades", "Tingis")
+ strait("Messana", "Rhegium")
+
+ sea("Alexandria", "Mare Aegypticum")
+ sea("Antiochia", "Mare Aegypticum")
+ sea("Athenae", "Mare Aegaeum")
+ sea("Aenos", "Mare Aegaeum")
+ sea("Aleria", "Mare Tyrrhenum")
+ sea("Ambracia", "Mare Internum")
+ sea("Aquileia", "Mare Hadriaticum")
+ sea("Byzantium", "Pontus Euxinus")
+ sea("Byzantium", "Propontis")
+ sea("Brundisium", "Mare Hadriaticum")
+ sea("Brundisium", "Mare Internum")
+ sea("Burdigala", "Oceanus Atlanticus")
+ sea("Carthago Nova", "Mare Hispanum")
+ sea("Caralis", "Mare Hispanum")
+ sea("Caralis", "Mare Tyrrhenum")
+ sea("Catabathmus", "Mare Aegypticum")
+ sea("Creta", "Mare Aegaeum")
+ sea("Creta", "Mare Aegypticum")
+ sea("Creta", "Mare Internum")
+ sea("Cyrene", "Mare Internum")
+ sea("Dyrrachium", "Mare Hadriaticum")
+ sea("Ephesus", "Mare Aegaeum")
+ sea("Gades", "Oceanus Atlanticus")
+ sea("Genua", "Mare Hispanum")
+ sea("Genua", "Mare Tyrrhenum")
+ sea("Iomnium", "Mare Hispanum")
+ sea("Lilybaeum", "Mare Internum")
+ sea("Lilybaeum", "Mare Tyrrhenum")
+ sea("Massilia", "Mare Hispanum")
+ sea("Mare Aegaeum", "Mare Aegypticum")
+ sea("Mare Aegaeum", "Mare Internum")
+ sea("Mare Aegaeum", "Propontis")
+ sea("Mare Aegaeum", "Thessalonica")
+ sea("Mare Aegypticum", "Mare Internum")
+ sea("Mare Aegypticum", "Pelusium")
+ sea("Mare Aegypticum", "Perga")
+ sea("Mare Aegypticum", "Salamis")
+ sea("Mare Aegypticum", "Tarsus")
+ sea("Mare Hadriaticum", "Mare Internum")
+ sea("Mare Hadriaticum", "Ravenna")
+ sea("Mare Hadriaticum", "Salona")
+ sea("Mare Hadriaticum", "Sipontum")
+ sea("Mare Hispanum", "Mare Tyrrhenum")
+ sea("Mare Hispanum", "Narbo")
+ sea("Mare Hispanum", "Oceanus Atlanticus")
+ sea("Mare Hispanum", "Siga")
+ sea("Mare Hispanum", "Tarraco")
+ sea("Mare Hispanum", "Tingis")
+ sea("Mare Hispanum", "Utica")
+ sea("Mare Internum", "Mare Tyrrhenum")
+ sea("Mare Internum", "Messana")
+ sea("Mare Internum", "Pylos")
+ sea("Mare Internum", "Rhegium")
+ sea("Mare Internum", "Syracusae")
+ sea("Mare Internum", "Tacape")
+ sea("Mare Internum", "Thubactus")
+ sea("Mare Internum", "Utica")
+ sea("Mare Tyrrhenum", "Messana")
+ sea("Mare Tyrrhenum", "Neapolis")
+ sea("Mare Tyrrhenum", "Roma")
+ sea("Mare Tyrrhenum", "Rhegium")
+ sea("Mare Tyrrhenum", "Utica")
+ sea("Nicomedia", "Propontis")
+ sea("Oceanus Atlanticus", "Olisipo")
+ sea("Oceanus Atlanticus", "Portus")
+ sea("Oceanus Atlanticus", "Sala")
+ sea("Oceanus Atlanticus", "Tingis")
+ sea("Pontus Euxinus", "Propontis")
+ sea("Pontus Euxinus", "Sinope")
+
+ function block(name, type, steps, initiative, firepower, levy = 0) {
+ if (levy)
+ levy = SPACES.findIndex(s=>s.name===levy)
+ BLOCKS.push({ name, type, steps, initiative, firepower, levy })
}
- function caesar(CR,S,T,N,L) { block(CAESAR, CR, S, T, N, L); }
- function pompeius(CR,S,T,N,L) { block(POMPEIUS, CR, S, T, N, L); }
-
- caesar("A3", 3, "leader", "Caesar");
- caesar("A2", 2, "leader", "Antonius");
- caesar("A2", 3, "leader", "Octavian");
-
- caesar("C2", 3, "legio", "Legio 7", "Tarraco");
- caesar("C3", 3, "legio", "Legio 8", "Tarraco");
- caesar("C2", 3, "legio", "Legio 9", "Carthago Nova");
- caesar("C4", 3, "legio", "Legio 10", "Corduba");
- caesar("C3", 3, "legio", "Legio 11", "Genua");
- caesar("C3", 3, "legio", "Legio 12", "Genua");
- caesar("C3", 3, "legio", "Legio 13", "Ravenna");
-
- caesar("C3", 3, "legio", "Legio 14", "Ravenna");
- caesar("C2", 3, "legio", "Legio 16", "Aquileia");
- caesar("C2", 4, "legio", "Legio 17", "Roma");
- caesar("C2", 4, "legio", "Legio 18", "Neapolis");
- caesar("C2", 4, "legio", "Legio 19", "Syracusae");
- caesar("C2", 4, "legio", "Legio 20", "Athenae");
- caesar("C3", 4, "legio", "Legio 21", "Ancyra");
-
- caesar("B2", 3, "equitatus", "Equitatus 1", "Lugdunum");
- caesar("B2", 2, "equitatus", "Equitatus 2", "Toletum");
- caesar("B3", 2, "equitatus", "Equitatus 3", "Byzantium");
- caesar("B3", 3, "equitatus", "Equitatus 4", "Antiochia");
-
- caesar("B1", 4, "auxilia-b", "Auxilia 1");
- caesar("B1", 4, "auxilia-b", "Auxilia 2");
- caesar("A1", 3, "auxilia-a", "Auxilia 3");
- caesar("A1", 3, "auxilia-a", "Auxilia 4");
-
- caesar("X4", 2, "ballista", "Ballista");
-
- caesar("D2", 2, "navis", "Navis 1");
- caesar("D2", 2, "navis", "Navis 2");
- caesar("D2", 2, "navis", "Navis 3");
- caesar("D3", 2, "navis", "Navis 4");
- caesar("D3", 2, "navis", "Navis 5");
-
- block(POMPEIUS, "C1", 4, "cleopatra", "Cleopatra");
-
- pompeius("B3", 3, "leader", "Pompeius");
- pompeius("A2", 3, "leader", "Scipio");
- pompeius("A2", 2, "leader", "Brutus");
-
- pompeius("C2", 4, "legio", "Legio 1", "Roma");
- pompeius("C2", 4, "legio", "Legio 2", "Carthago Nova");
- pompeius("C3", 3, "legio", "Legio 3", "Ravenna");
- pompeius("C2", 3, "legio", "Legio 4", "Carthago Nova");
- pompeius("C2", 3, "legio", "Legio 5", "Tarraco");
- pompeius("C2", 3, "legio", "Legio 6", "Tarraco");
- pompeius("C2", 3, "legio", "Legio 32", "Athenae");
-
- pompeius("C3", 3, "legio", "Legio 33", "Creta");
- pompeius("C3", 3, "legio", "Legio 34", "Antiochia");
- pompeius("C2", 3, "legio", "Legio 35", "Byzantium");
- pompeius("C2", 4, "legio", "Legio 36", "Ephesus");
- pompeius("C2", 3, "legio", "Legio 37", "Syracusae");
- pompeius("C2", 4, "legio", "Legio 38", "Alexandria");
- pompeius("C2", 3, "legio", "Legio 39", "Utica");
-
- pompeius("B3", 2, "equitatus", "Equitatus 1", "Toletum");
- pompeius("B2", 4, "equitatus", "Equitatus 2", "Badias");
- pompeius("B2", 3, "equitatus", "Equitatus 3", "Antiochia");
- pompeius("B3", 2, "elephant", "Elephant", "Utica");
-
- pompeius("B1", 4, "auxilia-b", "Auxilia 1");
- pompeius("B1", 4, "auxilia-b", "Auxilia 2");
- pompeius("A1", 3, "auxilia-a", "Auxilia 3");
- pompeius("A1", 3, "auxilia-a", "Auxilia 4");
-
- pompeius("X4", 2, "ballista", "Ballista");
-
- pompeius("D3", 2, "navis", "Navis 1");
- pompeius("D3", 2, "navis", "Navis 2");
- pompeius("D2", 2, "navis", "Navis 3");
- pompeius("D2", 2, "navis", "Navis 4");
- pompeius("D2", 2, "navis", "Navis 5");
-})();
+ block("Caesar", "leader", 3, "A", 3)
+ block("Antonius", "leader", 2, "A", 2)
+ block("Octavian", "leader", 3, "A", 2)
+ block("Legio 7", "legio", 3, "C", 2, "Tarraco")
+ block("Legio 8", "legio", 3, "C", 3, "Tarraco")
+ block("Legio 9", "legio", 3, "C", 2, "Carthago Nova")
+ block("Legio 10", "legio", 3, "C", 4, "Corduba")
+ block("Legio 11", "legio", 3, "C", 3, "Genua")
+ block("Legio 12", "legio", 3, "C", 3, "Genua")
+ block("Legio 13", "legio", 3, "C", 3, "Ravenna")
+ block("Legio 14", "legio", 3, "C", 3, "Ravenna")
+ block("Legio 16", "legio", 3, "C", 2, "Aquileia")
+ block("Legio 17", "legio", 4, "C", 2, "Roma")
+ block("Legio 18", "legio", 4, "C", 2, "Neapolis")
+ block("Legio 19", "legio", 4, "C", 2, "Syracusae")
+ block("Legio 20", "legio", 4, "C", 2, "Athenae")
+ block("Legio 21", "legio", 4, "C", 3, "Ancyra")
+ block("Equitatus 1", "equitatus", 3, "B", 2, "Lugdunum")
+ block("Equitatus 2", "equitatus", 2, "B", 2, "Toletum")
+ block("Equitatus 3", "equitatus", 2, "B", 3, "Byzantium")
+ block("Equitatus 4", "equitatus", 3, "B", 3, "Antiochia")
+ block("Auxilia 1", "auxilia-b", 4, "B", 1)
+ block("Auxilia 2", "auxilia-b", 4, "B", 1)
+ block("Auxilia 3", "auxilia-a", 3, "A", 1)
+ block("Auxilia 4", "auxilia-a", 3, "A", 1)
+ block("Ballista", "ballista", 2, "X", 4)
+ block("Navis 1", "navis", 2, "D", 2)
+ block("Navis 2", "navis", 2, "D", 2)
+ block("Navis 3", "navis", 2, "D", 2)
+ block("Navis 4", "navis", 2, "D", 3)
+ block("Navis 5", "navis", 2, "D", 3)
+
+ block("Cleopatra", "cleopatra", 4, "C", 1)
+
+ block("Pompeius", "leader", 3, "B", 3)
+ block("Scipio", "leader", 3, "A", 2)
+ block("Brutus", "leader", 2, "A", 2)
+ block("Legio 1", "legio", 4, "C", 2, "Roma")
+ block("Legio 2", "legio", 4, "C", 2, "Carthago Nova")
+ block("Legio 3", "legio", 3, "C", 3, "Ravenna")
+ block("Legio 4", "legio", 3, "C", 2, "Carthago Nova")
+ block("Legio 5", "legio", 3, "C", 2, "Tarraco")
+ block("Legio 6", "legio", 3, "C", 2, "Tarraco")
+ block("Legio 32", "legio", 3, "C", 2, "Athenae")
+ block("Legio 33", "legio", 3, "C", 3, "Creta")
+ block("Legio 34", "legio", 3, "C", 3, "Antiochia")
+ block("Legio 35", "legio", 3, "C", 2, "Byzantium")
+ block("Legio 36", "legio", 4, "C", 2, "Ephesus")
+ block("Legio 37", "legio", 3, "C", 2, "Syracusae")
+ block("Legio 38", "legio", 4, "C", 2, "Alexandria")
+ block("Legio 39", "legio", 3, "C", 2, "Utica")
+ block("Equitatus 1", "equitatus", 2, "B", 3, "Toletum")
+ block("Equitatus 2", "equitatus", 4, "B", 2, "Badias")
+ block("Equitatus 3", "equitatus", 3, "B", 2, "Antiochia")
+ block("Elephant", "elephant", 2, "B", 3, "Utica")
+ block("Auxilia 1", "auxilia-b", 4, "B", 1)
+ block("Auxilia 2", "auxilia-b", 4, "B", 1)
+ block("Auxilia 3", "auxilia-a", 3, "A", 1)
+ block("Auxilia 4", "auxilia-a", 3, "A", 1)
+ block("Ballista", "ballista", 2, "X", 4)
+ block("Navis 1", "navis", 2, "D", 3)
+ block("Navis 2", "navis", 2, "D", 3)
+ block("Navis 3", "navis", 2, "D", 2)
+ block("Navis 4", "navis", 2, "D", 2)
+ block("Navis 5", "navis", 2, "D", 2)
+}
+
+init_data()
if (typeof module !== 'undefined')
- module.exports = { CARDS, BLOCKS, SPACES, EDGES, block_index, space_index }
+ module.exports = { CARDS, BLOCKS, SPACES, EDGES }
diff --git a/play.css b/play.css
index 9bc5034..6492e90 100644
--- a/play.css
+++ b/play.css
@@ -16,7 +16,6 @@ header.your_turn { background-color: orange; }
#log { background-color: wheat; }
#log div { padding-left: 20px; text-indent: -12px; }
#log div.i { padding-left: 32px; text-indent: -12px; }
-#log div.i { font-style: italic; }
#log .h1 { background-color: brown; color: gold; font-weight: bold; }
#log .h2 { background-color: brown; color: gold; font-weight: bold; }
#log .C { background-color: salmon; }
diff --git a/play.js b/play.js
index 5aac58c..cdcf56f 100644
--- a/play.js
+++ b/play.js
@@ -16,11 +16,18 @@ function set_has(set, item) {
return false
}
-const DEAD = space_index["Dead"]
-const LEVY = space_index["Levy"]
+const CAESAR = "Caesar"
+const POMPEIUS = "Pompeius"
+
+const DEAD = 0
+const LEVY = 1
+const B_CLEOPATRA = 31
const ENEMY = { "Caesar": "Pompeius", "Pompeius": "Caesar" }
+for (let s of SPACES)
+ s.nbname = s.name.replace(/ /g, '\xa0')
+
const block_count = BLOCKS.length
const space_count = SPACES.length
@@ -101,18 +108,13 @@ function on_click_space_tip(x) {
function sub_space_name(match, p1, offset, string) {
let x = p1 | 0
- let n = SPACES[x].name
+ let n = SPACES[x].nbname
return `<span class="tip" onmouseenter="on_focus_space_tip(${x})" onmouseleave="on_blur_space_tip(${x})" onclick="on_click_space_tip(${x})">${n}</span>`
}
function on_log(text) {
let p = document.createElement("div")
- if (text.match(/^>>/)) {
- text = text.substring(2)
- p.className = "ii"
- }
-
if (text.match(/^>/)) {
text = text.substring(1)
p.className = "i"
@@ -123,7 +125,6 @@ function on_log(text) {
text = text.replace(/>/g, "&gt;")
text = text.replace(/\u2192 /g, "\u2192\xa0")
- text = text.replace(/Mare /g, "Mare\xa0")
text = text.replace(/^([A-Z]):/, '<span class="$1"> $1 </span>')
@@ -147,7 +148,7 @@ function on_log(text) {
}
function on_focus_space(evt) {
- document.getElementById("status").textContent = evt.target.space
+ document.getElementById("status").textContent = SPACES[evt.target.space].name
}
function on_blur_space(evt) {
@@ -172,8 +173,18 @@ function block_description(b) {
return block_owner(b)
}
+function block_color(who) {
+ if (who < B_CLEOPATRA)
+ return CAESAR
+ if (who > B_CLEOPATRA)
+ return POMPEIUS
+ return "Cleopatra"
+}
+
function block_original_owner(who) {
- return BLOCKS[who].owner
+ if (who >= B_CLEOPATRA)
+ return POMPEIUS
+ return CAESAR
}
function block_owner(who) {
@@ -252,7 +263,7 @@ function on_click_map_block(evt) {
let b = evt.target.block
let s = view.location[b]
if (view.actions && view.actions.secret && view.actions.secret.includes(s))
- send_action('secret', [s, BLOCKS[b].color])
+ send_action('secret', [s, block_color(b)])
else if (!view.battle)
send_action('block', b)
}
@@ -279,8 +290,8 @@ function build_map() {
element.addEventListener("mouseenter", on_focus_space)
element.addEventListener("mouseleave", on_blur_space)
element.addEventListener("click", on_click_space)
- element.style.left = (space.x - size/2) + "px"
- element.style.top = (space.y - size/2) + "px"
+ element.style.left = (space.layout.x - size/2) + "px"
+ element.style.top = (space.layout.y - size/2) + "px"
if (space.type !== 'pool')
document.getElementById("spaces").appendChild(element)
element.space = s
@@ -291,8 +302,8 @@ function build_map() {
let element = document.createElement("div")
element.classList.add("block")
element.classList.add("known")
- element.classList.add(block.color)
- element.classList.add("block_"+block.label)
+ element.classList.add(block_color(b))
+ element.classList.add("block_"+b)
element.addEventListener("mouseenter", on_focus_map_block)
element.addEventListener("mouseleave", on_blur_map_block)
element.addEventListener("click", on_click_map_block)
@@ -316,8 +327,8 @@ function build_map() {
function build_battle_block(b, block) {
let element = document.createElement("div")
element.classList.add("block")
- element.classList.add(block.color)
- element.classList.add("block_"+block.label)
+ element.classList.add(block_color(b))
+ element.classList.add("block_"+b)
element.addEventListener("mouseenter", on_focus_battle_block)
element.addEventListener("mouseleave", on_blur_battle_block)
element.addEventListener("click", on_click_battle_block)
@@ -350,7 +361,6 @@ function build_map() {
for (let b = 0; b < block_count; ++b) {
let block = BLOCKS[b]
- block.color = (block.name === "Cleopatra" ? "Cleopatra" : block.owner)
build_map_block(b, block)
build_battle_block(b, block)
}
@@ -390,7 +400,7 @@ function layout_blocks(location, north, south) {
}
function layout_blocks_spread(location, north, south) {
- let wrap = SPACES[location].wrap
+ let wrap = SPACES[location].layout.wrap
let s = north.length
let k = south.length
let n = s + k
@@ -422,7 +432,7 @@ function layout_blocks_spread(location, north, south) {
++i
}
- if (SPACES[location].layout_minor > 0.5)
+ if (SPACES[location].layout.minor > 0.5)
rows.reverse()
for (let j = 0; j < rows.length; ++j)
@@ -437,17 +447,17 @@ function position_block_spread(location, row, n_rows, col, n_cols, element) {
let offset = block_size + padding
let row_size = (n_rows-1) * offset
let col_size = (n_cols-1) * offset
- let x = space.x - block_size/2
- let y = space.y - block_size/2
+ let x = space.layout.x - block_size/2
+ let y = space.layout.y - block_size/2
- if (space.layout_axis === 'X') {
- x -= col_size * space.layout_major
- y -= row_size * space.layout_minor
+ if (space.layout.axis === 'X') {
+ x -= col_size * space.layout.major
+ y -= row_size * space.layout.minor
x += col * offset
y += row * offset
} else {
- y -= col_size * space.layout_major
- x -= row_size * space.layout_minor
+ y -= col_size * space.layout.major
+ x -= row_size * space.layout.minor
y += col * offset
x += row * offset
}
@@ -471,8 +481,8 @@ function layout_blocks_stacked(location, secret, known) {
function position_block_stacked(location, i, c, k, element) {
let space = SPACES[location]
let block_size = (label_style === 'columbia') ? 56+6 : 48+4
- let x = space.x + (i - c) * 16 + k * 12
- let y = space.y + (i - c) * 16 - k * 12
+ let x = space.layout.x + (i - c) * 16 + k * 12
+ let y = space.layout.y + (i - c) * 16 - k * 12
element.style.left = ((x - block_size/2)|0)+"px"
element.style.top = ((y - block_size/2)|0)+"px"
}
@@ -521,12 +531,12 @@ function update_map() {
if (space === DEAD && info.type !== 'leader')
moved = " moved"
if (is_known_block(b)) {
- let image = " block_" + info.label
+ let image = " block_" + b
let known = " known"
let jupiter = ""
if (set_has(view.traitor, b) && view.game_over)
jupiter = " jupiter"
- element.classList = info.color + known + " block" + image + moved + jupiter
+ element.classList = block_color(b) + known + " block" + image + moved + jupiter
update_steps(b, element, true)
} else {
let jupiter = ""
@@ -538,7 +548,7 @@ function update_map() {
mars = " mars"
if (block_owner(b) === view.neptune && space === view.surprise)
neptune = " neptune"
- element.classList = info.color + " block" + moved + jupiter + mars + neptune
+ element.classList = block_color(b) + " block" + moved + jupiter + mars + neptune
}
if (block_owner(b) === CAESAR)
layout[space].north.push(element)
@@ -590,8 +600,8 @@ function compare_blocks(a, b, ballista) {
if (aa === 'X') aa = ballista
if (bb === 'X') bb = ballista
if (aa === bb) {
- aa = BLOCKS[a].label
- bb = BLOCKS[b].label
+ aa = a
+ bb = b
}
return (aa < bb) ? -1 : (aa > bb) ? 1 : 0
}
diff --git a/rules.js b/rules.js
index 11614a2..140c131 100644
--- a/rules.js
+++ b/rules.js
@@ -11,9 +11,15 @@ exports.roles = [
"Pompeius",
]
-const {
- CARDS, SPACES, EDGES, BLOCKS, block_index, space_index,
-} = require('./data')
+const { CARDS, SPACES, EDGES, BLOCKS } = require('./data')
+
+function find_block(name) {
+ return BLOCKS.findIndex(b => b.name === name)
+}
+
+function find_space(name) {
+ return SPACES.findIndex(s => s.name === name)
+}
const block_count = BLOCKS.length
const space_count = SPACES.length
@@ -32,18 +38,18 @@ const BOTH = "Both"
const CAESAR = "Caesar"
const POMPEIUS = "Pompeius"
-const B_CAESAR = block_index["Caesar"]
-const B_POMPEIUS = block_index["Pompeius"]
-const B_CLEOPATRA = block_index["Cleopatra"]
-const B_OCTAVIAN = block_index["Octavian"]
-const B_BRUTUS = block_index["Brutus"]
-const B_ANTONIUS = block_index["Antonius"]
-const B_SCIPIO = block_index["Scipio"]
+const B_CAESAR = find_block("Caesar")
+const B_POMPEIUS = find_block("Pompeius")
+const B_CLEOPATRA = find_block("Cleopatra")
+const B_OCTAVIAN = find_block("Octavian")
+const B_BRUTUS = find_block("Brutus")
+const B_ANTONIUS = find_block("Antonius")
+const B_SCIPIO = find_block("Scipio")
-const ALEXANDRIA = space_index["Alexandria"]
-const ROMA = space_index["Roma"]
-const DEAD = space_index["Dead"]
-const LEVY = space_index["Levy"]
+const ALEXANDRIA = find_space("Alexandria")
+const ROMA = find_space("Roma")
+const DEAD = find_space("Dead")
+const LEVY = find_space("Levy")
// serif cirled numbers
const DIE_HIT = [ 0, '\u2776', '\u2777', '\u2778', '\u2779', '\u277A', '\u277B' ]
@@ -73,10 +79,6 @@ function logi(s) {
game.log.push(">" + s)
}
-function logii(s) {
- game.log.push(">>" + s)
-}
-
function log_battle(s) {
game.log.push(game.active[0] + ": " + s)
}
@@ -277,7 +279,9 @@ function move_to(who, from, to) {
}
function block_original_owner(who) {
- return BLOCKS[who].owner
+ if (who >= B_CLEOPATRA)
+ return POMPEIUS
+ return CAESAR
}
function block_owner(who) {
@@ -2681,9 +2685,9 @@ exports.setup = function (seed, scenario, options) {
function deploy_block(owner, location, name) {
for (let b = 0; b < block_count; ++b) {
- if (BLOCKS[b].owner === owner && BLOCKS[b].name === name) {
+ if (block_original_owner(b) === owner && BLOCKS[b].name === name) {
game.steps[b] = BLOCKS[b].steps
- game.location[b] = space_index[location]
+ game.location[b] = find_space(location)
return
}
}
@@ -2732,24 +2736,6 @@ exports.action = function (state, current, action, arg) {
game = state
let S = states[game.state]
if (action in S) {
- switch (action) {
- case 'block':
- case 'battle_fire':
- case 'battle_retreat':
- case 'battle_pass':
- case 'battle_hit':
- if (typeof arg === 'string')
- arg = block_index[arg]
- break
- case 'space':
- if (typeof arg === 'string')
- arg = space_index[arg]
- break
- case 'secret':
- if (typeof arg[0] === 'string')
- arg[0] = space_index[arg[0]]
- break
- }
S[action](arg, current)
} else {
throw new Error("Invalid action: " + action)