summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.js606
-rw-r--r--play.js548
2 files changed, 589 insertions, 565 deletions
diff --git a/data.js b/data.js
index ef4932d..7e5c8f4 100644
--- a/data.js
+++ b/data.js
@@ -1,346 +1,360 @@
-"use strict";
+"use strict"
let BOXES = {}
-let BLOCKADE = {};
-let COLONIES = {};
-let SPACES = {};
-let PATH_INDEX = {};
-let PATH_NAME;
-let PATH_TYPE;
+let BLOCKADE = {}
+let COLONIES = {}
+let SPACES = {}
+let PATH_INDEX = {}
+let PATH_NAME
+let PATH_TYPE
const GENERALS = {
- "Arnold": { owner: "American", strategy: 1, battle: 3, agility: 2, bonus: false },
- "Gates": { owner: "American", strategy: 2, battle: 2, agility: 1, bonus: false },
- "Greene": { owner: "American", strategy: 1, battle: 4, agility: 2, bonus: true },
- "Lafayette": { owner: "American", strategy: 1, battle: 2, agility: 1, bonus: false },
- "Lee": { owner: "American", strategy: 2, battle: 1, agility: 1, bonus: false },
- "Lincoln": { owner: "American", strategy: 2, battle: 1, agility: 1, bonus: false },
- "Washington": { owner: "American", strategy: 1, battle: 5, agility: 2, bonus: true },
+ Arnold: { owner: "American", strategy: 1, battle: 3, agility: 2, bonus: false },
+ Gates: { owner: "American", strategy: 2, battle: 2, agility: 1, bonus: false },
+ Greene: { owner: "American", strategy: 1, battle: 4, agility: 2, bonus: true },
+ Lafayette: { owner: "American", strategy: 1, battle: 2, agility: 1, bonus: false },
+ Lee: { owner: "American", strategy: 2, battle: 1, agility: 1, bonus: false },
+ Lincoln: { owner: "American", strategy: 2, battle: 1, agility: 1, bonus: false },
+ Washington: { owner: "American", strategy: 1, battle: 5, agility: 2, bonus: true },
- "Burgoyne": { owner: "British", strategy: 2, battle: 2, agility: 1, bonus: false },
- "Carleton": { owner: "British", strategy: 3, battle: 3, agility: 2, bonus: false },
- "Clinton": { owner: "British", strategy: 3, battle: 4, agility: 2, bonus: false },
- "Cornwallis": { owner: "British", strategy: 2, battle: 4, agility: 2, bonus: false },
- "Howe": { owner: "British", strategy: 3, battle: 6, agility: 3, bonus: false },
+ Burgoyne: { owner: "British", strategy: 2, battle: 2, agility: 1, bonus: false },
+ Carleton: { owner: "British", strategy: 3, battle: 3, agility: 2, bonus: false },
+ Clinton: { owner: "British", strategy: 3, battle: 4, agility: 2, bonus: false },
+ Cornwallis: { owner: "British", strategy: 2, battle: 4, agility: 2, bonus: false },
+ Howe: { owner: "British", strategy: 3, battle: 6, agility: 3, bonus: false },
- "Rochambeau": { owner: "French", strategy: 2, battle: 4, agility: 2, bonus: false },
-};
+ Rochambeau: { owner: "French", strategy: 2, battle: 4, agility: 2, bonus: false },
+}
function getEdge(A, B) {
if (A > B)
- return PATHS[B + "/" + A];
- return PATHS[A + "/" + B];
+ return PATHS[B + "/" + A]
+ return PATHS[A + "/" + B]
}
-(function() {
- let info = {};
+;(function () {
+ let info = {}
function box(category, A, x, y) {
- x += 40; y += 36;
- BOXES[A] = { name: A, category: category, x: x, y: y };
+ x += 40
+ y += 36
+ BOXES[A] = { name: A, category: category, x: x, y: y }
}
function space(colony, name, x, y, type) {
- x += 40; y += 36;
- if (type == 'winter-quarters') {
- x += 1; y += 1;
+ x += 40
+ y += 36
+ if (type == "winter-quarters") {
+ x += 1
+ y += 1
}
if (!(colony in COLONIES))
- COLONIES[colony] = [];
- COLONIES[colony].push(name);
- SPACES[name] = { name: name, colony: colony, type: type, port: false, x: x, y: y, exits: [] };
+ COLONIES[colony] = []
+ COLONIES[colony].push(name)
+ SPACES[name] = { name: name, colony: colony, type: type, port: false, x: x, y: y, exits: [] }
}
function line(A, B, type) {
if (A > B) {
- let C = B; B = A; A = C;
+ let C = B
+ B = A
+ A = C
}
- let id = A + "/" + B;
- SPACES[A].exits.push(B);
- SPACES[B].exits.push(A);
- info[id] = type;
- if (!(A in PATH_INDEX)) PATH_INDEX[A] = {}
- if (!(B in PATH_INDEX)) PATH_INDEX[B] = {}
- PATH_INDEX[A][B] = -1;
- PATH_INDEX[B][A] = -1;
+ let id = A + "/" + B
+ SPACES[A].exits.push(B)
+ SPACES[B].exits.push(A)
+ info[id] = type
+ if (!(A in PATH_INDEX))
+ PATH_INDEX[A] = {}
+ if (!(B in PATH_INDEX))
+ PATH_INDEX[B] = {}
+ PATH_INDEX[A][B] = -1
+ PATH_INDEX[B][A] = -1
}
- space("CA", "Fort Detroit", 55, 673, "regular-space");
- space("CA", "Montreal", 1000, 159, "fortified-port");
- space("CA", "Quebec", 1122, 57, "fortified-port");
- space("CT", "Hartford", 1183, 749, "winter-quarters");
- space("CT", "New Haven", 1088, 736, "regular-space");
- space("DE", "Wilmington DE", 885, 1079, "winter-quarters");
- space("GA", "Augusta", 140, 2060, "regular-space");
- space("GA", "Savannah", 227, 2271, "regular-space");
- space("GA", "St. Mary's", 180, 2394, "regular-space");
- space("MA", "Barnstable", 1394, 705, "regular-space");
- space("MA", "Boston", 1327, 592, "winter-quarters");
- space("MA", "Falmouth", 1334, 410, "regular-space");
- space("MA", "Lexington Concord", 1218, 628, "regular-space");
- space("MA", "Springfield", 1095, 624, "winter-quarters");
- space("MD", "Baltimore", 769, 1105, "winter-quarters");
- space("MD", "Fort Cumberland", 446, 1098, "regular-space");
- space("MD", "Frederick Town", 646, 1097, "regular-space");
- space("NC", "Charlotte", 215, 1653, "regular-space");
- space("NC", "Gilbert Town", 123, 1568, "regular-space");
- space("NC", "Hillsboro", 484, 1582, "regular-space");
- space("NC", "New Bern", 764, 1670, "regular-space");
- space("NC", "Salem", 308, 1561, "regular-space");
- space("NC", "Wake (Raleigh)", 606, 1671, "regular-space");
- space("NC", "Wilmington NC", 676, 1816, "regular-space");
- space("NH", "Brattleboro", 1102, 486, "regular-space");
- space("NH", "Concord", 1214, 460, "regular-space");
- space("NH", "Norwich", 1125, 342, "winter-quarters");
- space("NJ", "Monmouth", 998, 1074, "regular-space");
- space("NJ", "Morristown", 864, 831, "regular-space");
- space("NJ", "New Brunswick", 961, 942, "regular-space");
- space("NY", "Albany", 965, 626, "winter-quarters");
- space("NY", "Fort Niagara", 461, 526, "regular-space");
- space("NY", "Fort Stanwix", 877, 483, "winter-quarters");
- space("NY", "Genesee", 668, 582, "regular-space");
- space("NY", "Long Island", 1147, 868, "regular-space");
- space("NY", "New York", 1024, 838, "winter-quarters");
- space("NY", "Oswego", 768, 424, "regular-space");
- space("NY", "Saratoga", 992, 496, "regular-space");
- space("NY", "Ticonderoga", 993, 355, "winter-quarters");
- space("NY", "Westchester", 955, 747, "regular-space");
- space("PA", "Bassett Town", 147, 984, "regular-space");
- space("PA", "Harrisburg", 555, 880, "regular-space");
- space("PA", "Philadelphia", 846, 961, "fortified-port");
- space("PA", "Pittsburgh", 439, 958, "winter-quarters");
- space("PA", "Reading", 684, 900, "regular-space");
- space("PA", "Wyoming Valley", 685, 747, "winter-quarters");
- space("PA", "York", 589, 992, "regular-space");
- space("RI", "Newport", 1289, 736, "winter-quarters");
- space("SC", "Camden", 346, 1773, "regular-space");
- space("SC", "Charleston", 444, 2050, "fortified-port");
- space("SC", "Cheraw", 496, 1795, "regular-space");
- space("SC", "Eutaw Springs", 404, 1905, "regular-space");
- space("SC", "Fort Prince George", 74, 1773, "regular-space");
- space("SC", "Georgetown", 574, 1915, "regular-space");
- space("SC", "Ninety Six", 222, 1932, "regular-space");
- space("VA", "Abingdon", 61, 1451, "regular-space");
- space("VA", "Alexandria", 653, 1217, "winter-quarters");
- space("VA", "Charlottesville", 434, 1257, "winter-quarters");
- space("VA", "Fincastle", 349, 1402, "regular-space");
- space("VA", "Fort Chiswell", 212, 1408, "regular-space");
- space("VA", "Lynch's Ferry", 486, 1444, "regular-space");
- space("VA", "Norfolk", 781, 1450, "winter-quarters");
- space("VA", "Petersburg", 634, 1446, "regular-space");
- space("VA", "Point Pleasant", 132, 1218, "regular-space");
- space("VA", "Richmond", 608, 1323, "winter-quarters");
- space("VA", "Yorktown", 767, 1317, "regular-space");
+ space("CA", "Fort Detroit", 55, 673, "regular-space")
+ space("CA", "Montreal", 1000, 159, "fortified-port")
+ space("CA", "Quebec", 1122, 57, "fortified-port")
+ space("CT", "Hartford", 1183, 749, "winter-quarters")
+ space("CT", "New Haven", 1088, 736, "regular-space")
+ space("DE", "Wilmington DE", 885, 1079, "winter-quarters")
+ space("GA", "Augusta", 140, 2060, "regular-space")
+ space("GA", "Savannah", 227, 2271, "regular-space")
+ space("GA", "St. Mary's", 180, 2394, "regular-space")
+ space("MA", "Barnstable", 1394, 705, "regular-space")
+ space("MA", "Boston", 1327, 592, "winter-quarters")
+ space("MA", "Falmouth", 1334, 410, "regular-space")
+ space("MA", "Lexington Concord", 1218, 628, "regular-space")
+ space("MA", "Springfield", 1095, 624, "winter-quarters")
+ space("MD", "Baltimore", 769, 1105, "winter-quarters")
+ space("MD", "Fort Cumberland", 446, 1098, "regular-space")
+ space("MD", "Frederick Town", 646, 1097, "regular-space")
+ space("NC", "Charlotte", 215, 1653, "regular-space")
+ space("NC", "Gilbert Town", 123, 1568, "regular-space")
+ space("NC", "Hillsboro", 484, 1582, "regular-space")
+ space("NC", "New Bern", 764, 1670, "regular-space")
+ space("NC", "Salem", 308, 1561, "regular-space")
+ space("NC", "Wake (Raleigh)", 606, 1671, "regular-space")
+ space("NC", "Wilmington NC", 676, 1816, "regular-space")
+ space("NH", "Brattleboro", 1102, 486, "regular-space")
+ space("NH", "Concord", 1214, 460, "regular-space")
+ space("NH", "Norwich", 1125, 342, "winter-quarters")
+ space("NJ", "Monmouth", 998, 1074, "regular-space")
+ space("NJ", "Morristown", 864, 831, "regular-space")
+ space("NJ", "New Brunswick", 961, 942, "regular-space")
+ space("NY", "Albany", 965, 626, "winter-quarters")
+ space("NY", "Fort Niagara", 461, 526, "regular-space")
+ space("NY", "Fort Stanwix", 877, 483, "winter-quarters")
+ space("NY", "Genesee", 668, 582, "regular-space")
+ space("NY", "Long Island", 1147, 868, "regular-space")
+ space("NY", "New York", 1024, 838, "winter-quarters")
+ space("NY", "Oswego", 768, 424, "regular-space")
+ space("NY", "Saratoga", 992, 496, "regular-space")
+ space("NY", "Ticonderoga", 993, 355, "winter-quarters")
+ space("NY", "Westchester", 955, 747, "regular-space")
+ space("PA", "Bassett Town", 147, 984, "regular-space")
+ space("PA", "Harrisburg", 555, 880, "regular-space")
+ space("PA", "Philadelphia", 846, 961, "fortified-port")
+ space("PA", "Pittsburgh", 439, 958, "winter-quarters")
+ space("PA", "Reading", 684, 900, "regular-space")
+ space("PA", "Wyoming Valley", 685, 747, "winter-quarters")
+ space("PA", "York", 589, 992, "regular-space")
+ space("RI", "Newport", 1289, 736, "winter-quarters")
+ space("SC", "Camden", 346, 1773, "regular-space")
+ space("SC", "Charleston", 444, 2050, "fortified-port")
+ space("SC", "Cheraw", 496, 1795, "regular-space")
+ space("SC", "Eutaw Springs", 404, 1905, "regular-space")
+ space("SC", "Fort Prince George", 74, 1773, "regular-space")
+ space("SC", "Georgetown", 574, 1915, "regular-space")
+ space("SC", "Ninety Six", 222, 1932, "regular-space")
+ space("VA", "Abingdon", 61, 1451, "regular-space")
+ space("VA", "Alexandria", 653, 1217, "winter-quarters")
+ space("VA", "Charlottesville", 434, 1257, "winter-quarters")
+ space("VA", "Fincastle", 349, 1402, "regular-space")
+ space("VA", "Fort Chiswell", 212, 1408, "regular-space")
+ space("VA", "Lynch's Ferry", 486, 1444, "regular-space")
+ space("VA", "Norfolk", 781, 1450, "winter-quarters")
+ space("VA", "Petersburg", 634, 1446, "regular-space")
+ space("VA", "Point Pleasant", 132, 1218, "regular-space")
+ space("VA", "Richmond", 608, 1323, "winter-quarters")
+ space("VA", "Yorktown", 767, 1317, "regular-space")
- box("SEA", "Sea1", 1277, 65, "blockade");
- box("SEA", "Sea2", 1469, 514, "blockade");
- box("SEA", "Sea3", 1213, 981, "blockade");
- box("SEA", "Sea4", 1058, 1174, "blockade");
- box("SEA", "Sea5", 947, 1395, "blockade");
- box("SEA", "Sea6", 637, 2027, "blockade");
- box("SEA", "Sea7", 359, 2358, "blockade");
+ box("SEA", "Sea1", 1277, 65, "blockade")
+ box("SEA", "Sea2", 1469, 514, "blockade")
+ box("SEA", "Sea3", 1213, 981, "blockade")
+ box("SEA", "Sea4", 1058, 1174, "blockade")
+ box("SEA", "Sea5", 947, 1395, "blockade")
+ box("SEA", "Sea6", 637, 2027, "blockade")
+ box("SEA", "Sea7", 359, 2358, "blockade")
- box("HOLDING", "Continental Congress Dispersed", 545, 350);
- box("HOLDING", "Captured Generals", 1463, 80);
- box("HOLDING", "British Leader Reinforcements", 1425, 1745);
- box("HOLDING", "American Leader Reinforcements", 400, 310);
- box("HOLDING", "French Reinforcements", 150, 340);
+ box("HOLDING", "Continental Congress Dispersed", 545, 350)
+ box("HOLDING", "Captured Generals", 1463, 80)
+ box("HOLDING", "British Leader Reinforcements", 1425, 1745)
+ box("HOLDING", "American Leader Reinforcements", 400, 310)
+ box("HOLDING", "French Reinforcements", 150, 340)
- box("ALLIANCE", "French Alliance Track 0", 898, 2240);
- box("ALLIANCE", "French Alliance Track 1", 964, 2240);
- box("ALLIANCE", "French Alliance Track 2", 1030, 2240);
- box("ALLIANCE", "French Alliance Track 3", 1096, 2240);
- box("ALLIANCE", "French Alliance Track 4", 1162, 2240);
- box("ALLIANCE", "French Alliance Track 5", 1228, 2240);
- box("ALLIANCE", "French Alliance Track 6", 1294, 2240);
- box("ALLIANCE", "French Alliance Track 7", 1360, 2240);
- box("ALLIANCE", "French Alliance Track 8", 1426, 2240);
- box("ALLIANCE", "French Alliance Track 9", 1492, 2240);
+ box("ALLIANCE", "French Alliance Track 0", 898, 2240)
+ box("ALLIANCE", "French Alliance Track 1", 964, 2240)
+ box("ALLIANCE", "French Alliance Track 2", 1030, 2240)
+ box("ALLIANCE", "French Alliance Track 3", 1096, 2240)
+ box("ALLIANCE", "French Alliance Track 4", 1162, 2240)
+ box("ALLIANCE", "French Alliance Track 5", 1228, 2240)
+ box("ALLIANCE", "French Alliance Track 6", 1294, 2240)
+ box("ALLIANCE", "French Alliance Track 7", 1360, 2240)
+ box("ALLIANCE", "French Alliance Track 8", 1426, 2240)
+ box("ALLIANCE", "French Alliance Track 9", 1492, 2240)
- box("TURN", "Game Turn 1775", 898, 2370);
- box("TURN", "Game Turn 1776", 964, 2370);
- box("TURN", "Game Turn 1777", 1030, 2370);
- box("TURN", "Game Turn 1778", 1096, 2370);
- box("TURN", "Game Turn 1779", 1162, 2370);
- box("TURN", "Game Turn 1780", 1228, 2370);
- box("TURN", "Game Turn 1781", 1294, 2370);
- box("TURN", "Game Turn 1782", 1360, 2370);
- box("TURN", "Game Turn 1783", 1426, 2370);
+ box("TURN", "Game Turn 1775", 898, 2370)
+ box("TURN", "Game Turn 1776", 964, 2370)
+ box("TURN", "Game Turn 1777", 1030, 2370)
+ box("TURN", "Game Turn 1778", 1096, 2370)
+ box("TURN", "Game Turn 1779", 1162, 2370)
+ box("TURN", "Game Turn 1780", 1228, 2370)
+ box("TURN", "Game Turn 1781", 1294, 2370)
+ box("TURN", "Game Turn 1782", 1360, 2370)
+ box("TURN", "Game Turn 1783", 1426, 2370)
- box("CONTROL", "CA", 1376, 967);
- box("CONTROL", "NH", 1458, 1006);
- box("CONTROL", "NY", 1375, 1081);
- box("CONTROL", "MA", 1491, 1081);
- box("CONTROL", "CT", 1455, 1156);
- box("CONTROL", "RI", 1533, 1156);
- box("CONTROL", "PA", 1299, 1194);
- box("CONTROL", "NJ", 1376, 1189);
- box("CONTROL", "MD", 1299, 1266);
- box("CONTROL", "DE", 1376, 1266);
- box("CONTROL", "VA", 1241, 1337);
- box("CONTROL", "NC", 1260, 1407);
- box("CONTROL", "SC", 1212, 1479);
- box("CONTROL", "GA", 1164, 1550);
+ box("CONTROL", "CA", 1376, 967)
+ box("CONTROL", "NH", 1458, 1006)
+ box("CONTROL", "NY", 1375, 1081)
+ box("CONTROL", "MA", 1491, 1081)
+ box("CONTROL", "CT", 1455, 1156)
+ box("CONTROL", "RI", 1533, 1156)
+ box("CONTROL", "PA", 1299, 1194)
+ box("CONTROL", "NJ", 1376, 1189)
+ box("CONTROL", "MD", 1299, 1266)
+ box("CONTROL", "DE", 1376, 1266)
+ box("CONTROL", "VA", 1241, 1337)
+ box("CONTROL", "NC", 1260, 1407)
+ box("CONTROL", "SC", 1212, 1479)
+ box("CONTROL", "GA", 1164, 1550)
- function wilderness(A,B) { line(A,B, "wilderness"); }
- function path(A,B) { line(A,B, "path"); }
- function sea(space,zone) { SPACES[space].port = true; BLOCKADE[space] = zone; }
+ function wilderness(A, B) {
+ line(A, B, "wilderness")
+ }
+ function path(A, B) {
+ line(A, B, "path")
+ }
+ function sea(space, zone) {
+ SPACES[space].port = true
+ BLOCKADE[space] = zone
+ }
- wilderness("Quebec", "Falmouth");
- wilderness("Fort Detroit", "Bassett Town");
- wilderness("Bassett Town", "Point Pleasant");
+ wilderness("Quebec", "Falmouth")
+ wilderness("Fort Detroit", "Bassett Town")
+ wilderness("Bassett Town", "Point Pleasant")
- path("Quebec", "Montreal");
- path("Montreal", "Ticonderoga");
- path("Montreal", "Oswego");
- path("Oswego", "Fort Niagara");
- path("Oswego", "Fort Stanwix");
- path("Fort Niagara", "Fort Detroit");
- path("Fort Niagara", "Genesee");
- path("Ticonderoga", "Norwich");
- path("Ticonderoga", "Saratoga");
- path("Norwich", "Brattleboro");
- path("Norwich", "Concord");
- path("Concord", "Falmouth");
- path("Concord", "Brattleboro");
- path("Saratoga", "Brattleboro");
- path("Saratoga", "Albany");
- path("Brattleboro", "Springfield");
- path("Fort Stanwix", "Albany");
- path("Albany", "Springfield");
- path("Lexington Concord", "Springfield");
- path("Lexington Concord", "Boston");
- path("Falmouth", "Boston");
- path("Barnstable", "Boston");
- path("Newport", "Boston");
- path("Newport", "Hartford");
- path("Springfield", "Hartford");
- path("New Haven", "Hartford");
- path("New Haven", "New York");
- path("New Haven", "Westchester");
- path("New York", "Westchester");
- path("New York", "Long Island");
- path("Newport", "Lexington Concord");
- path("Albany", "Westchester");
- path("Fort Stanwix", "Genesee");
- path("Genesee", "Wyoming Valley");
- path("Fort Niagara", "Pittsburgh");
- path("Morristown", "Westchester");
- path("Morristown", "Wyoming Valley");
- path("Morristown", "Reading");
- path("Morristown", "New Brunswick");
- path("Morristown", "New York");
- path("New York", "New Brunswick");
- path("Monmouth", "New Brunswick");
- path("Philadelphia", "New Brunswick");
- path("Monmouth", "Philadelphia");
- path("Reading", "Philadelphia");
- path("Wyoming Valley", "Reading");
- path("Wilmington DE", "Philadelphia");
- path("Wilmington DE", "Baltimore");
- path("Bassett Town", "Pittsburgh");
- path("Fort Cumberland", "Pittsburgh");
- path("Harrisburg", "Pittsburgh");
- path("Harrisburg", "York");
- path("Reading", "York");
- path("Harrisburg", "Reading");
- path("Frederick Town", "York");
- path("Frederick Town", "Baltimore");
- path("Frederick Town", "Alexandria");
- path("Frederick Town", "Charlottesville");
- path("Frederick Town", "Fort Cumberland");
- path("Richmond", "Alexandria");
- path("Richmond", "Yorktown");
- path("Richmond", "Petersburg");
- path("Richmond", "Lynch's Ferry");
- path("Richmond", "Charlottesville");
- path("Richmond", "Norfolk");
- path("Fincastle", "Charlottesville");
- path("Fincastle", "Lynch's Ferry");
- path("Fincastle", "Fort Chiswell");
- path("Point Pleasant", "Fort Chiswell");
- path("Abingdon", "Fort Chiswell");
- path("Abingdon", "Gilbert Town");
- path("Fort Prince George", "Gilbert Town");
- path("Charlotte", "Gilbert Town");
- path("Charlotte", "Salem");
- path("Hillsboro", "Salem");
- path("Cheraw", "Salem");
- path("Lynch's Ferry", "Salem");
- path("Charlotte", "Camden");
- path("Abingdon", "Fort Prince George");
- path("New Bern", "Norfolk");
- path("Petersburg", "Norfolk");
- path("Petersburg", "Wake (Raleigh)");
- path("New Bern", "Wake (Raleigh)");
- path("Hillsboro", "Wake (Raleigh)");
- path("Petersburg", "Hillsboro");
- path("Petersburg", "Lynch's Ferry");
- path("Wilmington NC", "Wake (Raleigh)");
- path("Wilmington NC", "Cheraw");
- path("Wilmington NC", "Georgetown");
- path("Cheraw", "Georgetown");
- path("Cheraw", "Camden");
- path("Ninety Six", "Fort Prince George");
- path("Ninety Six", "Camden");
- path("Ninety Six", "Augusta");
- path("Eutaw Springs", "Camden");
- path("Eutaw Springs", "Charleston");
- path("Georgetown", "Charleston");
- path("Savannah", "Charleston");
- path("Alexandria", "Baltimore");
- path("Savannah", "Augusta");
- path("Savannah", "St. Mary's");
- path("Charlottesville", "Lynch's Ferry");
+ path("Quebec", "Montreal")
+ path("Montreal", "Ticonderoga")
+ path("Montreal", "Oswego")
+ path("Oswego", "Fort Niagara")
+ path("Oswego", "Fort Stanwix")
+ path("Fort Niagara", "Fort Detroit")
+ path("Fort Niagara", "Genesee")
+ path("Ticonderoga", "Norwich")
+ path("Ticonderoga", "Saratoga")
+ path("Norwich", "Brattleboro")
+ path("Norwich", "Concord")
+ path("Concord", "Falmouth")
+ path("Concord", "Brattleboro")
+ path("Saratoga", "Brattleboro")
+ path("Saratoga", "Albany")
+ path("Brattleboro", "Springfield")
+ path("Fort Stanwix", "Albany")
+ path("Albany", "Springfield")
+ path("Lexington Concord", "Springfield")
+ path("Lexington Concord", "Boston")
+ path("Falmouth", "Boston")
+ path("Barnstable", "Boston")
+ path("Newport", "Boston")
+ path("Newport", "Hartford")
+ path("Springfield", "Hartford")
+ path("New Haven", "Hartford")
+ path("New Haven", "New York")
+ path("New Haven", "Westchester")
+ path("New York", "Westchester")
+ path("New York", "Long Island")
+ path("Newport", "Lexington Concord")
+ path("Albany", "Westchester")
+ path("Fort Stanwix", "Genesee")
+ path("Genesee", "Wyoming Valley")
+ path("Fort Niagara", "Pittsburgh")
+ path("Morristown", "Westchester")
+ path("Morristown", "Wyoming Valley")
+ path("Morristown", "Reading")
+ path("Morristown", "New Brunswick")
+ path("Morristown", "New York")
+ path("New York", "New Brunswick")
+ path("Monmouth", "New Brunswick")
+ path("Philadelphia", "New Brunswick")
+ path("Monmouth", "Philadelphia")
+ path("Reading", "Philadelphia")
+ path("Wyoming Valley", "Reading")
+ path("Wilmington DE", "Philadelphia")
+ path("Wilmington DE", "Baltimore")
+ path("Bassett Town", "Pittsburgh")
+ path("Fort Cumberland", "Pittsburgh")
+ path("Harrisburg", "Pittsburgh")
+ path("Harrisburg", "York")
+ path("Reading", "York")
+ path("Harrisburg", "Reading")
+ path("Frederick Town", "York")
+ path("Frederick Town", "Baltimore")
+ path("Frederick Town", "Alexandria")
+ path("Frederick Town", "Charlottesville")
+ path("Frederick Town", "Fort Cumberland")
+ path("Richmond", "Alexandria")
+ path("Richmond", "Yorktown")
+ path("Richmond", "Petersburg")
+ path("Richmond", "Lynch's Ferry")
+ path("Richmond", "Charlottesville")
+ path("Richmond", "Norfolk")
+ path("Fincastle", "Charlottesville")
+ path("Fincastle", "Lynch's Ferry")
+ path("Fincastle", "Fort Chiswell")
+ path("Point Pleasant", "Fort Chiswell")
+ path("Abingdon", "Fort Chiswell")
+ path("Abingdon", "Gilbert Town")
+ path("Fort Prince George", "Gilbert Town")
+ path("Charlotte", "Gilbert Town")
+ path("Charlotte", "Salem")
+ path("Hillsboro", "Salem")
+ path("Cheraw", "Salem")
+ path("Lynch's Ferry", "Salem")
+ path("Charlotte", "Camden")
+ path("Abingdon", "Fort Prince George")
+ path("New Bern", "Norfolk")
+ path("Petersburg", "Norfolk")
+ path("Petersburg", "Wake (Raleigh)")
+ path("New Bern", "Wake (Raleigh)")
+ path("Hillsboro", "Wake (Raleigh)")
+ path("Petersburg", "Hillsboro")
+ path("Petersburg", "Lynch's Ferry")
+ path("Wilmington NC", "Wake (Raleigh)")
+ path("Wilmington NC", "Cheraw")
+ path("Wilmington NC", "Georgetown")
+ path("Cheraw", "Georgetown")
+ path("Cheraw", "Camden")
+ path("Ninety Six", "Fort Prince George")
+ path("Ninety Six", "Camden")
+ path("Ninety Six", "Augusta")
+ path("Eutaw Springs", "Camden")
+ path("Eutaw Springs", "Charleston")
+ path("Georgetown", "Charleston")
+ path("Savannah", "Charleston")
+ path("Alexandria", "Baltimore")
+ path("Savannah", "Augusta")
+ path("Savannah", "St. Mary's")
+ path("Charlottesville", "Lynch's Ferry")
- sea("Quebec", "Sea1");
- sea("Montreal", "Sea1");
+ sea("Quebec", "Sea1")
+ sea("Montreal", "Sea1")
- sea("Falmouth", "Sea2");
- sea("Boston", "Sea2");
- sea("Barnstable", "Sea2");
- sea("Newport", "Sea2");
+ sea("Falmouth", "Sea2")
+ sea("Boston", "Sea2")
+ sea("Barnstable", "Sea2")
+ sea("Newport", "Sea2")
- sea("New Haven", "Sea3");
- sea("New York", "Sea3");
- sea("Long Island", "Sea3");
+ sea("New Haven", "Sea3")
+ sea("New York", "Sea3")
+ sea("Long Island", "Sea3")
- sea("Philadelphia", "Sea4");
- sea("Wilmington DE", "Sea4");
+ sea("Philadelphia", "Sea4")
+ sea("Wilmington DE", "Sea4")
- sea("Baltimore", "Sea5");
- sea("Alexandria", "Sea5");
- sea("Yorktown", "Sea5");
- sea("Norfolk", "Sea5");
+ sea("Baltimore", "Sea5")
+ sea("Alexandria", "Sea5")
+ sea("Yorktown", "Sea5")
+ sea("Norfolk", "Sea5")
- sea("New Bern", "Sea6");
- sea("Wilmington NC", "Sea6");
- sea("Charleston", "Sea6");
+ sea("New Bern", "Sea6")
+ sea("Wilmington NC", "Sea6")
+ sea("Charleston", "Sea6")
- sea("Savannah", "Sea7");
- sea("St. Mary's", "Sea7");
+ sea("Savannah", "Sea7")
+ sea("St. Mary's", "Sea7")
- PATH_NAME = Object.keys(info).sort();
- PATH_TYPE = [];
+ PATH_NAME = Object.keys(info).sort()
+ PATH_TYPE = []
for (let id of PATH_NAME)
- PATH_TYPE.push(info[id]);
+ PATH_TYPE.push(info[id])
for (let a in PATH_INDEX) {
for (let b in PATH_INDEX[a]) {
- let id = a < b ? a + '/' + b : b + '/' + a;
- PATH_INDEX[a][b] = PATH_NAME.indexOf(id);
+ let id = a < b ? a + "/" + b : b + "/" + a
+ PATH_INDEX[a][b] = PATH_NAME.indexOf(id)
}
}
-})();
+})()
-if (typeof module == 'object') {
+if (typeof module == "object") {
module.exports = {
- GENERALS:GENERALS,
- BOXES:BOXES,
- COLONIES:COLONIES,
- SPACES:SPACES,
- PATH_NAME:PATH_NAME,
- PATH_TYPE:PATH_TYPE,
- PATH_INDEX:PATH_INDEX,
- BLOCKADE
+ GENERALS: GENERALS,
+ BOXES: BOXES,
+ COLONIES: COLONIES,
+ SPACES: SPACES,
+ PATH_NAME: PATH_NAME,
+ PATH_TYPE: PATH_TYPE,
+ PATH_INDEX: PATH_INDEX,
+ BLOCKADE,
}
}
diff --git a/play.js b/play.js
index f07bbb4..e7a684d 100644
--- a/play.js
+++ b/play.js
@@ -1,12 +1,12 @@
-"use strict";
+"use strict"
-const THE_13_COLONIES = [ 'NH', 'NY', 'MA', 'CT', 'RI', 'PA', 'NJ', 'MD', 'DE', 'VA', 'NC', 'SC', 'GA' ];
-const ALL_COLONIES = THE_13_COLONIES.concat(['CA']);
-const AMERICAN_GENERALS = [ "Arnold", "Gates", "Greene", "Lafayette", "Lee", "Lincoln", "Washington", ];
-const CONTINENTAL_CONGRESS_DISPERSED = "Continental Congress Dispersed";
-const BRITISH = "British";
-const AMERICAN = "American";
-const BLOCKADE_ZONES = [ "Sea1","Sea2","Sea3","Sea4","Sea5","Sea6","Sea7" ];
+const THE_13_COLONIES = [ "NH", "NY", "MA", "CT", "RI", "PA", "NJ", "MD", "DE", "VA", "NC", "SC", "GA" ]
+const ALL_COLONIES = THE_13_COLONIES.concat([ "CA" ])
+const AMERICAN_GENERALS = [ "Arnold", "Gates", "Greene", "Lafayette", "Lee", "Lincoln", "Washington" ]
+const CONTINENTAL_CONGRESS_DISPERSED = "Continental Congress Dispersed"
+const BRITISH = "British"
+const AMERICAN = "American"
+const BLOCKADE_ZONES = [ "Sea1", "Sea2", "Sea3", "Sea4", "Sea5", "Sea6", "Sea7" ]
let ui = {
cards: {},
@@ -15,277 +15,288 @@ let ui = {
control: {},
blockade: {},
cu: [],
-};
+}
function on_log(text) {
- let p = document.createElement("div");
- text = text.replace(/&/g, "&amp;");
- text = text.replace(/</g, "&lt;");
- text = text.replace(/>/g, "&gt;");
+ let p = document.createElement("div")
+ text = text.replace(/&/g, "&amp;")
+ text = text.replace(/</g, "&lt;")
+ text = text.replace(/>/g, "&gt;")
- text = text.replace(/\[(\d+)([^\]]*)\]/, '<span class="card_tip" data-card="$1">$1$2</span>');
+ text = text.replace(/\[(\d+)([^\]]*)\]/, '<span class="card_tip" data-card="$1">$1$2</span>')
if (text.match(/^\.h1 /)) {
- p.className = 'h1';
- text = text.substring(4);
+ p.className = "h1"
+ text = text.substring(4)
} else if (text.match(/^\.h2.american /)) {
- p.className = 'h2 american';
- text = text.substring(13);
+ p.className = "h2 american"
+ text = text.substring(13)
} else if (text.match(/^\.h2.british /)) {
- p.className = 'h2 british';
- text = text.substring(12);
+ p.className = "h2 british"
+ text = text.substring(12)
}
- p.innerHTML = text;
- return p;
+ p.innerHTML = text
+ return p
}
function clearList(container) {
while (container.firstChild)
- container.removeChild(container.firstChild);
+ container.removeChild(container.firstChild)
}
function onHoverCard(X) {
- let c = CARDS[X.id.split("+")[1]];
- document.getElementById("status").textContent = JSON.stringify(c);
+ let c = CARDS[X.id.split("+")[1]]
+ document.getElementById("status").textContent = JSON.stringify(c)
}
function onFocusNode(evt) {
- let space = SPACES[evt.target.id];
- document.getElementById("status").textContent = space.name;
+ let space = SPACES[evt.target.id]
+ document.getElementById("status").textContent = space.name
}
function onBlurNode(evt) {
- let space = SPACES[evt.target.id];
- document.getElementById("status").textContent = "";
+ let space = SPACES[evt.target.id]
+ document.getElementById("status").textContent = ""
}
function clear_group(name) {
- let container = document.getElementById(name);
+ let container = document.getElementById(name)
while (container.firstChild)
- container.removeChild(container.firstChild);
+ container.removeChild(container.firstChild)
}
function build_marker(container, id, x, y, w, h, classList) {
- let e = document.createElement("div");
- e.foo = { w:w, h:h };
- e.classList.add("marker");
+ let e = document.createElement("div")
+ e.foo = { w: w, h: h }
+ e.classList.add("marker")
for (let c of classList)
- e.classList.add(c);
- e.setAttribute("id", id);
- e.style.left = ((x - w/2)|0) + "px";
- e.style.top = ((y - h/2)|0) + "px";
- document.getElementById(container).appendChild(e);
- return e;
+ e.classList.add(c)
+ e.setAttribute("id", id)
+ e.style.left = ((x - w / 2) | 0) + "px"
+ e.style.top = ((y - h / 2) | 0) + "px"
+ document.getElementById(container).appendChild(e)
+ return e
}
function update_marker(e, space) {
- let box = SPACES[space] || BOXES[space];
- e.style.left = ((box.x - e.foo.w/2)|0) + "px";
- e.style.top = ((box.y - e.foo.h/2)|0) + "px";
+ let box = SPACES[space] || BOXES[space]
+ e.style.left = ((box.x - e.foo.w / 2) | 0) + "px"
+ e.style.top = ((box.y - e.foo.h / 2) | 0) + "px"
}
function update_marker_xy(e, x, y) {
- e.style.left = ((x - e.foo.w/2)|0) + "px";
- e.style.top = ((y - e.foo.h/2)|0) + "px";
+ e.style.left = ((x - e.foo.w / 2) | 0) + "px"
+ e.style.top = ((y - e.foo.h / 2) | 0) + "px"
}
function build_map() {
function buildNode(type, x, y, colony) {
- let e = document.createElement("div");
- let w, h;
- e.classList.add("space");
- e.classList.add(type);
- if (colony && colony != 'SEA')
- e.classList.add("colony_" + colony);
- if (type === 'regular-space') {
- w = 66;
- h = 66;
- } else if (type === 'winter-quarters') {
- w = 66;
- h = 66;
- } else if (type === 'fortified-port') {
- w = 54;
- h = 54;
- } else if (type === 'blockade') {
- w = 96;
- h = 80;
+ let e = document.createElement("div")
+ let w, h
+ e.classList.add("space")
+ e.classList.add(type)
+ if (colony && colony != "SEA")
+ e.classList.add("colony_" + colony)
+ if (type === "regular-space") {
+ w = 66
+ h = 66
+ } else if (type === "winter-quarters") {
+ w = 66
+ h = 66
+ } else if (type === "fortified-port") {
+ w = 54
+ h = 54
+ } else if (type === "blockade") {
+ w = 96
+ h = 80
} else {
- w = 60;
- h = 60;
+ w = 60
+ h = 60
}
- let b = 7;
- w -= 2;
- h -= 2;
- e.style.left = (x - w/2 - b) + "px";
- e.style.top = (y - h/2 - b) + "px";
- e.style.width = (w) + "px";
- e.style.height = (h) + "px";
- return e;
+ let b = 7
+ w -= 2
+ h -= 2
+ e.style.left = x - w / 2 - b + "px"
+ e.style.top = y - h / 2 - b + "px"
+ e.style.width = w + "px"
+ e.style.height = h + "px"
+ return e
}
for (let name in SPACES) {
- let space = SPACES[name];
+ let space = SPACES[name]
if (space.colony != null) {
- let e = buildNode(space.type, space.x, space.y, SPACES[name].colony);
- e.setAttribute("id", name);
- e.addEventListener("mouseenter", onFocusNode);
- e.addEventListener("mouseleave", onBlurNode);
- e.addEventListener("click", on_space);
- ui.spaces[name] = e;
- document.getElementById("spaces").appendChild(e);
- build_marker("pc", name+"-pc", space.x, space.y, 67, 58.5, ["pc"]);
+ let e = buildNode(space.type, space.x, space.y, SPACES[name].colony)
+ e.setAttribute("id", name)
+ e.addEventListener("mouseenter", onFocusNode)
+ e.addEventListener("mouseleave", onBlurNode)
+ e.addEventListener("click", on_space)
+ ui.spaces[name] = e
+ document.getElementById("spaces").appendChild(e)
+ build_marker("pc", name + "-pc", space.x, space.y, 67, 58.5, [ "pc" ])
}
}
for (let zone of BLOCKADE_ZONES) {
- let e = buildNode("blockade", BOXES[zone].x, BOXES[zone].y, "SEA");
- e.setAttribute("id", zone);
- e.addEventListener("click", on_space);
- document.getElementById("spaces").appendChild(e);
- ui.blockade[zone] = e;
+ let e = buildNode("blockade", BOXES[zone].x, BOXES[zone].y, "SEA")
+ e.setAttribute("id", zone)
+ e.addEventListener("click", on_space)
+ document.getElementById("spaces").appendChild(e)
+ ui.blockade[zone] = e
}
- ui.turn = build_marker("markers", "GameTurn",
- BOXES["Game Turn 1775"].x, BOXES["Game Turn 1775"].y, 56.5, 56.5,
- ["turn"]);
-
- ui.french_alliance = build_marker("markers", "FrenchAlliance",
- BOXES["French Alliance Track 0"].x, BOXES["French Alliance Track 0"].y, 56.5, 56.5,
- ["french-alliance"]);
-
- ui.french_navy = build_marker("markers", "FrenchNavy",
- BOXES["French Reinforcements"].x-130/2-10, BOXES["French Reinforcements"].y-32, 126/2, 252/2,
- ["french-navy"]);
-
- ui.congress = build_marker("markers", "Congress",
- SPACES["Philadelphia"].x, SPACES["Philadelphia"].y, 113/2, 113/2,
- ["congress"]);
+ ui.turn = build_marker("markers", "GameTurn", BOXES["Game Turn 1775"].x, BOXES["Game Turn 1775"].y, 56.5, 56.5, [
+ "turn",
+ ])
+
+ ui.french_alliance = build_marker(
+ "markers",
+ "FrenchAlliance",
+ BOXES["French Alliance Track 0"].x,
+ BOXES["French Alliance Track 0"].y,
+ 56.5,
+ 56.5,
+ [ "french-alliance" ]
+ )
+
+ ui.french_navy = build_marker(
+ "markers",
+ "FrenchNavy",
+ BOXES["French Reinforcements"].x - 130 / 2 - 10,
+ BOXES["French Reinforcements"].y - 32,
+ 126 / 2,
+ 252 / 2,
+ [ "french-navy" ]
+ )
+
+ ui.congress = build_marker(
+ "markers",
+ "Congress",
+ SPACES["Philadelphia"].x,
+ SPACES["Philadelphia"].y,
+ 113 / 2,
+ 113 / 2,
+ [ "congress" ]
+ )
for (let c in COLONIES) {
- ui.control[c] = build_marker("markers", "control_" + c,
- BOXES[c].x, BOXES[c].y, 38+8, 38+8,
- ["control"]);
+ ui.control[c] = build_marker("markers", "control_" + c, BOXES[c].x, BOXES[c].y, 38 + 8, 38 + 8, [ "control" ])
}
for (let c = 1; c <= 110; ++c) {
- ui.cards[c] = document.getElementById("card+"+c);
- ui.cards[c].addEventListener("click", on_card);
+ ui.cards[c] = document.getElementById("card+" + c)
+ ui.cards[c].addEventListener("click", on_card)
}
for (let g in GENERALS) {
- let color = GENERALS[g].owner.toLowerCase();
- ui.generals[g] = build_marker("generals", g,
- 0,
- 0,
- 126/2,
- 252/2,
- ["general", color, g, "offmap"]);
- ui.generals[g].addEventListener("click", on_general);
+ let color = GENERALS[g].owner.toLowerCase()
+ ui.generals[g] = build_marker("generals", g, 0, 0, 126 / 2, 252 / 2, [ "general", color, g, "offmap" ])
+ ui.generals[g].addEventListener("click", on_general)
}
}
function update_units() {
- const unitW = 130/2;
- const unitH = 263/2;
- const generalX = -22;
- const generalY = 22;
- const cuX = 20;
- const cuY = 10;
-
- update_marker(ui.turn, "Game Turn " + view.year);
+ const unitW = 130 / 2
+ const unitH = 263 / 2
+ const generalX = -22
+ const generalY = 22
+ const cuX = 20
+ const cuY = 10
+
+ update_marker(ui.turn, "Game Turn " + view.year)
if (view.regulars)
- ui.turn.classList.remove("no-regulars");
+ ui.turn.classList.remove("no-regulars")
else
- ui.turn.classList.add("no-regulars");
+ ui.turn.classList.add("no-regulars")
- update_marker(ui.congress, view.congress);
+ update_marker(ui.congress, view.congress)
- update_marker(ui.french_alliance, "French Alliance Track " + view.french_alliance);
+ update_marker(ui.french_alliance, "French Alliance Track " + view.french_alliance)
if (view.european_war)
- ui.french_alliance.classList.add("european-war");
+ ui.french_alliance.classList.add("european-war")
else
- ui.french_alliance.classList.remove("european-war");
+ ui.french_alliance.classList.remove("european-war")
if (view.french_navy == "French Reinforcements") {
- let x = BOXES["French Reinforcements"].x-130/2-10;
- let y = BOXES["French Reinforcements"].y-32;
- let w = 126/2;
- let h = 252/2;
- ui.french_navy.style.left = ((x-w/2)|0) + "px";
- ui.french_navy.style.top = ((y-h/2)|0) + "px";
+ let x = BOXES["French Reinforcements"].x - 130 / 2 - 10
+ let y = BOXES["French Reinforcements"].y - 32
+ let w = 126 / 2
+ let h = 252 / 2
+ ui.french_navy.style.left = ((x - w / 2) | 0) + "px"
+ ui.french_navy.style.top = ((y - h / 2) | 0) + "px"
} else {
- update_marker(ui.french_navy, view.french_navy);
+ update_marker(ui.french_navy, view.french_navy)
}
for (let space in SPACES) {
- let space_pc = view.pc[space];
- let e = document.getElementById(space+"-pc");
+ let space_pc = view.pc[space]
+ let e = document.getElementById(space + "-pc")
if (e) {
if (space_pc === BRITISH) {
- e.classList.remove("american");
- e.classList.add("british");
+ e.classList.remove("american")
+ e.classList.add("british")
} else if (space_pc === AMERICAN) {
- e.classList.add("american");
- e.classList.remove("british");
+ e.classList.add("american")
+ e.classList.remove("british")
} else {
- e.classList.remove("american");
- e.classList.remove("british");
+ e.classList.remove("american")
+ e.classList.remove("british")
}
}
}
for (let c in COLONIES) {
- let control = 0;
+ let control = 0
for (let space of COLONIES[c]) {
if (view.pc[space] == BRITISH)
- --control;
+ --control
else if (view.pc[space] == AMERICAN)
- ++control;
+ ++control
}
if (control < 0)
- ui.control[c].className = "marker control british";
+ ui.control[c].className = "marker control british"
else if (control > 0)
- ui.control[c].className = "marker control american";
+ ui.control[c].className = "marker control american"
else
- ui.control[c].className = "marker control";
+ ui.control[c].className = "marker control"
}
- let offset = {};
+ let offset = {}
for (let g in GENERALS) {
- let e = ui.generals[g];
- let unit = view.generals[g];
- let space = SPACES[unit.location] || BOXES[unit.location];
+ let e = ui.generals[g]
+ let unit = view.generals[g]
+ let space = SPACES[unit.location] || BOXES[unit.location]
if (space) {
- let o = (offset[space.name]|0);
- update_marker_xy(e, space.x + o * generalX, space.y + o * generalY - 32);
- e.classList.remove("offmap");
- offset[space.name] = ++o;
+ let o = offset[space.name] | 0
+ update_marker_xy(e, space.x + o * generalX, space.y + o * generalY - 32)
+ e.classList.remove("offmap")
+ offset[space.name] = ++o
} else {
- e.classList.add("offmap");
+ e.classList.add("offmap")
}
if (view.who == g)
- e.classList.add("selected");
+ e.classList.add("selected")
else
- e.classList.remove("selected");
+ e.classList.remove("selected")
}
// TODO: reuse CU elements
- offset = {};
- clear_group("cu");
+ offset = {}
+ clear_group("cu")
for (let i = 0; i < view.cu.length; ++i) {
- let cu = view.cu[i];
- let space = SPACES[cu.location] || BOXES[cu.location];
- let o = (offset[space.name]|0);
- let x = space.x + o * cuX;
- let y = space.y + o * cuY;
- let e = build_marker("cu", "cu"+i, x, y, 122/2, 122/2, ["cu", cu.owner.toLowerCase()]);
- e.textContent = cu.count;
- offset[space.name] = ++o;
+ let cu = view.cu[i]
+ let space = SPACES[cu.location] || BOXES[cu.location]
+ let o = offset[space.name] | 0
+ let x = space.x + o * cuX
+ let y = space.y + o * cuY
+ let e = build_marker("cu", "cu" + i, x, y, 122 / 2, 122 / 2, [ "cu", cu.owner.toLowerCase() ])
+ e.textContent = cu.count
+ offset[space.name] = ++o
}
}
-build_map();
+build_map()
function player_info(player, nc, nq) {
let info = ""
@@ -296,120 +307,120 @@ function player_info(player, nc, nq) {
if (nq > 0)
info += nq + "\u{231b} "
info += nc + "\u{1f3b4}"
- return info;
+ return info
}
function on_update() {
- let e;
+ let e
- roles.American.stat.textContent = player_info(AMERICAN, view.a_cards, view.a_queue);
- roles.British.stat.textContent = player_info(BRITISH, view.b_cards, view.b_queue);
+ roles.American.stat.textContent = player_info(AMERICAN, view.a_cards, view.a_queue)
+ roles.British.stat.textContent = player_info(BRITISH, view.b_cards, view.b_queue)
if (!view.last_played)
- document.getElementById("last_played").className = "card show card_back";
+ document.getElementById("last_played").className = "card show card_back"
else
- document.getElementById("last_played").className = "card show card_" + view.last_played;
-
- action_button("pickup_british_cu", "Pick up British CU");
- action_button("pickup_american_cu", "Pick up American CU");
- action_button("pickup_french_cu", "Pick up French CU");
- action_button("drop_british_cu", "Drop off British CU");
- action_button("drop_american_cu", "Drop off American CU");
- action_button("drop_french_cu", "Drop off French CU");
- action_button("british_first", "British");
- action_button("american_first", "American");
- action_button("surrender", "Surrender");
- action_button("pass", "Next");
- action_button("undo", "Undo");
-
- e = document.getElementById("war_ends");
- e.classList.remove("year_1779");
- e.classList.remove("year_1780");
- e.classList.remove("year_1781");
- e.classList.remove("year_1782");
- e.classList.remove("year_1783");
+ document.getElementById("last_played").className = "card show card_" + view.last_played
+
+ action_button("pickup_british_cu", "Pick up British CU")
+ action_button("pickup_american_cu", "Pick up American CU")
+ action_button("pickup_french_cu", "Pick up French CU")
+ action_button("drop_british_cu", "Drop off British CU")
+ action_button("drop_american_cu", "Drop off American CU")
+ action_button("drop_french_cu", "Drop off French CU")
+ action_button("british_first", "British")
+ action_button("american_first", "American")
+ action_button("surrender", "Surrender")
+ action_button("pass", "Next")
+ action_button("undo", "Undo")
+
+ e = document.getElementById("war_ends")
+ e.classList.remove("year_1779")
+ e.classList.remove("year_1780")
+ e.classList.remove("year_1781")
+ e.classList.remove("year_1782")
+ e.classList.remove("year_1783")
if (view.war_ends)
- e.classList.add("year_" + view.war_ends);
-
- e = document.getElementById("played_british_reinforcements");
- e.classList.remove("ops_1");
- e.classList.remove("ops_2");
- e.classList.remove("ops_3");
- e.classList.add("ops_" + view.played_british_reinforcements);
-
- e = document.getElementById("played_american_reinforcements_1");
- e.classList.remove("ops_1");
- e.classList.remove("ops_2");
- e.classList.remove("ops_3");
+ e.classList.add("year_" + view.war_ends)
+
+ e = document.getElementById("played_british_reinforcements")
+ e.classList.remove("ops_1")
+ e.classList.remove("ops_2")
+ e.classList.remove("ops_3")
+ e.classList.add("ops_" + view.played_british_reinforcements)
+
+ e = document.getElementById("played_american_reinforcements_1")
+ e.classList.remove("ops_1")
+ e.classList.remove("ops_2")
+ e.classList.remove("ops_3")
if (view.played_american_reinforcements.length >= 1)
- e.classList.add("ops_" + view.played_american_reinforcements[0]);
+ e.classList.add("ops_" + view.played_american_reinforcements[0])
- e = document.getElementById("played_american_reinforcements_2");
- e.classList.remove("ops_1");
- e.classList.remove("ops_2");
- e.classList.remove("ops_3");
+ e = document.getElementById("played_american_reinforcements_2")
+ e.classList.remove("ops_1")
+ e.classList.remove("ops_2")
+ e.classList.remove("ops_3")
if (view.played_american_reinforcements.length >= 2)
- e.classList.add("ops_" + view.played_american_reinforcements[1]);
+ e.classList.add("ops_" + view.played_american_reinforcements[1])
- let cards = view.hand;
+ let cards = view.hand
for (let c = 1; c <= 110; ++c) {
- ui.cards[c].classList.remove('enabled');
+ ui.cards[c].classList.remove("enabled")
if (cards && cards.includes(c))
- ui.cards[c].classList.add('show');
+ ui.cards[c].classList.add("show")
else
- ui.cards[c].classList.remove('show');
+ ui.cards[c].classList.remove("show")
}
for (let space in SPACES)
- ui.spaces[space].classList.remove('enabled');
+ ui.spaces[space].classList.remove("enabled")
for (let general in GENERALS)
- ui.generals[general].classList.remove('enabled');
+ ui.generals[general].classList.remove("enabled")
for (let zone of BLOCKADE_ZONES)
- ui.blockade[zone].classList.remove('enabled');
+ ui.blockade[zone].classList.remove("enabled")
- update_units();
+ update_units()
if (player != view.active)
- return;
+ return
for (let action of Object.keys(view.actions)) {
- let args = view.actions[action];
+ let args = view.actions[action]
switch (action) {
- case 'card_play_event':
- case 'card_discard_event':
- case 'card_campaign':
- case 'card_ops_general':
- case 'card_ops_pc':
- case 'card_ops_reinforcements':
- case 'card_ops_queue':
- case 'card_battle_play':
- case 'card_battle_discard':
- case 'exchange_for_discard':
- for (let card of args)
- ui.cards[card].classList.add('enabled');
- break;
- case 'remove_cu':
+ case "card_play_event":
+ case "card_discard_event":
+ case "card_campaign":
+ case "card_ops_general":
+ case "card_ops_pc":
+ case "card_ops_reinforcements":
+ case "card_ops_queue":
+ case "card_battle_play":
+ case "card_battle_discard":
+ case "exchange_for_discard":
+ for (let card of args)
+ ui.cards[card].classList.add("enabled")
+ break
+ case "remove_cu":
// TODO: target CU not space?
- case 'move':
- case 'sea_move':
- case 'place_continental_congress':
- case 'place_reinforcements':
- case 'place_american_pc':
- case 'place_british_pc':
- case 'remove_pc':
- case 'flip_pc':
- for (let space of args)
- ui.spaces[space].classList.add('enabled');
- break;
- case 'select_general':
- for (let general of args)
- ui.generals[general].classList.add('enabled');
- break;
- case 'place_navy':
- for (let zone of args)
- ui.blockade[zone].classList.add('enabled');
+ case "move":
+ case "sea_move":
+ case "place_continental_congress":
+ case "place_reinforcements":
+ case "place_american_pc":
+ case "place_british_pc":
+ case "remove_pc":
+ case "flip_pc":
+ for (let space of args)
+ ui.spaces[space].classList.add("enabled")
+ break
+ case "select_general":
+ for (let general of args)
+ ui.generals[general].classList.add("enabled")
+ break
+ case "place_navy":
+ for (let zone of args)
+ ui.blockade[zone].classList.add("enabled")
}
}
}
@@ -472,39 +483,38 @@ function hide_popup_menu() {
function on_card(evt) {
if (view.actions) {
- let c = evt.target.id.split("+")[1] | 0;
+ let c = evt.target.id.split("+")[1] | 0
show_popup_menu(evt, "popup", c, CARDS[c].title)
}
}
function get_action_from_arg(x) {
for (let action of Object.keys(view.actions)) {
- let args = view.actions[action];
+ let args = view.actions[action]
if (Array.isArray(args) && args.includes(x))
- return action;
+ return action
}
- return null;
+ return null
}
function on_space(evt) {
if (view.actions) {
- let space = evt.target.id;
- let action = get_action_from_arg(space);
+ let space = evt.target.id
+ let action = get_action_from_arg(space)
if (action)
- send_action(action, space);
+ send_action(action, space)
}
}
function on_general(evt) {
if (view.actions) {
- let general = evt.target.id;
- let action = get_action_from_arg(general);
+ let general = evt.target.id
+ let action = get_action_from_arg(general)
if (action)
- send_action(action, general);
+ send_action(action, general)
}
}
function toggle_markers() {
- document.querySelector("#map").classList.toggle("hide_markers");
+ document.querySelector("#map").classList.toggle("hide_markers")
}
-