From 5d81b4294bd8f9b20ac8a396a185f6cf9550c00f Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 25 Oct 2024 11:58:58 +0200 Subject: Update client. Fixed some spelling errors in space data table. Create tools directory and add Makefile. Add layout.svg with boxes drawn on top of locations. Add genlayout.js to create list of box locations. Add gencolors.js to create beveled marker border colors. Major rewrite of play.js and play.css with official assets. --- Makefile | 9 + data.js | 1355 +++++++++++++++++++++++++++++++++++++++++++++++--- gencode.js | 107 ---- images/trash-can.svg | 1 + info/cards.html | 193 +++++++ play.css | 1010 +++++++++++++------------------------ play.html | 236 ++++----- play.js | 1080 +++++++++++++++++----------------------- rules.js | 71 ++- tools/colors.js | 110 ++++ tools/gencode.js | 106 ++++ tools/gencolors.js | 78 +++ tools/genlayout.js | 37 ++ tools/layout.svg | 920 ++++++++++++++++++++++++++++++++++ 14 files changed, 3651 insertions(+), 1662 deletions(-) create mode 100644 Makefile delete mode 100644 gencode.js create mode 100644 images/trash-can.svg create mode 100644 info/cards.html create mode 100644 tools/colors.js create mode 100644 tools/gencode.js create mode 100644 tools/gencolors.js create mode 100644 tools/genlayout.js create mode 100644 tools/layout.svg diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..daa5c21 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +default: rules.js play.js +rules.js: events.txt + sed '/const CODE /,$$d' < rules.js > /tmp/rules.js + node tools/gencode.js >> /tmp/rules.js + cp /tmp/rules.js rules.js +play.js: tools/layout.svg + sed '/var LAYOUT /,$$d' < play.js > /tmp/play.js + node tools/genlayout.js >> /tmp/play.js + cp /tmp/play.js play.js diff --git a/data.js b/data.js index 17e7530..6c37c50 100644 --- a/data.js +++ b/data.js @@ -1,80 +1,1280 @@ -const spaces = [ - null, - {name_unique: 'Schwerin', space_id: 1, socio: 4, stability: 3, battleground: 0, demInfl: 0, comInfl: 0, country: 'East_Germany', region: 'Eastern Europe', box: {x: 111, y: 61}, adjacent: [2, 3, , , ]}, - {name_unique: 'Rostock', space_id: 2, socio: 4, stability: 3, battleground: 0, demInfl: 0, comInfl: 0, country: 'East_Germany', region: 'Eastern Europe', box: {x: 228, y: 41}, adjacent: [1, 3, , , ]}, - {name_unique: 'Berlin', space_id: 3, socio: 2, stability: 3, battleground: 1, demInfl: 0, comInfl: 2, country: 'East_Germany', region: 'Eastern Europe', box: {x: 251, y: 113}, adjacent: [1, 2, 5, 9, ]}, - {name_unique: 'German Writers', space_id: 4, socio: 5, stability: 2, battleground: 0, demInfl: 0, comInfl: 0, country: 'East_Germany', region: 'Eastern Europe', box: {x: 58, y: 185}, adjacent: [5, , , , ]}, - {name_unique: 'Walter Ulbricht Academy', space_id: 5, socio: 6, stability: 1, battleground: 0, demInfl: 0, comInfl: 0, country: 'East_Germany', region: 'Eastern Europe', box: {x: 175, y: 187}, adjacent: [3, 4, , , ]}, - {name_unique: 'Lutherian Church', space_id: 6, socio: 7, stability: 5, battleground: 1, demInfl: 1, comInfl: 0, country: 'East_Germany', region: 'Eastern Europe', box: {x: 300, y: 212}, adjacent: [9, , , , ]}, - {name_unique: 'Magdeburg', space_id: 7, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'East_Germany', region: 'Eastern Europe', box: {x: 58, y: 275}, adjacent: [8, 10, 11, , ]}, - {name_unique: 'Halle', space_id: 8, socio: 4, stability: 3, battleground: 0, demInfl: 0, comInfl: 0, country: 'East_Germany', region: 'Eastern Europe', box: {x: 175, y: 278}, adjacent: [7, 9, 11, , ]}, - {name_unique: 'Leipzig', space_id: 9, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'East_Germany', region: 'Eastern Europe', box: {x: 297, y: 297}, adjacent: [3, 6, 8, 11, 12]}, - {name_unique: 'Erfurt', space_id: 10, socio: 3, stability: 4, battleground: 0, demInfl: 0, comInfl: 0, country: 'East_Germany', region: 'Eastern Europe', box: {x: 23, y: 356}, adjacent: [7, , , , ]}, - {name_unique: 'Karl-Marx-Stadt', space_id: 11, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'East_Germany', region: 'Eastern Europe', box: {x: 138, y: 385}, adjacent: [7, 8, 9, 12, ]}, - {name_unique: 'Dresden', space_id: 12, socio: 1, stability: 4, battleground: 1, demInfl: 0, comInfl: 2, country: 'East_Germany', region: 'Eastern Europe', box: {x: 262, y: 375}, adjacent: [9, 11, 19, 27, ]}, - {name_unique: 'Szczecin', space_id: 13, socio: 4, stability: 3, battleground: 0, demInfl: 0, comInfl: 0, country: 'Poland', region: 'Eastern Europe', box: {x: 434, y: 204}, adjacent: [14, 16, , , ]}, - {name_unique: 'Gdańsk', space_id: 14, socio: 4, stability: 3, battleground: 1, demInfl: 1, comInfl: 0, country: 'Poland', region: 'Eastern Europe', box: {x: 699, y: 215}, adjacent: [13, 15, 16, 17, 18]}, - {name_unique: 'Bydgoszcz', space_id: 15, socio: 1, stability: 4, battleground: 0, demInfl: 0, comInfl: 1, country: 'Poland', region: 'Eastern Europe', box: {x: 679, y: 304}, adjacent: [14, 17, , , ]}, - {name_unique: 'Poznań', space_id: 16, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Poland', region: 'Eastern Europe', box: {x: 521, y: 355}, adjacent: [13, 14, 19, 20, ]}, - {name_unique: 'Warszawa', space_id: 17, socio: 2, stability: 3, battleground: 1, demInfl: 0, comInfl: 1, country: 'Poland', region: 'Eastern Europe', box: {x: 806, y: 383}, adjacent: [14, 15, 18, 21, 24]}, - {name_unique: 'Białystok', space_id: 18, socio: 3, stability: 4, battleground: 0, demInfl: 0, comInfl: 0, country: 'Poland', region: 'Eastern Europe', box: {x: 940, y: 342}, adjacent: [14, 17, 24, , ]}, - {name_unique: 'Wrocław', space_id: 19, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Poland', region: 'Eastern Europe', box: {x: 462, y: 443}, adjacent: [12, 16, 20, 22, ]}, - {name_unique: 'Catholic Church, Poland', space_id: 20, socio: 7, stability: 5, battleground: 0, demInfl: 5, comInfl: 0, country: 'Poland', region: 'Eastern Europe', box: {x: 625, y: 437}, adjacent: [16, 19, 21, 22, 23]}, - {name_unique: 'Łódź', space_id: 21, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Poland', region: 'Eastern Europe', box: {x: 749, y: 486}, adjacent: [17, 20, 23, 24, ]}, - {name_unique: 'Katowice', space_id: 22, socio: 4, stability: 3, battleground: 0, demInfl: 0, comInfl: 0, country: 'Poland', region: 'Eastern Europe', box: {x: 570, y: 569}, adjacent: [19, 20, 23, 33, ]}, - {name_unique: 'Kraków', space_id: 23, socio: 4, stability: 3, battleground: 1, demInfl: 1, comInfl: 0, country: 'Poland', region: 'Eastern Europe', box: {x: 711, y: 598}, adjacent: [20, 21, 22, 25, ]}, - {name_unique: 'Lublin', space_id: 24, socio: 3, stability: 4, battleground: 0, demInfl: 0, comInfl: 1, country: 'Poland', region: 'Eastern Europe', box: {x: 879, y: 603}, adjacent: [17, 18, 21, , ]}, - {name_unique: 'Jagiellian University', space_id: 25, socio: 6, stability: 1, battleground: 0, demInfl: 0, comInfl: 0, country: 'Poland', region: 'Eastern Europe', box: {x: 679, y: 681}, adjacent: [23, 26, , , ]}, - {name_unique: 'Polish Writers', space_id: 26, socio: 5, stability: 2, battleground: 0, demInfl: 0, comInfl: 0, country: 'Poland', region: 'Eastern Europe', box: {x: 832, y: 694}, adjacent: [25, , , , ]}, - {name_unique: 'Plzeň', space_id: 27, socio: 1, stability: 4, battleground: 0, demInfl: 0, comInfl: 2, country: 'Czechoslovakia', region: 'Eastern Europe', box: {x: 159, y: 483}, adjacent: [12, 28, 29, , ]}, - {name_unique: 'České Budĕjovice', space_id: 28, socio: 4, stability: 3, battleground: 0, demInfl: 0, comInfl: 0, country: 'Czechoslovakia', region: 'Eastern Europe', box: {x: 196, y: 601}, adjacent: [27, 29, , , ]}, - {name_unique: 'Praha', space_id: 29, socio: 2, stability: 3, battleground: 1, demInfl: 0, comInfl: 2, country: 'Czechoslovakia', region: 'Eastern Europe', box: {x: 317, y: 614}, adjacent: [27, 28, 30, 32, ]}, - {name_unique: 'Charles University', space_id: 30, socio: 6, stability: 1, battleground: 1, demInfl: 0, comInfl: 0, country: 'Czechoslovakia', region: 'Eastern Europe', box: {x: 380, y: 532}, adjacent: [29, 31, , , ]}, - {name_unique: 'Czech Writers', space_id: 31, socio: 5, stability: 2, battleground: 1, demInfl: 2, comInfl: 0, country: 'Czechoslovakia', region: 'Eastern Europe', box: {x: 444, y: 607}, adjacent: [30, , , , ]}, - {name_unique: 'Brno', space_id: 32, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 1, country: 'Czechoslovakia', region: 'Eastern Europe', box: {x: 403, y: 711}, adjacent: [29, 33, 34, , ]}, - {name_unique: 'Ostrava', space_id: 33, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Czechoslovakia', region: 'Eastern Europe', box: {x: 523, y: 681}, adjacent: [22, 32, 34, 35, ]}, - {name_unique: 'Bratislava', space_id: 34, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Czechoslovakia', region: 'Eastern Europe', box: {x: 417, y: 797}, adjacent: [32, 33, 35, , ]}, - {name_unique: 'Catholic Church, Czechoslovakia', space_id: 35, socio: 7, stability: 5, battleground: 0, demInfl: 1, comInfl: 0, country: 'Czechoslovakia', region: 'Eastern Europe', box: {x: 538, y: 794}, adjacent: [33, 34, 36, , ]}, - {name_unique: 'Prešov', space_id: 36, socio: 3, stability: 4, battleground: 0, demInfl: 0, comInfl: 0, country: 'Czechoslovakia', region: 'Eastern Europe', box: {x: 658, y: 794}, adjacent: [35, 37, , , ]}, - {name_unique: 'Košice', space_id: 37, socio: 3, stability: 4, battleground: 0, demInfl: 0, comInfl: 0, country: 'Czechoslovakia', region: 'Eastern Europe', box: {x: 777, y: 815}, adjacent: [36, 42, , , ]}, - {name_unique: 'Catholic Church, Hungary', space_id: 38, socio: 7, stability: 5, battleground: 0, demInfl: 1, comInfl: 0, country: 'Hungary', region: 'Eastern Europe', box: {x: 314, y: 886}, adjacent: [39, 43, , , ]}, - {name_unique: 'Győr', space_id: 39, socio: 4, stability: 3, battleground: 0, demInfl: 0, comInfl: 0, country: 'Hungary', region: 'Eastern Europe', box: {x: 434, y: 887}, adjacent: [38, 40, 43, 44, ]}, - {name_unique: 'Tatabánya', space_id: 40, socio: 4, stability: 3, battleground: 0, demInfl: 0, comInfl: 0, country: 'Hungary', region: 'Eastern Europe', box: {x: 549, y: 886}, adjacent: [39, 41, 45, , ]}, - {name_unique: 'Miskolc', space_id: 41, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Hungary', region: 'Eastern Europe', box: {x: 664, y: 901}, adjacent: [40, 42, 45, , ]}, - {name_unique: 'Debrecen', space_id: 42, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Hungary', region: 'Eastern Europe', box: {x: 781, y: 938}, adjacent: [37, 41, , , ]}, - {name_unique: 'Szombathely', space_id: 43, socio: 1, stability: 4, battleground: 0, demInfl: 0, comInfl: 1, country: 'Hungary', region: 'Eastern Europe', box: {x: 316, y: 963}, adjacent: [38, 39, 44, , ]}, - {name_unique: 'Székesfehérvár', space_id: 44, socio: 4, stability: 3, battleground: 0, demInfl: 1, comInfl: 0, country: 'Hungary', region: 'Eastern Europe', box: {x: 442, y: 962}, adjacent: [39, 43, 45, , ]}, - {name_unique: 'Budapest', space_id: 45, socio: 2, stability: 3, battleground: 1, demInfl: 1, comInfl: 0, country: 'Hungary', region: 'Eastern Europe', box: {x: 630, y: 983}, adjacent: [40, 41, 44, 47, 48]}, - {name_unique: 'Hungarian Writers', space_id: 46, socio: 5, stability: 2, battleground: 0, demInfl: 0, comInfl: 0, country: 'Hungary', region: 'Eastern Europe', box: {x: 348, y: 1040}, adjacent: [47, , , , ]}, - {name_unique: 'Eötvös Loránd University', space_id: 47, socio: 6, stability: 1, battleground: 0, demInfl: 0, comInfl: 0, country: 'Hungary', region: 'Eastern Europe', box: {x: 512, y: 1034}, adjacent: [46, 45, , , ]}, - {name_unique: 'Szeged', space_id: 48, socio: 3, stability: 4, battleground: 1, demInfl: 1, comInfl: 0, country: 'Hungary', region: 'Eastern Europe', box: {x: 632, y: 1073}, adjacent: [45, 49, 50, , ]}, - {name_unique: 'Pécs', space_id: 49, socio: 3, stability: 4, battleground: 0, demInfl: 0, comInfl: 0, country: 'Hungary', region: 'Eastern Europe', box: {x: 486, y: 1105}, adjacent: [48, , , , ]}, - {name_unique: 'Timişoara', space_id: 50, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Romania', region: 'Balkans', box: {x: 597, y: 1204}, adjacent: [48, 51, 60, , ]}, - {name_unique: 'Cluj-Napoca', space_id: 51, socio: 1, stability: 4, battleground: 1, demInfl: 0, comInfl: 2, country: 'Romania', region: 'Balkans', box: {x: 756, y: 1125}, adjacent: [50, 54, 58, 61, ]}, - {name_unique: 'Târgu Mureş', space_id: 52, socio: 3, stability: 4, battleground: 0, demInfl: 0, comInfl: 0, country: 'Romania', region: 'Balkans', box: {x: 915, y: 1136}, adjacent: [53, 56, , , ]}, - {name_unique: 'Iaşi', space_id: 53, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Romania', region: 'Balkans', box: {x: 1072, y: 1097}, adjacent: [52, 57, 62, , ]}, - {name_unique: 'Babeş-Bolyai University', space_id: 54, socio: 6, stability: 1, battleground: 0, demInfl: 0, comInfl: 0, country: 'Romania', region: 'Balkans', box: {x: 746, y: 1203}, adjacent: [51, 55, , , ]}, - {name_unique: 'Romanian Writers', space_id: 55, socio: 5, stability: 2, battleground: 0, demInfl: 0, comInfl: 0, country: 'Romania', region: 'Balkans', box: {x: 739, y: 1278}, adjacent: [54, , , , ]}, - {name_unique: 'Hargita/Covasna', space_id: 56, socio: 8, stability: 4, battleground: 0, demInfl: 0, comInfl: 0, country: 'Romania', region: 'Balkans', box: {x: 928, y: 1227}, adjacent: [52, , , , ]}, - {name_unique: 'Braşov', space_id: 57, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Romania', region: 'Balkans', box: {x: 1049, y: 1225}, adjacent: [53, 59, 61, , ]}, - {name_unique: 'Orthodox Church Romania', space_id: 58, socio: 7, stability: 3, battleground: 0, demInfl: 0, comInfl: 0, country: 'Romania', region: 'Balkans', box: {x: 855, y: 1338}, adjacent: [51, 60, , , ]}, - {name_unique: 'Ploieşti', space_id: 59, socio: 4, stability: 3, battleground: 0, demInfl: 0, comInfl: 0, country: 'Romania', region: 'Balkans', box: {x: 1061, y: 1316}, adjacent: [57, 61, 62, , ]}, - {name_unique: 'Craiova', space_id: 60, socio: 3, stability: 4, battleground: 0, demInfl: 0, comInfl: 0, country: 'Romania', region: 'Balkans', box: {x: 763, y: 1411}, adjacent: [50, 58, 61, , ]}, - {name_unique: 'Bucureşti', space_id: 61, socio: 2, stability: 3, battleground: 1, demInfl: 0, comInfl: 2, country: 'Romania', region: 'Balkans', box: {x: 929, y: 1445}, adjacent: [51, 57, 59, 60, 63]}, - {name_unique: 'Galaţi', space_id: 62, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Romania', region: 'Balkans', box: {x: 1104, y: 1399}, adjacent: [53, 59, 63, , ]}, - {name_unique: 'Constanţa', space_id: 63, socio: 4, stability: 3, battleground: 0, demInfl: 0, comInfl: 0, country: 'Romania', region: 'Balkans', box: {x: 1130, y: 1517}, adjacent: [61, 62, 72, , ]}, - {name_unique: 'Pleven', space_id: 64, socio: 3, stability: 4, battleground: 0, demInfl: 0, comInfl: 0, country: 'Bulgaria', region: 'Balkans', box: {x: 764, y: 1534}, adjacent: [68, , , , ]}, - {name_unique: 'Orthodox Church Bulgaria', space_id: 65, socio: 7, stability: 3, battleground: 0, demInfl: 0, comInfl: 0, country: 'Bulgaria', region: 'Balkans', box: {x: 882, y: 1540}, adjacent: [66, 68, , , ]}, - {name_unique: 'Ruse', space_id: 66, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Bulgaria', region: 'Balkans', box: {x: 998, y: 1540}, adjacent: [65, 69, 70, 71, 72]}, - {name_unique: 'Sofia University', space_id: 67, socio: 6, stability: 1, battleground: 0, demInfl: 0, comInfl: 0, country: 'Bulgaria', region: 'Balkans', box: {x: 645, y: 1650}, adjacent: [68, 73, , , ]}, - {name_unique: 'Sofia', space_id: 68, socio: 2, stability: 3, battleground: 1, demInfl: 0, comInfl: 2, country: 'Bulgaria', region: 'Balkans', box: {x: 768, y: 1653}, adjacent: [64, 65, 67, 69, 74]}, - {name_unique: 'Stara Zagora', space_id: 69, socio: 1, stability: 4, battleground: 0, demInfl: 0, comInfl: 1, country: 'Bulgaria', region: 'Balkans', box: {x: 886, y: 1694}, adjacent: [66, 68, 71, , ]}, - {name_unique: 'Razgrad', space_id: 70, socio: 8, stability: 4, battleground: 0, demInfl: 0, comInfl: 0, country: 'Bulgaria', region: 'Balkans', box: {x: 954, y: 1620}, adjacent: [66, , , , ]}, - {name_unique: 'Burgas', space_id: 71, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Bulgaria', region: 'Balkans', box: {x: 1004, y: 1695}, adjacent: [66, 69, 72, , ]}, - {name_unique: 'Varna', space_id: 72, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Bulgaria', region: 'Balkans', box: {x: 1086, y: 1613}, adjacent: [63, 66, 71, , ]}, - {name_unique: 'Bulgarian Writers', space_id: 73, socio: 5, stability: 2, battleground: 0, demInfl: 0, comInfl: 0, country: 'Bulgaria', region: 'Balkans', box: {x: 652, y: 1726}, adjacent: [67, , , , ]}, - {name_unique: 'Plovdiv', space_id: 74, socio: 4, stability: 3, battleground: 1, demInfl: 0, comInfl: 0, country: 'Bulgaria', region: 'Balkans', box: {x: 771, y: 1739}, adjacent: [68, 75, , , ]}, - {name_unique: 'Sliven', space_id: 75, socio: 3, stability: 4, battleground: 0, demInfl: 0, comInfl: 0, country: 'Bulgaria', region: 'Balkans', box: {x: 894, y: 1768}, adjacent: [74, , , , ]} +const spaces = [ + null, + { + name_unique: "Schwerin", + space_id: 1, + socio: 4, + stability: 3, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "East_Germany", + region: "Eastern Europe", + box: { + x: 111, + y: 61, + }, + adjacent: [ 2, 3 ], + ascii_name: "Schwerin", + }, + { + name_unique: "Rostock", + space_id: 2, + socio: 4, + stability: 3, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "East_Germany", + region: "Eastern Europe", + box: { + x: 228, + y: 41, + }, + adjacent: [ 1, 3 ], + ascii_name: "Rostock", + }, + { + name_unique: "Berlin", + space_id: 3, + socio: 2, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 2, + country: "East_Germany", + region: "Eastern Europe", + box: { + x: 251, + y: 113, + }, + adjacent: [ 1, 2, 5, 9 ], + ascii_name: "Berlin", + }, + { + name_unique: "German Writers", + space_id: 4, + socio: 5, + stability: 2, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "East_Germany", + region: "Eastern Europe", + box: { + x: 58, + y: 185, + }, + adjacent: [ 5 ], + ascii_name: "German Writers", + }, + { + name_unique: "Walter Ulbricht Academy", + space_id: 5, + socio: 6, + stability: 1, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "East_Germany", + region: "Eastern Europe", + box: { + x: 175, + y: 187, + }, + adjacent: [ 3, 4 ], + ascii_name: "Walter Ulbricht Academy", + }, + { + name_unique: "Lutheran Church", + space_id: 6, + socio: 7, + stability: 5, + battleground: 1, + demInfl: 1, + comInfl: 0, + country: "East_Germany", + region: "Eastern Europe", + box: { + x: 300, + y: 212, + }, + adjacent: [ 9 ], + ascii_name: "Lutheran Church", + }, + { + name_unique: "Magdeburg", + space_id: 7, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "East_Germany", + region: "Eastern Europe", + box: { + x: 58, + y: 275, + }, + adjacent: [ 8, 10, 11 ], + ascii_name: "Magdeburg", + }, + { + name_unique: "Halle", + space_id: 8, + socio: 4, + stability: 3, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "East_Germany", + region: "Eastern Europe", + box: { + x: 175, + y: 278, + }, + adjacent: [ 7, 9, 11 ], + ascii_name: "Halle", + }, + { + name_unique: "Leipzig", + space_id: 9, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "East_Germany", + region: "Eastern Europe", + box: { + x: 297, + y: 297, + }, + adjacent: [ 3, 6, 8, 11, 12 ], + ascii_name: "Leipzig", + }, + { + name_unique: "Erfurt", + space_id: 10, + socio: 3, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "East_Germany", + region: "Eastern Europe", + box: { + x: 23, + y: 356, + }, + adjacent: [ 7 ], + ascii_name: "Erfurt", + }, + { + name_unique: "Karl-Marx-Stadt", + space_id: 11, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "East_Germany", + region: "Eastern Europe", + box: { + x: 138, + y: 385, + }, + adjacent: [ 7, 8, 9, 12 ], + ascii_name: "Karl-Marx-Stadt", + }, + { + name_unique: "Dresden", + space_id: 12, + socio: 1, + stability: 4, + battleground: 1, + demInfl: 0, + comInfl: 2, + country: "East_Germany", + region: "Eastern Europe", + box: { + x: 262, + y: 375, + }, + adjacent: [ 9, 11, 19, 27 ], + ascii_name: "Dresden", + }, + { + name_unique: "Szczecin", + space_id: 13, + socio: 4, + stability: 3, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Poland", + region: "Eastern Europe", + box: { + x: 434, + y: 204, + }, + adjacent: [ 14, 16 ], + ascii_name: "Szczecin", + }, + { + name_unique: "Gdańsk", + space_id: 14, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 1, + comInfl: 0, + country: "Poland", + region: "Eastern Europe", + box: { + x: 699, + y: 215, + }, + adjacent: [ 13, 15, 16, 17, 18 ], + ascii_name: "Gdansk", + }, + { + name_unique: "Bydgoszcz", + space_id: 15, + socio: 1, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 1, + country: "Poland", + region: "Eastern Europe", + box: { + x: 679, + y: 304, + }, + adjacent: [ 14, 17 ], + ascii_name: "Bydgoszcz", + }, + { + name_unique: "Poznań", + space_id: 16, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Poland", + region: "Eastern Europe", + box: { + x: 521, + y: 355, + }, + adjacent: [ 13, 14, 19, 20 ], + ascii_name: "Poznan", + }, + { + name_unique: "Warszawa", + space_id: 17, + socio: 2, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 1, + country: "Poland", + region: "Eastern Europe", + box: { + x: 806, + y: 383, + }, + adjacent: [ 14, 15, 18, 21, 24 ], + ascii_name: "Warszawa", + }, + { + name_unique: "Białystok", + space_id: 18, + socio: 3, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Poland", + region: "Eastern Europe", + box: { + x: 940, + y: 342, + }, + adjacent: [ 14, 17, 24 ], + ascii_name: "Bialystok", + }, + { + name_unique: "Wrocław", + space_id: 19, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Poland", + region: "Eastern Europe", + box: { + x: 462, + y: 443, + }, + adjacent: [ 12, 16, 20, 22 ], + ascii_name: "Wroclaw", + }, + { + name_unique: "Catholic Church, Poland", + space_id: 20, + socio: 7, + stability: 5, + battleground: 0, + demInfl: 5, + comInfl: 0, + country: "Poland", + region: "Eastern Europe", + box: { + x: 625, + y: 437, + }, + adjacent: [ 16, 19, 21, 22, 23 ], + ascii_name: "Catholic Church, Poland", + }, + { + name_unique: "Łódź", + space_id: 21, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Poland", + region: "Eastern Europe", + box: { + x: 749, + y: 486, + }, + adjacent: [ 17, 20, 23, 24 ], + ascii_name: "Lodz", + }, + { + name_unique: "Katowice", + space_id: 22, + socio: 4, + stability: 3, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Poland", + region: "Eastern Europe", + box: { + x: 570, + y: 569, + }, + adjacent: [ 19, 20, 23, 33 ], + ascii_name: "Katowice", + }, + { + name_unique: "Kraków", + space_id: 23, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 1, + comInfl: 0, + country: "Poland", + region: "Eastern Europe", + box: { + x: 711, + y: 598, + }, + adjacent: [ 20, 21, 22, 25 ], + ascii_name: "Krakow", + }, + { + name_unique: "Lublin", + space_id: 24, + socio: 3, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 1, + country: "Poland", + region: "Eastern Europe", + box: { + x: 879, + y: 603, + }, + adjacent: [ 17, 18, 21 ], + ascii_name: "Lublin", + }, + { + name_unique: "Jagiellonian University", + space_id: 25, + socio: 6, + stability: 1, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Poland", + region: "Eastern Europe", + box: { + x: 679, + y: 681, + }, + adjacent: [ 23, 26 ], + ascii_name: "Jagiellonian University", + }, + { + name_unique: "Polish Writers", + space_id: 26, + socio: 5, + stability: 2, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Poland", + region: "Eastern Europe", + box: { + x: 832, + y: 694, + }, + adjacent: [ 25 ], + ascii_name: "Polish Writers", + }, + { + name_unique: "Plzeň", + space_id: 27, + socio: 1, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 2, + country: "Czechoslovakia", + region: "Eastern Europe", + box: { + x: 159, + y: 483, + }, + adjacent: [ 12, 28, 29 ], + ascii_name: "Plzen", + }, + { + name_unique: "České Budĕjovice", + space_id: 28, + socio: 4, + stability: 3, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Czechoslovakia", + region: "Eastern Europe", + box: { + x: 196, + y: 601, + }, + adjacent: [ 27, 29 ], + ascii_name: "Ceske Budejovice", + }, + { + name_unique: "Praha", + space_id: 29, + socio: 2, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 2, + country: "Czechoslovakia", + region: "Eastern Europe", + box: { + x: 317, + y: 614, + }, + adjacent: [ 27, 28, 30, 32 ], + ascii_name: "Praha", + }, + { + name_unique: "Charles University", + space_id: 30, + socio: 6, + stability: 1, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Czechoslovakia", + region: "Eastern Europe", + box: { + x: 380, + y: 532, + }, + adjacent: [ 29, 31 ], + ascii_name: "Charles University", + }, + { + name_unique: "Czech Writers", + space_id: 31, + socio: 5, + stability: 2, + battleground: 1, + demInfl: 2, + comInfl: 0, + country: "Czechoslovakia", + region: "Eastern Europe", + box: { + x: 444, + y: 607, + }, + adjacent: [ 30 ], + ascii_name: "Czech Writers", + }, + { + name_unique: "Brno", + space_id: 32, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 1, + country: "Czechoslovakia", + region: "Eastern Europe", + box: { + x: 403, + y: 711, + }, + adjacent: [ 29, 33, 34 ], + ascii_name: "Brno", + }, + { + name_unique: "Ostrava", + space_id: 33, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Czechoslovakia", + region: "Eastern Europe", + box: { + x: 523, + y: 681, + }, + adjacent: [ 22, 32, 34, 35 ], + ascii_name: "Ostrava", + }, + { + name_unique: "Bratislava", + space_id: 34, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Czechoslovakia", + region: "Eastern Europe", + box: { + x: 417, + y: 797, + }, + adjacent: [ 32, 33, 35 ], + ascii_name: "Bratislava", + }, + { + name_unique: "Catholic Church, Czechoslovakia", + space_id: 35, + socio: 7, + stability: 5, + battleground: 0, + demInfl: 1, + comInfl: 0, + country: "Czechoslovakia", + region: "Eastern Europe", + box: { + x: 538, + y: 794, + }, + adjacent: [ 33, 34, 36 ], + ascii_name: "Catholic Church, Czechoslovakia", + }, + { + name_unique: "Prešov", + space_id: 36, + socio: 3, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Czechoslovakia", + region: "Eastern Europe", + box: { + x: 658, + y: 794, + }, + adjacent: [ 35, 37 ], + ascii_name: "Presov", + }, + { + name_unique: "Košice", + space_id: 37, + socio: 3, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Czechoslovakia", + region: "Eastern Europe", + box: { + x: 777, + y: 815, + }, + adjacent: [ 36, 42 ], + ascii_name: "Kosice", + }, + { + name_unique: "Catholic Church, Hungary", + space_id: 38, + socio: 7, + stability: 5, + battleground: 0, + demInfl: 1, + comInfl: 0, + country: "Hungary", + region: "Eastern Europe", + box: { + x: 314, + y: 886, + }, + adjacent: [ 39, 43 ], + ascii_name: "Catholic Church, Hungary", + }, + { + name_unique: "Győr", + space_id: 39, + socio: 4, + stability: 3, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Hungary", + region: "Eastern Europe", + box: { + x: 434, + y: 887, + }, + adjacent: [ 38, 40, 43, 44 ], + ascii_name: "Gyor", + }, + { + name_unique: "Tatabánya", + space_id: 40, + socio: 4, + stability: 3, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Hungary", + region: "Eastern Europe", + box: { + x: 549, + y: 886, + }, + adjacent: [ 39, 41, 45 ], + ascii_name: "Tatabanya", + }, + { + name_unique: "Miskolc", + space_id: 41, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Hungary", + region: "Eastern Europe", + box: { + x: 664, + y: 901, + }, + adjacent: [ 40, 42, 45 ], + ascii_name: "Miskolc", + }, + { + name_unique: "Debrecen", + space_id: 42, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Hungary", + region: "Eastern Europe", + box: { + x: 781, + y: 938, + }, + adjacent: [ 37, 41 ], + ascii_name: "Debrecen", + }, + { + name_unique: "Szombathely", + space_id: 43, + socio: 1, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 1, + country: "Hungary", + region: "Eastern Europe", + box: { + x: 316, + y: 963, + }, + adjacent: [ 38, 39, 44 ], + ascii_name: "Szombathely", + }, + { + name_unique: "Székesfehérvár", + space_id: 44, + socio: 4, + stability: 3, + battleground: 0, + demInfl: 1, + comInfl: 0, + country: "Hungary", + region: "Eastern Europe", + box: { + x: 442, + y: 962, + }, + adjacent: [ 39, 43, 45 ], + ascii_name: "Szekesfehervar", + }, + { + name_unique: "Budapest", + space_id: 45, + socio: 2, + stability: 3, + battleground: 1, + demInfl: 1, + comInfl: 0, + country: "Hungary", + region: "Eastern Europe", + box: { + x: 630, + y: 983, + }, + adjacent: [ 40, 41, 44, 47, 48 ], + ascii_name: "Budapest", + }, + { + name_unique: "Hungarian Writers", + space_id: 46, + socio: 5, + stability: 2, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Hungary", + region: "Eastern Europe", + box: { + x: 348, + y: 1040, + }, + adjacent: [ 47 ], + ascii_name: "Hungarian Writers", + }, + { + name_unique: "Eötvös Loránd University", + space_id: 47, + socio: 6, + stability: 1, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Hungary", + region: "Eastern Europe", + box: { + x: 512, + y: 1034, + }, + adjacent: [ 46, 45 ], + ascii_name: "Eotvos Lorand University", + }, + { + name_unique: "Szeged", + space_id: 48, + socio: 3, + stability: 4, + battleground: 1, + demInfl: 1, + comInfl: 0, + country: "Hungary", + region: "Eastern Europe", + box: { + x: 632, + y: 1073, + }, + adjacent: [ 45, 49, 50 ], + ascii_name: "Szeged", + }, + { + name_unique: "Pécs", + space_id: 49, + socio: 3, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Hungary", + region: "Eastern Europe", + box: { + x: 486, + y: 1105, + }, + adjacent: [ 48 ], + ascii_name: "Pecs", + }, + { + name_unique: "Timişoara", + space_id: 50, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Romania", + region: "Balkans", + box: { + x: 597, + y: 1204, + }, + adjacent: [ 48, 51, 60 ], + ascii_name: "Timisoara", + }, + { + name_unique: "Cluj-Napoca", + space_id: 51, + socio: 1, + stability: 4, + battleground: 1, + demInfl: 0, + comInfl: 2, + country: "Romania", + region: "Balkans", + box: { + x: 756, + y: 1125, + }, + adjacent: [ 50, 54, 58, 61 ], + ascii_name: "Cluj-Napoca", + }, + { + name_unique: "Târgu Mureş", + space_id: 52, + socio: 3, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Romania", + region: "Balkans", + box: { + x: 915, + y: 1136, + }, + adjacent: [ 53, 56 ], + ascii_name: "Targu Mures", + }, + { + name_unique: "Iaşi", + space_id: 53, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Romania", + region: "Balkans", + box: { + x: 1072, + y: 1097, + }, + adjacent: [ 52, 57, 62 ], + ascii_name: "Iasi", + }, + { + name_unique: "Babeş-Bolyai University", + space_id: 54, + socio: 6, + stability: 1, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Romania", + region: "Balkans", + box: { + x: 746, + y: 1203, + }, + adjacent: [ 51, 55 ], + ascii_name: "Babes-Bolyai University", + }, + { + name_unique: "Romanian Writers", + space_id: 55, + socio: 5, + stability: 2, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Romania", + region: "Balkans", + box: { + x: 739, + y: 1278, + }, + adjacent: [ 54 ], + ascii_name: "Romanian Writers", + }, + { + name_unique: "Harghita/Covasna", + space_id: 56, + socio: 8, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Romania", + region: "Balkans", + box: { + x: 928, + y: 1227, + }, + adjacent: [ 52 ], + ascii_name: "Harghita/Covasna", + }, + { + name_unique: "Braşov", + space_id: 57, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Romania", + region: "Balkans", + box: { + x: 1049, + y: 1225, + }, + adjacent: [ 53, 59, 61 ], + ascii_name: "Brasov", + }, + { + name_unique: "Orthodox Church, Romania", + space_id: 58, + socio: 7, + stability: 3, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Romania", + region: "Balkans", + box: { + x: 855, + y: 1338, + }, + adjacent: [ 51, 60 ], + ascii_name: "Orthodox Church, Romania", + }, + { + name_unique: "Ploieşti", + space_id: 59, + socio: 4, + stability: 3, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Romania", + region: "Balkans", + box: { + x: 1061, + y: 1316, + }, + adjacent: [ 57, 61, 62 ], + ascii_name: "Ploiesti", + }, + { + name_unique: "Craiova", + space_id: 60, + socio: 3, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Romania", + region: "Balkans", + box: { + x: 763, + y: 1411, + }, + adjacent: [ 50, 58, 61 ], + ascii_name: "Craiova", + }, + { + name_unique: "Bucureşti", + space_id: 61, + socio: 2, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 2, + country: "Romania", + region: "Balkans", + box: { + x: 929, + y: 1445, + }, + adjacent: [ 51, 57, 59, 60, 63 ], + ascii_name: "Bucuresti", + }, + { + name_unique: "Galaţi", + space_id: 62, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Romania", + region: "Balkans", + box: { + x: 1104, + y: 1399, + }, + adjacent: [ 53, 59, 63 ], + ascii_name: "Galati", + }, + { + name_unique: "Constanţa", + space_id: 63, + socio: 4, + stability: 3, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Romania", + region: "Balkans", + box: { + x: 1130, + y: 1517, + }, + adjacent: [ 61, 62, 72 ], + ascii_name: "Constanta", + }, + { + name_unique: "Pleven", + space_id: 64, + socio: 3, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Bulgaria", + region: "Balkans", + box: { + x: 764, + y: 1534, + }, + adjacent: [ 68 ], + ascii_name: "Pleven", + }, + { + name_unique: "Orthodox Church, Bulgaria", + space_id: 65, + socio: 7, + stability: 3, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Bulgaria", + region: "Balkans", + box: { + x: 882, + y: 1540, + }, + adjacent: [ 66, 68 ], + ascii_name: "Orthodox Church, Bulgaria", + }, + { + name_unique: "Ruse", + space_id: 66, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Bulgaria", + region: "Balkans", + box: { + x: 998, + y: 1540, + }, + adjacent: [ 65, 69, 70, 71, 72 ], + ascii_name: "Ruse", + }, + { + name_unique: "Sofia University", + space_id: 67, + socio: 6, + stability: 1, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Bulgaria", + region: "Balkans", + box: { + x: 645, + y: 1650, + }, + adjacent: [ 68, 73 ], + ascii_name: "Sofia University", + }, + { + name_unique: "Sofia", + space_id: 68, + socio: 2, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 2, + country: "Bulgaria", + region: "Balkans", + box: { + x: 768, + y: 1653, + }, + adjacent: [ 64, 65, 67, 69, 74 ], + ascii_name: "Sofia", + }, + { + name_unique: "Stara Zagora", + space_id: 69, + socio: 1, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 1, + country: "Bulgaria", + region: "Balkans", + box: { + x: 886, + y: 1694, + }, + adjacent: [ 66, 68, 71 ], + ascii_name: "Stara Zagora", + }, + { + name_unique: "Razgrad", + space_id: 70, + socio: 8, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Bulgaria", + region: "Balkans", + box: { + x: 954, + y: 1620, + }, + adjacent: [ 66 ], + ascii_name: "Razgrad", + }, + { + name_unique: "Burgas", + space_id: 71, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Bulgaria", + region: "Balkans", + box: { + x: 1004, + y: 1695, + }, + adjacent: [ 66, 69, 72 ], + ascii_name: "Burgas", + }, + { + name_unique: "Varna", + space_id: 72, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Bulgaria", + region: "Balkans", + box: { + x: 1086, + y: 1613, + }, + adjacent: [ 63, 66, 71 ], + ascii_name: "Varna", + }, + { + name_unique: "Bulgarian Writers", + space_id: 73, + socio: 5, + stability: 2, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Bulgaria", + region: "Balkans", + box: { + x: 652, + y: 1726, + }, + adjacent: [ 67 ], + ascii_name: "Bulgarian Writers", + }, + { + name_unique: "Plovdiv", + space_id: 74, + socio: 4, + stability: 3, + battleground: 1, + demInfl: 0, + comInfl: 0, + country: "Bulgaria", + region: "Balkans", + box: { + x: 771, + y: 1739, + }, + adjacent: [ 68, 75 ], + ascii_name: "Plovdiv", + }, + { + name_unique: "Sliven", + space_id: 75, + socio: 3, + stability: 4, + battleground: 0, + demInfl: 0, + comInfl: 0, + country: "Bulgaria", + region: "Balkans", + box: { + x: 894, + y: 1768, + }, + adjacent: [ 74 ], + ascii_name: "Sliven", + }, ] const cards = [ @@ -249,5 +1449,4 @@ null, {number: 54, name: 'Petition', value: 3, socio: 0, url: 'ps10'}, ] - if (typeof module !== 'undefined') module.exports = { spaces, cards, power_cards } diff --git a/gencode.js b/gencode.js deleted file mode 100644 index 6e66a02..0000000 --- a/gencode.js +++ /dev/null @@ -1,107 +0,0 @@ -"use strict" - -let fs = require("fs") - -let pc = 0 - -function tokenize(s) { - let list = [] - let p = 0, - n = s.length - while (p < n) { - while (p < n && s[p] === " ") - ++p - if (p < n) { - let m = p - while (p < n && s[p] !== " ") { - let q = s[p++] - switch (q) { - case "(": - case "[": - case "{": - for (let x = 1; p < n && x > 0; ++p) { - switch (s[p]) { - case "(": - case "[": - case "{": - ++x - break - case ")": - case "]": - case "}": - --x - break - } - } - break - case '"': - case "'": - case "`": - while (p < n && s[p] !== q) - ++p - break - } - } - list.push(s.substring(m, p)) - } - } - return list -} - -function emit(line) { - ++pc - line[0] = "vm_" + line[0] - for (let i = 1; i < line.length; ++i) { - if (typeof line[i] === "string") { - if (line[i] === "all") - line[i] = 999 - if (line[i][0] === "(" && !line[i].match(/\)=>/)) - line[i] = "()=>" + line[i] - if (line[i][0] === "`") - line[i] = "()=>" + line[i] - } - } - console.log("\t[ " + line.join(", ") + " ],") -} - -console.log("// #region GENERATED EVENT CODE") -console.log("const CODE = []") -let first = false - -for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) { - line = line.trim() - if (line.length === 0 || line[0] === "#") - continue - if (line === "EOF") - break - line = tokenize(line) - switch (line[0]) { - case "CARD": - if (first++) { - emit(["return"]) - console.log("]") - } - console.log("") - console.log("CODE[" + line[1] + "] = [ // " + line.slice(3).join(" ")) - break - - case "log": - case "prompt": - emit([ line[0], line.slice(1).join(" ") ]) - break - - case "asm": - case "if": - case "while": - emit([ line[0], "()=>" + line.slice(1).join(" ") ]) - break - - default: - emit(line) - break - } -} - -emit(["return"]) -console.log("]") -console.log("// #endregion") \ No newline at end of file diff --git a/images/trash-can.svg b/images/trash-can.svg new file mode 100644 index 0000000..7b8da5a --- /dev/null +++ b/images/trash-can.svg @@ -0,0 +1 @@ + diff --git a/info/cards.html b/info/cards.html new file mode 100644 index 0000000..479867d --- /dev/null +++ b/info/cards.html @@ -0,0 +1,193 @@ + + + +1989 - Cards + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/play.css b/play.css index 2a65885..3b49c7b 100644 --- a/play.css +++ b/play.css @@ -1,46 +1,14 @@ -main { background-color: dimgray; } -header { background-color: silver; } -header.your_turn { background-color: orange; } -#role_Democrat { background-color: hsl(200, 80%, 80%); } -#role_Communist { background-color: hsl(0, 80%, 80%); } -#turn_info { background-color: white; } -/*.aside_events { - font-family: "Source Sans"; - font-style: normal; - font-size: 16px; - line-height: 1.5; -}*/ -#deck_data { - font-family: "Source Sans"; - font-style: normal; - font-size: 16px; - line-height: 1.5; -} -#deck_stat {padding-left: 5px; padding-bottom: 5px;} - +main { background-color: slategray; } -#log { background-color: whitesmoke; } -#log .h1 { font-weight: bold; padding-top:2px; padding-bottom:2px; text-align: center; } -#log .h2 { padding-top:2px; padding-bottom:2px; text-align: center; } -#log .h3 { text-align: center; } -#log .h4 { text-decoration: underline; } -#log .h5 { text-decoration: underline; } +body.Democrat header.your_turn { background-color: hsl(206, 85%, 75%); } +body.Communist header.your_turn { background-color: hsl(355, 70%, 75%); } -#log .h2 { background-color: hsl(0,0%,80%);} -#log .h1 { background-color: hsl(0,0%,80%); } -#log .h2.dem { background-color: hsl(200, 80%, 80%); } -#log .h2.com { background-color: hsl(0, 80%, 80%); } -#log .h3.democrat { background-color: hsl(210,30%,90%); } -#log .h3.h2.communist { background-color: hsl(35,40%,90%); } +#role_Democrat { background-color: hsl(206, 80%, 80%); } +#role_Communist { background-color: hsl(355, 70%, 80%); } -#log div { padding-left: 20px; text-indent: -12px; } -#log div.i { padding-left: 32px; text-indent: -12px; } -#log div.ii { padding-left: 44px; text-indent: -12px; } +/* LOG */ - -#log .card_name { font-style: italic; } -#log .card_name:hover { text-decoration: underline; } -#log .space_tip:hover { cursor: pointer; text-decoration: underline; } +#log { font-variant-numeric: tabular-nums; } #log .die { display: inline-block; @@ -62,555 +30,212 @@ header.your_turn { background-color: orange; } #log .d5 { background-position: 80% 0; } #log .d6 { background-position: 100% 0; } -.selected { - cursor: pointer; -} +#log .h1 { font-weight: bold; padding-top:2px; padding-bottom:2px; text-align: center; } +#log .h2 { padding-top:2px; padding-bottom:2px; text-align: center; } +#log .h3 { text-align: center; } +#log .h4 { text-decoration: underline; } +#log .h5 { text-decoration: underline; } -#log { - font-variant-numeric: tabular-nums; -} +#log { background-color: floralwhite } +#log .h1 { background-color: tan } +#log .h2 { background-color: wheat } +#log .h2.dem { background-color: hsl(206, 85%, 80%); } +#log .h2.com { background-color: hsl(355, 70%, 80%); } -/* TOOLBAR */ +#log div { padding-left: 20px; text-indent: -12px; } +#log div.i { padding-left: 32px; text-indent: -12px; } +#log div.ii { padding-left: 44px; text-indent: -12px; } -#toolbar { - justify-content: space-evenly; -} +#log .card_name { font-style: italic; } +#log .card_name:hover { text-decoration: underline; } +#log .space_tip:hover { cursor: pointer; text-decoration: underline; } -#prompt { - display: flex; - margin-left: auto; -} +/* MAP */ -#button { - display: flex; - margin-left: auto; +#mapwrap { + width: 1650px; + height: 2550px; } -/* MAP */ #map { - margin: 0 auto ; - position: relative; - background-repeat: no-repeat; - background-size: cover; - width: 1275px; /* was 1275*/ - height: 2000px; - /*border: solid black;*/ - overflow: clip; + width: 1650px; + height: 2550px; + background-size: 1650px 2550px; box-shadow: 0px 1px 10px #0008; - /*z-index: 3;*/ -} - -#map { background-image: url(1989_map.jpg) } - -/* Containers to appear on hover*/ - #overlay { - position: relative; - top: 0; - left: 0; - width: 100%; - height: 100%; - /* background-color: rgba(255, 255, 255, 0.8); /* Semi-transparent overlay */ - /* display: none;*/ - justify-content: center; - align-items: center; - text-align: left; - } - -/* SPACES */ - -.space-area { - position: absolute; - box-sizing: border-box; - border: transparent red 2px; -} - -/* PANELS AND HANDS */ - -.panel { - background-color: #555; - display: inline-block; -} - -.panel_header { - background-color: #444; - color: hsl(40, 60%, 90%); - font-weight: bold; - text-align: center; - padding: 3px 1em; -} - -.hide { - display: none; -} - -#hand_panel, #events_panel, #played_card_panel, #table_panel, #samizdat_panel, #opp_hand_panel, #power_panel, #ceausescu_panel { - min-width: 200px; - width: auto; - /*display: inline-block;*/ - margin: 10px; - border-radius: 5px; -} - -#events { - display: flex; -} - -#discard_panel, #removed_panel { - min-width: 200px; - width: auto; - display: inline-block; - margin: 10px; - border-radius: 5px; -} - -#discard_panel.hide, #removed_panel.hide { - display: none; -} - -#hand_panel { - margin: 10px; - border-radius: 5px; -} - -/* INFLUENCE MARKERS */ - -.demInfl { - position: absolute; - box-sizing: border-box; - bottom: 1px; - left: 6px; - height: 35px; - width: 35px; - border-radius: 5px; -} - -.demInfl.controlled { - background-image: url(images/US_blank.gif); - background-size: contain; -} - - -.demInfl.uncontrolled { - background-image: url(images/USd_blank.gif); - background-size: contain; -} -/* -.demInfl:hover { - cursor: pointer; -}*/ - -.comInfl { - position: absolute; - box-sizing: border-box; - bottom: 1px; - right: 6px; - height: 35px; - width: 35px; -} -/* -.comInfl:hover { - cursor: pointer; -}*/ - -.comInfl.controlled { - background-image: url(images/SV_blank.gif); - background-size: contain; -} - - -.comInfl.uncontrolled { - background-image: url(images/SVd_blank.gif); - background-size: contain; -} - -.demInflValue { - position: absolute; - box-sizing: border-box; - font-family: 'Open Sans'; - font-size: 20px; - font-weight: bold; - top: 10px; - left: 16px; } -.demInflValue_10 { - position: absolute; - box-sizing: border-box; - font-family: 'Open Sans'; - font-size: 20px; - font-weight: bold; - top: 10px; - left: 10px; +#map { background-image: url("map75.jpg") } +@media (min-resolution: 97dpi) { + #map { background-image: url("map150.jpg") } } -.comInflValue { - position: absolute; - box-sizing: border-box; - font-family: 'Open Sans'; - font-size: 20px; - font-weight: bold; - top: 12px; - left: 74px; -} +/* SPACES */ -.comInflValue_10 { +.space { position: absolute; box-sizing: border-box; - font-family: 'Open Sans'; - font-size: 20px; - font-weight: bold; - top: 12px; - left: 68px; + border: 4px solid transparent; } -.comInflValue.controlled, .held { - color: whitesmoke; - text-shadow: - 1px 1px 0 #c2272d, /* Right bottom */ - -1px 1px 0 #c2272d, /* Left bottom */ - 1px -1px 0 #c2272d, /* Right top */ - -1px -1px 0 #c2272d; /* Left top */ +.space.action { + border-color: white; + box-shadow: 0 0 0 1px black, inset 0 0 0 1px black; } -.comInflValue.uncontrolled { - color: #c2272d; - text-shadow: - 1px 1px 0 #ffffff, /* Right bottom */ - -1px 1px 0 #ffffff, /* Left bottom */ - 1px -1px 0 #ffffff, /* Right top */ - -1px -1px 0 #ffffff; /* Left top */ -} +.space.East_Germany.action { border-color: white; } +.space.Poland.action { border-color: yellow; } +.space.Czechoslovakia.action { border-color: lightgreen; } +.space.Hungary.action { border-color: gold; } +.space.Romania.action { border-color: peachpuff; } +.space.Bulgaria.action { border-color: palegreen; } -.comInflValue_10.controlled, .held { - color: whitesmoke; - text-shadow: - 1px 1px 0 #c2272d, /* Right bottom */ - -1px 1px 0 #c2272d, /* Left bottom */ - 1px -1px 0 #c2272d, /* Right top */ - -1px -1px 0 #c2272d; /* Left top */ +.space.tip { + border-color: lime; + box-shadow: 0 0 0 1px black, inset 0 0 0 1px black; } -.comInflValue_10.uncontrolled { - color: #c2272d; - text-shadow: - 1px 1px 0 #ffffff, /* Right bottom */ - -1px 1px 0 #ffffff, /* Left bottom */ - 1px -1px 0 #ffffff, /* Right top */ - -1px -1px 0 #ffffff; /* Left top */ -} - - -/* GAME MARKERS */ - -.t0 {left: 511px} -.t1 {left: 511px} -.t2 {left: 553px} -.t3 {left: 595px} -.t4 {left: 637px} -.t5 {left: 679px} -.t6 {left: 721px} -.t7 {left: 763px} -.t8 {left: 805px} -.t9 {left: 847px} -.t10 {left: 889px} - -#turn-tracker { - position:absolute; - top: 65px; - height: 35px; - width: 36px; - /*display: block;*/ -} - -.r0 {left: 554px} -.r1 {left: 554px} -.r2 {left: 596px} -.r3 {left: 638px} -.r4 {left: 680px} -.r5 {left: 722px} -.r6 {left: 764px} -.r7 {left: 806px} -.r8 {left: 848px} +/* MARKERS */ -.dem-action-round-tracker { background-image: url(images/US_Action_Round.gif);} -.com-action-round-tracker { background-image: url(images/SV_Action_Round.gif);} +/* node tools/gencolors.js */ +.marker { background-color: #ffffff; border-color: #eeeeee #8a8a8a #8a8a8a #eeeeee; box-shadow: 0 0 0 1px #323232, 1px 2px 4px #0008; } +.demInfl.ctl { background-color: #c4e2f6; border-color: #e6ffff #8ca8bb #8ca8bb #e6ffff; box-shadow: 0 0 0 1px #274050, 1px 2px 4px #0008; } +.comInfl.ctl { background-color: #c1272d; border-color: #e74e4c #9c0009 #9c0009 #e74e4c; box-shadow: 0 0 0 1px #520000, 1px 2px 4px #0008; } +#marker_action_round.com { background-color: #147fc0; border-color: #44a3e6 #005c9b #005c9b #44a3e6; box-shadow: 0 0 0 1px #001a54, 1px 2px 4px #0008; } +#marker_action_round.dem { background-color: #c1272d; border-color: #e74e4c #9c0009 #9c0009 #e74e4c; box-shadow: 0 0 0 1px #520000, 1px 2px 4px #0008; } +#marker_vp, #marker_turn { background-color: #fadb04; border-color: #ffff51 #c0a100 #c0a100 #ffff51; box-shadow: 0 0 0 1px #563600, 1px 2px 4px #0008; } +#marker_com_tst { background-color: #f26649; border-color: #ff9273 #c2391c #c2391c #ff9273; box-shadow: 0 0 0 1px #640000, 1px 2px 4px #0008; } +#marker_dem_tst { background-color: #c4e2f4; border-color: #e6ffff #8ca8ba #8ca8ba #e6ffff; box-shadow: 0 0 0 1px #27404f, 1px 2px 4px #0008; } -#action-round-tracker { +#event_reminder_list { position: absolute; - top: 114px; - height: 30px; - width: 35px; - background-size: cover; -} - - - -#stability-track { - position:absolute; - left: 1085px; - height: 35px; - width: 35px; -} - -.s0 {top: 853px} -.s1 {top: 896px} -.s2 {top: 939px} -.s3 {top: 982px} -.s4 {top: 1025px} - - -.tst0 {left: 0} -.tst1 {left: 38px} -.tst2 {left: 93px} -.tst3 {left: 148px} -.tst4 {left: 203px} -.tst5 {left: 258px} -.tst6 {left: 313px} -.tst7 {left: 368px} -.tst8 {left: 436px} - -#dem-TST { - position: absolute; - top: 1680px; - height: 35px; - width: 35px; -} - -#com-TST { - position: absolute; - top: 1782px; - height: 35px; - width: 35px; -} - -.vp0 {top: 1913px; -left: 660px} - -.vp-20, .vp-18, .vp-16, .vp-14, .vp-12, .vp-10, .vp-8, .vp-6, .vp-4, .vp-2, .vp1, .vp3, .vp5, .vp7, .vp9, .vp11, .vp13, .vp15, .vp17, .vp19 {top: 1889px} -.vp-19, .vp-17, .vp-15, .vp-13, .vp-11, .vp-9, .vp-7, .vp-5, .vp-3, .vp-1, .vp2, .vp4, .vp6, .vp8, .vp10, .vp12, .vp14, .vp16, .vp18, .vp20 {top: 1938px} - -.vp-21 {top: 1912px; left: 117px} -.vp21 {top: 1912px; left: 1182px} - -.vp-20 {left: 165px} -.vp-19 {left: 189px} -.vp-18 {left: 214px} -.vp-17 {left: 238px} -.vp-16 {left: 263px} -.vp-15 {left: 287px} -.vp-14 {left: 312px} -.vp-13 {left: 336px} -.vp-12 {left: 361px} -.vp-11 {left: 385px} -.vp-10 {left: 410px} -.vp-9 {left: 434px} -.vp-8 {left: 459px} -.vp-7 {left: 483px} -.vp-6 {left: 508px} -.vp-5 {left: 532px} -.vp-4 {left: 557px} -.vp-3 {left: 581px} -.vp-2 {left: 606px} -.vp-1 {left: 630px} -.vp1 {left: 692px} -.vp2 {left: 717px} -.vp3 {left: 741px} -.vp4 {left: 766px} -.vp5 {left: 790px} -.vp6 {left: 815px} -.vp7 {left: 839px} -.vp8 {left: 864px} -.vp9 {left: 888px} -.vp10 {left: 913px} -.vp11 {left: 937px} -.vp12 {left: 962px} -.vp13 {left: 986px} -.vp14 {left: 1011px} -.vp15 {left: 1035px} -.vp16 {left: 1060px} -.vp17 {left: 1084px} -.vp18 {left: 1109px} -.vp19 {left: 1133px} -.vp20 {left: 1158px} - -#vp { - position: absolute; - height: 40px; - width: 40px; + display: flex; + flex-rap: wrap; + gap: 5px; + bottom: 165px; + right: 195px; } .marker { position: absolute; - height: 30px; - width: 30px; -} - -.revolution {background-image: url(images/US_blank.gif); background-size: contain} -.held {background-image: url(images/SV_blank.gif); background-size: contain} - -.germany {top: 127px; left: 439px} -.poland { top: 232px; left: 934px} -.czech {top: 494px; left: 362px} -.hungary {top: 1041px; left: 813px} -.romania {top: 1063px; left: 1012px} -.bulgaria {top: 1578px; left: 720px} - -.times_held { - position: absolute; - font-family: 'Open Sans'; - font-size: 20px; - font-weight: bold; - top: -18px; - left: 8px -} - -.outlined_text { - text-shadow: - 1px 1px 0 #ffffff, /* Right bottom */ - -1px 1px 0 #ffffff, /* Left bottom */ - 1px -1px 0 #ffffff, /* Right top */ - -1px -1px 0 #ffffff; /* Left top */ -} - -/* ============= EVENT MARKERS ========== */ - -.event-marker { - display: none; - position: absolute; - height: 30px; - width: 30px; - transition: transform 0.3s ease; -} - -.event-marker:hover { - cursor: pointer; - transform: scale(2); - z-index: 1; -} - -.event-marker.aside { - border: solid black 1.5px; - margin: 3px; - position: relative; -} - -#turn_info { - display: flex; - flex-direction: column; - align-items: flex-start; -} - -#turn_info > div { - display: flex; - margin-bottom: 8px; - gap: 4px; -} - -#turn_info > img { - display: block; - -} - -/*Solidarity legalised*/ -#event_2 { - top: 216px; - left: 612px; -} - -/*Systematisation*/ -#event_69 { - height: 65px; - width: 65px; -} + pointer-events: none; + width: 45px; + height: 45px; + border: 2px solid; + border-color: #eee #bbb #bbb #eee; + /* TODO: per marker border color */ + box-shadow: 0 0 0 1px #444; + //border-radius: 8px; +} + +.demInfl { background-color: #fff; } +.comInfl { background-color: #fff; } +.demInfl.ctl { background-color: #147fc0; } +.comInfl.ctl { background-color: #c1272d; } + +.demInfl.v1 { background-image: url(markers75/di1.png) } +.demInfl.v2 { background-image: url(markers75/di2.png) } +.demInfl.v3 { background-image: url(markers75/di3.png) } +.demInfl.v4 { background-image: url(markers75/di4.png) } +.demInfl.v5 { background-image: url(markers75/di5.png) } +.demInfl.v6 { background-image: url(markers75/di6.png) } +.demInfl.v7 { background-image: url(markers75/di7.png) } +.demInfl.v8 { background-image: url(markers75/di8.png) } +.demInfl.ctl.v1 { background-image: url(markers75/dc1.png) } +.demInfl.ctl.v2 { background-image: url(markers75/dc2.png) } +.demInfl.ctl.v3 { background-image: url(markers75/dc3.png) } +.demInfl.ctl.v4 { background-image: url(markers75/dc4.png) } +.demInfl.ctl.v5 { background-image: url(markers75/dc5.png) } +.demInfl.ctl.v6 { background-image: url(markers75/dc6.png) } +.demInfl.ctl.v7 { background-image: url(markers75/dc7.png) } +.demInfl.ctl.v8 { background-image: url(markers75/dc8.png) } + +.comInfl.v1 { background-image: url(markers75/ci1.png) } +.comInfl.v2 { background-image: url(markers75/ci2.png) } +.comInfl.v3 { background-image: url(markers75/ci3.png) } +.comInfl.v4 { background-image: url(markers75/ci4.png) } +.comInfl.v5 { background-image: url(markers75/ci5.png) } +.comInfl.v6 { background-image: url(markers75/ci6.png) } +.comInfl.v7 { background-image: url(markers75/ci7.png) } +.comInfl.v8 { background-image: url(markers75/ci8.png) } +.comInfl.ctl.v1 { background-image: url(markers75/cc1.png) } +.comInfl.ctl.v2 { background-image: url(markers75/cc2.png) } +.comInfl.ctl.v3 { background-image: url(markers75/cc3.png) } +.comInfl.ctl.v4 { background-image: url(markers75/cc4.png) } +.comInfl.ctl.v5 { background-image: url(markers75/cc5.png) } +.comInfl.ctl.v6 { background-image: url(markers75/cc6.png) } +.comInfl.ctl.v7 { background-image: url(markers75/cc7.png) } +.comInfl.ctl.v8 { background-image: url(markers75/cc8.png) } + +#marker_turn { background-image: url(markers75/turn.png) } +#marker_action_round.dem { background-image: url(markers75/action_round_blue.png) } +#marker_action_round.com { background-image: url(markers75/action_round_blue.png) } +#marker_stability_track { background-image: url(markers75/ussr_stability_track.png) } +#marker_dem_tst { background-image: url(markers75/ts_blue.png) } +#marker_com_tst { background-image: url(markers75/ts_red.png) } +#marker_vp { background-image: url(markers75/vp.png) } + +/* EVENT MARKERS */ + +.marker.aside { + position: static; +} + +#event_2 { background-image: url(markers75/event_solidarity_legalized.png) } +#event_9 { background-image: url(markers75/event_the_wall.png) } +#event_15 { background-image: url(markers75/event_honecker.png) } +#event_24 { background-image: url(markers75/event_st_nicholas.png) } +#event_26 { background-image: url(markers75/event_helsinki.png) } +#event_39 { background-image: url(markers75/event_eco_glasnost.png) } +#event_48 { background-image: url(markers75/event_we_are_the_people.png) } +#event_49 { background-image: url(markers75/event_foreign_currency.png) } +#event_53 { background-image: url(markers75/event_li_peng.png) } +#event_58 { background-image: url(markers75/event_austria_hungary.png) } +#event_59 { background-image: url(markers75/event_grenz_truppen.png) } +#event_65 { background-image: url(markers75/event_pres_visit.png) } +#event_69 { background-image: url(markers75/event_systematization.png) } +#event_70 { background-image: url(markers75/event_securitate.png) } +#event_73 { background-image: url(markers75/event_laszlo_tokes.png) } +#event_97 { background-image: url(markers75/event_tyrant.png) } +#event_100 { background-image: url(markers75/event_stand_fast.png) } +#event_101 { background-image: url(markers75/event_elena.png) } +#event_104 { background-image: url(markers75/event_nye_party.png) } + +/* Solidarity legalized */ +#event_2 { top: 265px; left: 778px; } + +/* The Wall */ +#event_9 { top: 175px; left: 216px; } + +/* CARD PANELS */ -/*The Tyrant is Gone*/ -#event_97 { - height: 40px; - width: 40px; +.panel { + background-color: #607080; + max-width: 1650px; + margin: 24px auto; } -/*The Wall*/ -#event_9 { - top: 143px; - left: 170px; +.panel_header { + background-color: #506070; + color: white; + font-weight: bold; + padding: 3px; + text-align: center; } - -/* =========== CARDS ================= */ -/* -.playedCard { +.panel_body { + margin-top: 3px; display: flex; - margin: auto; - height: 300px; -}*/ - -.hand_card { - background-size: contain; - height: 250px; - margin: 10px; - border-radius: 5px; - transition: transform .3s ease 0.5s; -} -/* -.hand_card:hover { - cursor: pointer; -}*/ - -.zoom { - transform: scale(1.75) -} - -.power_card { - background-size: contain; - height: 250px; - margin: 10px; - border-radius: 5px; -} - -.discard_card, .event_card { - background-size: contain; - height: 150px; - margin: 5px; - border-radius: 5px; - transition: transform .3s ease; -} - -.discard_card:hover, .event_card:hover { - /*cursor: pointer;*/ - transform: scale(2); + flex-wrap: wrap; + padding: 16px; + gap: 16px; + min-height: 350px; } -.selected.space-area { - background-color: #0002; - outline: solid white 2px; - /*box-shadow: 0 0 4px white; */ - border-radius: 10px 10px 0 0; -} - -.space-area.tip { - background-color: #ff08; - outline: solid white 2px; - box-shadow: 0 0 8px #ff08; - border-radius: 10px 10px 0 0; -} - -.selected.hand_card { - outline: solid silver 3px; - /*box-shadow: 0 0 4px white; */ - border-radius: 18px; -} - - -.selected.power_card { - outline: solid silver 3px; - /*box-shadow: 0 0 4px white; */ - border-radius: 18px; +.panel:has(.panel_body:empty) { + display: none; } -/* =============== OTHER ===============*/ -#space-characteristics {display: none} - -/* =============== CARD IMAGES =========*/ +/* CARD IMAGES */ #tooltip { position: fixed; @@ -626,116 +251,179 @@ left: 660px} width: 250px; height: 350px; border-radius: 16px; - box-shadow: 1px 2px 4px #0004; -} - -.card_1 {background-image: url(cards/e1.gif)} -.card_2 {background-image: url(cards/e2.gif)} -.card_3 {background-image: url(cards/e3.gif)} -.card_4 {background-image: url(cards/e4.gif)} -.card_5 {background-image: url(cards/e5.gif)} -.card_6 {background-image: url(cards/e6.gif)} -.card_7 {background-image: url(cards/e7.gif)} -.card_8 {background-image: url(cards/e8.gif)} -.card_9 {background-image: url(cards/e9.gif)} -.card_10 {background-image: url(cards/e10.gif)} -.card_11 {background-image: url(cards/e11.gif)} -.card_12 {background-image: url(cards/e12.gif)} -.card_13 {background-image: url(cards/e13.gif)} -.card_14 {background-image: url(cards/e14.gif)} -.card_15 {background-image: url(cards/e15.gif)} -.card_16 {background-image: url(cards/e16.gif)} -.card_17 {background-image: url(cards/e17.gif)} -.card_18 {background-image: url(cards/e18.gif)} -.card_19 {background-image: url(cards/e19.gif)} -.card_20 {background-image: url(cards/e20.gif)} -.card_21 {background-image: url(cards/e21.gif)} -.card_22 {background-image: url(cards/e22.gif)} -.card_23 {background-image: url(cards/e23.gif)} -.card_24 {background-image: url(cards/e24.gif)} -.card_25 {background-image: url(cards/e25.gif)} -.card_26 {background-image: url(cards/e26.gif)} -.card_27 {background-image: url(cards/e27.gif)} -.card_28 {background-image: url(cards/e28.gif)} -.card_29 {background-image: url(cards/e29.gif)} -.card_30 {background-image: url(cards/e30.gif)} -.card_31 {background-image: url(cards/e31.gif)} -.card_32 {background-image: url(cards/e32.gif)} -.card_33 {background-image: url(cards/e33.gif)} -.card_34 {background-image: url(cards/e34.gif)} -.card_35 {background-image: url(cards/e35.gif)} -.card_36 {background-image: url(cards/e36.gif)} -.card_37 {background-image: url(cards/e37.gif)} -.card_38 {background-image: url(cards/e38.gif)} -.card_39 {background-image: url(cards/e39.gif)} -.card_40 {background-image: url(cards/e40.gif)} -.card_41 {background-image: url(cards/e41.gif)} -.card_42 {background-image: url(cards/e42.gif)} -.card_43 {background-image: url(cards/e43.gif)} -.card_44 {background-image: url(cards/e44.gif)} -.card_45 {background-image: url(cards/e45.gif)} -.card_46 {background-image: url(cards/e46.gif)} -.card_47 {background-image: url(cards/e47.gif)} -.card_48 {background-image: url(cards/e48.gif)} -.card_49 {background-image: url(cards/e49.gif)} -.card_50 {background-image: url(cards/e50.gif)} -.card_51 {background-image: url(cards/e51.gif)} -.card_52 {background-image: url(cards/e52.gif)} -.card_53 {background-image: url(cards/e53.gif)} -.card_54 {background-image: url(cards/e54.gif)} -.card_55 {background-image: url(cards/e55.gif)} -.card_56 {background-image: url(cards/e56.gif)} -.card_57 {background-image: url(cards/e57.gif)} -.card_58 {background-image: url(cards/e58.gif)} -.card_59 {background-image: url(cards/e59.gif)} -.card_60 {background-image: url(cards/e60.gif)} -.card_61 {background-image: url(cards/e61.gif)} -.card_62 {background-image: url(cards/e62.gif)} -.card_63 {background-image: url(cards/e63.gif)} -.card_64 {background-image: url(cards/e64.gif)} -.card_65 {background-image: url(cards/e65.gif)} -.card_66 {background-image: url(cards/e66.gif)} -.card_67 {background-image: url(cards/e67.gif)} -.card_68 {background-image: url(cards/e68.gif)} -.card_69 {background-image: url(cards/e69.gif)} -.card_70 {background-image: url(cards/e70.gif)} -.card_71 {background-image: url(cards/e71.gif)} -.card_72 {background-image: url(cards/e72.gif)} -.card_73 {background-image: url(cards/e73.gif)} -.card_74 {background-image: url(cards/e74.gif)} -.card_75 {background-image: url(cards/e75.gif)} -.card_76 {background-image: url(cards/e76.gif)} -.card_77 {background-image: url(cards/e77.gif)} -.card_78 {background-image: url(cards/e78.gif)} -.card_79 {background-image: url(cards/e79.gif)} -.card_80 {background-image: url(cards/e80.gif)} -.card_81 {background-image: url(cards/e81.gif)} -.card_82 {background-image: url(cards/e82.gif)} -.card_83 {background-image: url(cards/e83.gif)} -.card_84 {background-image: url(cards/e84.gif)} -.card_85 {background-image: url(cards/e85.gif)} -.card_86 {background-image: url(cards/e86.gif)} -.card_87 {background-image: url(cards/e87.gif)} -.card_88 {background-image: url(cards/e88.gif)} -.card_89 {background-image: url(cards/e89.gif)} -.card_90 {background-image: url(cards/e90.gif)} -.card_91 {background-image: url(cards/e91.gif)} -.card_92 {background-image: url(cards/e92.gif)} -.card_93 {background-image: url(cards/e93.gif)} -.card_94 {background-image: url(cards/e94.gif)} -.card_95 {background-image: url(cards/e95.gif)} -.card_96 {background-image: url(cards/e96.gif)} -.card_97 {background-image: url(cards/e97.gif)} -.card_98 {background-image: url(cards/e98.gif)} -.card_99 {background-image: url(cards/e99.gif)} -.card_100 {background-image: url(cards/e100.gif)} -.card_101 {background-image: url(cards/e101.gif)} -.card_102 {background-image: url(cards/e102.gif)} -.card_103 {background-image: url(cards/e103.gif)} -.card_104 {background-image: url(cards/e104.gif)} -.card_105 {background-image: url(cards/e105.gif)} -.card_106 {background-image: url(cards/e106.gif)} -.card_107 {background-image: url(cards/e107.gif)} -.card_108 {background-image: url(cards/e108.gif)} -.card_109 {background-image: url(cards/e109.gif)} -.card_110 {background-image: url(cards/e110.gif)} + box-shadow: 0 0 0 1px #444, 1px 2px 4px #0004; +} + +.card.action { + box-shadow: 0 0 0 1px #444, 0 0 0 4px white; +} + +.card.selected { + box-shadow: 0 0 0 1px #444, 0 0 0 4px yellow; +} + +.card.event_0 { background-image: url(cards100/event_back.webp) } +.card.event_1 { background-image: url(cards100/event_1.webp) } +.card.event_2 { background-image: url(cards100/event_2.webp) } +.card.event_3 { background-image: url(cards100/event_3.webp) } +.card.event_4 { background-image: url(cards100/event_4.webp) } +.card.event_5 { background-image: url(cards100/event_5.webp) } +.card.event_6 { background-image: url(cards100/event_6.webp) } +.card.event_7 { background-image: url(cards100/event_7.webp) } +.card.event_8 { background-image: url(cards100/event_8.webp) } +.card.event_9 { background-image: url(cards100/event_9.webp) } +.card.event_10 { background-image: url(cards100/event_10.webp) } +.card.event_11 { background-image: url(cards100/event_11.webp) } +.card.event_12 { background-image: url(cards100/event_12.webp) } +.card.event_13 { background-image: url(cards100/event_13.webp) } +.card.event_14 { background-image: url(cards100/event_14.webp) } +.card.event_15 { background-image: url(cards100/event_15.webp) } +.card.event_16 { background-image: url(cards100/event_16.webp) } +.card.event_17 { background-image: url(cards100/event_17.webp) } +.card.event_18 { background-image: url(cards100/event_18.webp) } +.card.event_19 { background-image: url(cards100/event_19.webp) } +.card.event_20 { background-image: url(cards100/event_20.webp) } +.card.event_21 { background-image: url(cards100/event_21.webp) } +.card.event_22 { background-image: url(cards100/event_22.webp) } +.card.event_23 { background-image: url(cards100/event_23.webp) } +.card.event_24 { background-image: url(cards100/event_24.webp) } +.card.event_25 { background-image: url(cards100/event_25.webp) } +.card.event_26 { background-image: url(cards100/event_26.webp) } +.card.event_27 { background-image: url(cards100/event_27.webp) } +.card.event_28 { background-image: url(cards100/event_28.webp) } +.card.event_29 { background-image: url(cards100/event_29.webp) } +.card.event_30 { background-image: url(cards100/event_30.webp) } +.card.event_31 { background-image: url(cards100/event_31.webp) } +.card.event_32 { background-image: url(cards100/event_32.webp) } +.card.event_33 { background-image: url(cards100/event_33.webp) } +.card.event_34 { background-image: url(cards100/event_34.webp) } +.card.event_35 { background-image: url(cards100/event_35.webp) } +.card.event_36 { background-image: url(cards100/event_36.webp) } +.card.event_37 { background-image: url(cards100/event_37.webp) } +.card.event_38 { background-image: url(cards100/event_38.webp) } +.card.event_39 { background-image: url(cards100/event_39.webp) } +.card.event_40 { background-image: url(cards100/event_40.webp) } +.card.event_41 { background-image: url(cards100/event_41.webp) } +.card.event_42 { background-image: url(cards100/event_42.webp) } +.card.event_43 { background-image: url(cards100/event_43.webp) } +.card.event_44 { background-image: url(cards100/event_44.webp) } +.card.event_45 { background-image: url(cards100/event_45.webp) } +.card.event_46 { background-image: url(cards100/event_46.webp) } +.card.event_47 { background-image: url(cards100/event_47.webp) } +.card.event_48 { background-image: url(cards100/event_48.webp) } +.card.event_49 { background-image: url(cards100/event_49.webp) } +.card.event_50 { background-image: url(cards100/event_50.webp) } +.card.event_51 { background-image: url(cards100/event_51.webp) } +.card.event_52 { background-image: url(cards100/event_52.webp) } +.card.event_53 { background-image: url(cards100/event_53.webp) } +.card.event_54 { background-image: url(cards100/event_54.webp) } +.card.event_55 { background-image: url(cards100/event_55.webp) } +.card.event_56 { background-image: url(cards100/event_56.webp) } +.card.event_57 { background-image: url(cards100/event_57.webp) } +.card.event_58 { background-image: url(cards100/event_58.webp) } +.card.event_59 { background-image: url(cards100/event_59.webp) } +.card.event_60 { background-image: url(cards100/event_60.webp) } +.card.event_61 { background-image: url(cards100/event_61.webp) } +.card.event_62 { background-image: url(cards100/event_62.webp) } +.card.event_63 { background-image: url(cards100/event_63.webp) } +.card.event_64 { background-image: url(cards100/event_64.webp) } +.card.event_65 { background-image: url(cards100/event_65.webp) } +.card.event_66 { background-image: url(cards100/event_66.webp) } +.card.event_67 { background-image: url(cards100/event_67.webp) } +.card.event_68 { background-image: url(cards100/event_68.webp) } +.card.event_69 { background-image: url(cards100/event_69.webp) } +.card.event_70 { background-image: url(cards100/event_70.webp) } +.card.event_71 { background-image: url(cards100/event_71.webp) } +.card.event_72 { background-image: url(cards100/event_72.webp) } +.card.event_73 { background-image: url(cards100/event_73.webp) } +.card.event_74 { background-image: url(cards100/event_74.webp) } +.card.event_75 { background-image: url(cards100/event_75.webp) } +.card.event_76 { background-image: url(cards100/event_76.webp) } +.card.event_77 { background-image: url(cards100/event_77.webp) } +.card.event_78 { background-image: url(cards100/event_78.webp) } +.card.event_79 { background-image: url(cards100/event_79.webp) } +.card.event_80 { background-image: url(cards100/event_80.webp) } +.card.event_81 { background-image: url(cards100/event_81.webp) } +.card.event_82 { background-image: url(cards100/event_82.webp) } +.card.event_83 { background-image: url(cards100/event_83.webp) } +.card.event_84 { background-image: url(cards100/event_84.webp) } +.card.event_85 { background-image: url(cards100/event_85.webp) } +.card.event_86 { background-image: url(cards100/event_86.webp) } +.card.event_87 { background-image: url(cards100/event_87.webp) } +.card.event_88 { background-image: url(cards100/event_88.webp) } +.card.event_89 { background-image: url(cards100/event_89.webp) } +.card.event_90 { background-image: url(cards100/event_90.webp) } +.card.event_91 { background-image: url(cards100/event_91.webp) } +.card.event_92 { background-image: url(cards100/event_92.webp) } +.card.event_93 { background-image: url(cards100/event_93.webp) } +.card.event_94 { background-image: url(cards100/event_94.webp) } +.card.event_95 { background-image: url(cards100/event_95.webp) } +.card.event_96 { background-image: url(cards100/event_96.webp) } +.card.event_97 { background-image: url(cards100/event_97.webp) } +.card.event_98 { background-image: url(cards100/event_98.webp) } +.card.event_99 { background-image: url(cards100/event_99.webp) } +.card.event_100 { background-image: url(cards100/event_100.webp) } +.card.event_101 { background-image: url(cards100/event_101.webp) } +.card.event_102 { background-image: url(cards100/event_102.webp) } +.card.event_103 { background-image: url(cards100/event_103.webp) } +.card.event_104 { background-image: url(cards100/event_104.webp) } +.card.event_105 { background-image: url(cards100/event_105.webp) } +.card.event_106 { background-image: url(cards100/event_106.webp) } +.card.event_107 { background-image: url(cards100/event_107.webp) } +.card.event_108 { background-image: url(cards100/event_108.webp) } +.card.event_109 { background-image: url(cards100/event_109.webp) } +.card.event_110 { background-image: url(cards100/event_110.webp) } + +.card.power_0 { background-image: url(cards100/power_back.webp) } +.card.power_1 { background-image: url(cards100/power_1.webp) } +.card.power_2 { background-image: url(cards100/power_2.webp) } +.card.power_3 { background-image: url(cards100/power_3.webp) } +.card.power_4 { background-image: url(cards100/power_4.webp) } +.card.power_5 { background-image: url(cards100/power_5.webp) } +.card.power_6 { background-image: url(cards100/power_6.webp) } +.card.power_7 { background-image: url(cards100/power_7.webp) } +.card.power_8 { background-image: url(cards100/power_8.webp) } +.card.power_9 { background-image: url(cards100/power_9.webp) } +.card.power_10 { background-image: url(cards100/power_10.webp) } +.card.power_11 { background-image: url(cards100/power_11.webp) } +.card.power_12 { background-image: url(cards100/power_12.webp) } +.card.power_13 { background-image: url(cards100/power_13.webp) } +.card.power_14 { background-image: url(cards100/power_14.webp) } +.card.power_15 { background-image: url(cards100/power_15.webp) } +.card.power_16 { background-image: url(cards100/power_16.webp) } +.card.power_17 { background-image: url(cards100/power_17.webp) } +.card.power_18 { background-image: url(cards100/power_18.webp) } +.card.power_19 { background-image: url(cards100/power_19.webp) } +.card.power_20 { background-image: url(cards100/power_20.webp) } +.card.power_21 { background-image: url(cards100/power_21.webp) } +.card.power_22 { background-image: url(cards100/power_22.webp) } +.card.power_23 { background-image: url(cards100/power_23.webp) } +.card.power_24 { background-image: url(cards100/power_24.webp) } +.card.power_25 { background-image: url(cards100/power_25.webp) } +.card.power_26 { background-image: url(cards100/power_26.webp) } +.card.power_27 { background-image: url(cards100/power_27.webp) } +.card.power_28 { background-image: url(cards100/power_28.webp) } +.card.power_29 { background-image: url(cards100/power_29.webp) } +.card.power_30 { background-image: url(cards100/power_30.webp) } +.card.power_31 { background-image: url(cards100/power_31.webp) } +.card.power_32 { background-image: url(cards100/power_32.webp) } +.card.power_33 { background-image: url(cards100/power_33.webp) } +.card.power_34 { background-image: url(cards100/power_34.webp) } +.card.power_35 { background-image: url(cards100/power_35.webp) } +.card.power_36 { background-image: url(cards100/power_36.webp) } +.card.power_37 { background-image: url(cards100/power_37.webp) } +.card.power_38 { background-image: url(cards100/power_38.webp) } +.card.power_39 { background-image: url(cards100/power_39.webp) } +.card.power_40 { background-image: url(cards100/power_40.webp) } +.card.power_41 { background-image: url(cards100/power_41.webp) } +.card.power_42 { background-image: url(cards100/power_42.webp) } +.card.power_43 { background-image: url(cards100/power_43.webp) } +.card.power_44 { background-image: url(cards100/power_44.webp) } +.card.power_45 { background-image: url(cards100/power_45.webp) } +.card.power_46 { background-image: url(cards100/power_46.webp) } +.card.power_47 { background-image: url(cards100/power_47.webp) } +.card.power_48 { background-image: url(cards100/power_48.webp) } +.card.power_49 { background-image: url(cards100/power_49.webp) } +.card.power_50 { background-image: url(cards100/power_50.webp) } +.card.power_51 { background-image: url(cards100/power_51.webp) } +.card.power_52 { background-image: url(cards100/power_52.webp) } diff --git a/play.html b/play.html index e09e214..eb2f495 100644 --- a/play.html +++ b/play.html @@ -7,204 +7,140 @@ 1989 - - - +
- + + +
  • Rules of Play +
  • Background Book +
  • Reference Sheets +
  • +
  • Card Gallery +
  • +
    +
    + -
  • Rules of Play -
  • Background Book -
  • Reference Sheets - +
  • Show removed events +
  • Show discard
  • - - -
    -
    - - -
    - -
    -
    -
    -

    - -
    - - - - -
    -

    1

    -
    -

    1

    -
    -

    1

    -
    -

    1

    -
    -

    1

    -
    -

    1

    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + - - - - - - - -
    -
    +
    -
    - - - -
    -
    -
    Event Markers
    -
    - - - - - - - - - - - - - - - -
    -
    -
    + -
    -
    -
    Cards on the Table
    -
    -
    -
    +
    +
    Cards on the Table
    +
    +
    -
    -
    -
    Played Card
    -
    +
    +
    Played Card
    +
    -
    - - -
    -
    -
    Discard
    -
    -
    -
    - - -
    -
    -
    Permanently Removed Events
    -
    -
    -
    + +
    +
    Hand
    +
    +
    -
    -
    -
    Ceausescu Cards
    -
    -
    -
    -
    Power Struggle Hand
    -
    -
    -
    - - +
    +
    Ceausescu Cards
    +
    +
    +
    +
    Power Struggle Hand
    +
    +
    -
    +
    +
    Opponent Hand
    +
    +
    -
    -
    Opponent Hand
    -
    -
    - -
    +
    +
    Opponent Power Struggle Hand
    +
    +
    -
    -
    -
    Set aside card
    -
    -
    -
    - +
    +
    Samizdat Card
    +
    +
    - -
    + +
    +
    Permanently Removed Events
    +
    +
    -
    -
    Hand
    -
    + +
    +
    Discard
    +
    -
    - - diff --git a/play.js b/play.js index 5ccf136..9ac9e60 100644 --- a/play.js +++ b/play.js @@ -1,677 +1,417 @@ +"use strict" -const seed = 'none' -const scenario = 'standard' -const options = 'none' -//const rules = require("./rules") +let action_register = [] +function register_action(target, action, id) { + target.my_action = action + target.my_id = id + target.onmousedown = on_click_action + action_register.push(target) +} + +function is_action(action, arg) { + return !!(view.actions && view.actions[action] && view.actions[action].includes(arg)) +} + +function on_click_action(evt) { + if (evt.button === 0) + send_action(evt.target.my_action, evt.target.my_id) +} + +const last_space = 75 const last_card = 110 const last_power_card = 52 -let hover_timeout -const height = 65 -const width = 105 -const toolbar = document.getElementById('toolbar') -const vpMarker = document.getElementById('vp') -const counters = document.getElementById('counters') - -const countries= ['Poland', 'Hungary', 'East_Germany', 'Bulgaria', 'Czechoslovakia', 'Romania'] - -/*const aside_events = [ - "honecker", - "st_nicholas_church", - "helsinki_final_act", - "eco_glasnost", - "we_are_the_people", - "foreign_currency_debt_burden", - "li_peng", - "austria_hungary_border_reopened", - "grenztruppen", - "presidential_visit", - "securitate", - "laslzo_tokes", - "stand_fast", - "elena", - "new_years_eve_party" -]*/ -const board_events = [2, 9, 69, 97] + +const countries = [ "Poland", "Hungary", "East_Germany", "Bulgaria", "Czechoslovakia", "Romania" ] +const board_events = [ 2, 9, 69, 97 ] const box_events = [ 15, 24, 26, 39, 48, 49, 53, 58, 59, 65, 70, 73, 100, 101, 104 ] -let box_events_showing = false -let show_discard = false - -const overlay = document.getElementById('overlay'); -const spaceNameElement = document.getElementById('space-name'); -const spaceCharacteristicsElement = document.getElementById('space-characteristics'); - - -// Event listener to track mouse movement over the map - document.querySelector('.map').addEventListener('mousemove', function(event) { - const x = event.offsetX; // X-coordinate of mouse relative to container - const y = event.offsetY; // Y-coordinate of mouse relative to container - spaceCharacteristicsElement.innerText = `X: ${x}, Y: ${y}`; - }) - - - // Create map areas dynamically based on coordinates - - function create_ui() { - -// CREATE MAP - - spaces.forEach((space) => { - - - if (space && space.box) { - - //CREATE SPACES - const { x, y} = space.box; - const spaceArea = document.createElement('div'); - spaceArea.classList.add('space-area', space.country) - spaceArea.id=`space_${space.space_id}`; - spaceArea.style.left = x + 'px'; - spaceArea.style.top = y + 'px'; - spaceArea.style.width = width + 'px'; - spaceArea.style.height = height + 'px'; - spaceArea.style.zIndex = 2; - spaceArea.my_space = space.space_id; - spaceArea.addEventListener('mousedown', on_click_space); - - //CREATE DEMOCRATIC INFLUENCE MARKERS FOR EACH SPACE - const dem_img = document.createElement('div') - dem_img.classList.add('demInfl', space.country) - dem_img.style.display = 'none' - dem_img.id=`${space.name_unique}_demInfl` - dem_img.style.zIndex = 1 - dem_img.my_space = space.space_id; - dem_img.addEventListener('mousedown', on_click_space); - spaceArea.appendChild(dem_img) - - //CREATE DEMOCRATIC INFLUENCE VALUES - const demInflValue = document.createElement('p') - demInflValue.className='demInflValue' - demInflValue.style.display = 'none' - demInflValue.id=`${space.name_unique}_demInflValue` - demInflValue.innerText=space.demInfl - demInflValue.style.zIndex = 1 - demInflValue.my_space = space.space_id; - demInflValue.addEventListener('mousedown', on_click_space); - spaceArea.appendChild(demInflValue) - - //CREATE COMMUNIST INFLUENCE MARKERS FOR EACH SPACE - const com_img = document.createElement('div') - com_img.className='comInfl' - com_img.style.display='none' - com_img.id=`${space.name_unique}_comInfl` - com_img.style.zIndex = 1 - com_img.my_space = space.space_id; - com_img.addEventListener('mousedown', on_click_space); - spaceArea.appendChild(com_img) - - //CREATE COMMUNIST INFLUENCE VALUES - const comInflValue = document.createElement('p') - comInflValue.className='comInflValue' - comInflValue.style.display='none' - comInflValue.id=`${space.name_unique}_comInflValue` - comInflValue.innerText=space.comInfl - comInflValue.style.zIndex = 1 - comInflValue.my_space = space.space_id; - comInflValue.addEventListener('mousedown', on_click_space); - spaceArea.appendChild(comInflValue) - //} - - counters.appendChild(spaceArea); - } - }); -// CREATE CARDS +const ui = { + favicon: document.getElementById("favicon"), + turn_info: document.getElementById("turn_info"), + + turn: document.getElementById("marker_turn"), + round: document.getElementById("marker_action_round"), + stability: document.getElementById("marker_stability_track"), + dem_tst: document.getElementById("marker_dem_tst"), + com_tst: document.getElementById("marker_com_tst"), + vp: document.getElementById("marker_vp"), + + event_reminder_list: document.getElementById("event_reminder_list"), + + played_card: document.getElementById("played_card"), + hand: document.getElementById("hand"), + power_hand: document.getElementById("power_hand"), + opp_hand: document.getElementById("opp_hand"), + opp_power_hand: document.getElementById("opp_power_hand"), + discard: document.getElementById("discard"), + removed: document.getElementById("removed"), + table_cards: document.getElementById("table_cards"), + + ceausescu_hand: document.getElementById("ceausescu_hand"), + samizdat_card: document.getElementById("samizdat_card"), +} + +function create_country(id, name) { + let [ x, y, w, h ] = LAYOUT[name] + let xc = Math.round(x + w / 2) + let yc = Math.round(y + h / 2) + + let e = document.createElement("div") + e.className = "marker demInfl" + e.style.left = xc - 25 + "px" + e.style.top = yc - 25 + "px" + ui.countries[id] = e + document.getElementById("markers").appendChild(e) +} + +function create_ui() { + ui.layout_xy = [] + ui.spaces = [] + ui.dem_inf = [] + ui.com_inf = [] + + for (let s = 1; s <= last_space; ++s) { + let info = spaces[s] + let [ x, y, w, h ] = LAYOUT[info.ascii_name] + let xc = Math.round( x + w / 2 ) + let yc = Math.round( y + h / 2 ) + x -= 6 + y -= 6 + w += 12 + h += 12 + + ui.layout_xy[s] = [ xc, yc ] + + let space_e = document.createElement("div") + register_action(space_e, "space", s) + space_e.className = "space " + info.country + space_e.style.left = x + "px" + space_e.style.top = y + "px" + space_e.style.width = w + "px" + space_e.style.height = h + "px" + ui.spaces[s] = space_e + + let com_e = document.createElement("div") + com_e.className = "marker comInfl hide" + com_e.style.left = (xc + 32 - 25) + "px" + com_e.style.top = (yc + 12 - 25) + "px" + ui.com_inf[s] = com_e + + let dem_e = document.createElement("div") + dem_e.className = "marker demInfl hide" + dem_e.style.left = (xc - 32 - 25) + "px" + dem_e.style.top = (yc + 12 - 25) + "px" + ui.dem_inf[s] = dem_e + + document.getElementById("spaces").append(space_e) + document.getElementById("markers").appendChild(com_e) + document.getElementById("markers").appendChild(dem_e) + } - const is_mobile = window.matchMedia("(pointer: coarse)").matches + ui.cards = [] for (let c = 1; c <= last_card; ++c) { + const card_e = document.createElement("div") + register_action(card_e, "card", c) + card_e.className = "card event_" + c + ui.cards[c] = card_e + } - const hand_card = document.createElement('img'); - hand_card.classList.add('hand_card') - hand_card.id=`card_${c}`; - hand_card.src = `cards/e${c}.gif` - hand_card.my_card = c; - hand_card.addEventListener('click', on_click_card); - - if(!is_mobile) { - hand_card.addEventListener('mouseenter', () => { - hover_timeout = setTimeout(() => { - hand_card.classList.add('zoom'); - }, 500) }) - hand_card.addEventListener('mouseleave', () => { - clearTimeout(hover_timeout); - hand_card.classList.remove('zoom'); - }); - } + ui.power_cards = [] + for (let c = 1; c <= last_power_card; ++c) { + const power_card_e = document.createElement("div") + register_action(power_card_e, "power_card", c) + power_card_e.className = "card power_" + c + ui.power_cards[c] = power_card_e + } - ui.cards.push(hand_card); + ui.events = [] + for (let id of box_events) { + ui.events[id] = document.createElement("div") + ui.events[id].id = "event_" + id + ui.events[id].className = "marker event aside" } - - - - for (let card of power_cards) { - if (!card) continue; - const power_card = document.createElement('img'); - power_card.classList.add('power_card'); - power_card.id = `power_card_${card.number}`; - power_card.src = `cards_2/${card.url}.gif`; - power_card.my_card = card.number; - power_card.addEventListener('mousedown', on_click_card); - ui.power_cards.push(power_card); + for (let id of board_events) { + ui.events[id] = document.createElement("div") + ui.events[id].id = "event_" + id + ui.events[id].className = "marker event" + document.getElementById("markers").appendChild(ui.events[id]) } -} - - - -function is_card_enabled(card) { - if (view.actions) { - if (card_action_menu.some(a => view.actions[a] && view.actions[a].includes(card))) - return true - if (view.actions.card_select && view.actions.card_select.includes(card)) - return true - if (view.actions.card && view.actions.card.includes(card)) - return true - } - return false + ui.countries = [] + create_country(0, "country_poland") + create_country(1, "country_hungary") + create_country(2, "country_east_germany") + create_country(3, "country_bulgaria") + create_country(4, "country_czechoslovakia") + create_country(5, "country_romania") } // SUPPORTING FUNCTIONS function on_click_space(evt) { - if (evt.button === 0) { - const space = evt.target.my_space; - //console.log('on_click_space_called with space:', space); - if (send_action('infl', space)) { + if (evt.button === 0) { + const space = evt.target.my_space + //console.log('on_click_space_called with space:', space); + if (send_action("infl", space)) { //console.log('send_action with infl:', space); - evt.stopPropagation(); - } else if (send_action('sc', space)) { + evt.stopPropagation() + } else if (send_action("sc", space)) { //console.log('send_action with sc:', space); - evt.stopPropagation(); + evt.stopPropagation() } else { - // console.log('send_action failed for space:', space); - } - } - //hide_popup_menu(); -} - -function on_click_card(evt) { - if (evt.button === 0) { - const card = evt.target.my_card; - //console.log('on_click_card_called with card:', card); - if (is_action('card', card)) { - //console.log('in action card') - if (send_action('card', card)) { - evt.stopPropagation(); - } - } - if (is_action('power_card', card)) { - if (send_action('power_card', card)) { - evt.stopPropagation(); - } + // console.log('send_action failed for space:', space); } } + //hide_popup_menu(); } -function is_action(action) { - //console.log('is_action called with: ', action) - //console.log('view.actions', view.actions) - if (view.actions && view.actions[action]) - return true - return false -} - -function is_card_action(action, card) { - //console.log('is_card_action called with action', action, 'card', card) - //console.log('view.actions', view.actions, 'view.actions[action]', view.actions[action]) - if (view.actions && view.actions[action] && view.actions[action].includes(card)) - return true - return false -} - -function on_log(text) { // eslint-disable-line no-unused-vars +function on_log(text) { + // eslint-disable-line no-unused-vars let p = document.createElement("div") if (text.match(/^>/)) { text = text.substring(1) - p.className = 'i' + p.className = "i" } - text = text.replace(/_/g, ' ') + text = text.replace(/_/g, " ") text = text.replace(/C(\d+)/g, sub_card_name) text = text.replace(/P(\d+)/g, sub_power_card_name) text = text.replace(/V(\d+)/g, sub_power_card_value) text = text.replace(/%(\d+)/g, sub_space_name) text = text.replace(/D[1-6]/g, sub_die) - if (text.match(/^\.h1/)) { text = text.substring(4) - p.className = 'h1' - } - else if (text.match(/^\.h2d/)) { + p.className = "h1" + } else if (text.match(/^\.h2d/)) { text = text.substring(5) - p.className = 'h2 dem' - } - else if (text.match(/^\.h2c/)) { + p.className = "h2 dem" + } else if (text.match(/^\.h2c/)) { text = text.substring(5) - p.className = 'h2 com' - } - else if (text.match(/^\.h2/)) { + p.className = "h2 com" + } else if (text.match(/^\.h2/)) { text = text.substring(4) - p.className = 'h2' - } - else if (text.match(/^\.h3/)) { + p.className = "h2" + } else if (text.match(/^\.h3/)) { text = text.substring(4) - p.className = 'h3' + p.className = "h3" } p.innerHTML = text return p } -let ui = { - favicon: document.getElementById('favicon'), - player: [ - document.getElementById("role_Democrat"), - document.getElementById("role_Communist"), - ], - cards: [ null ], - power_cards: [null], - dem_hand_count: document.getElementById("role_stat_dem"), - com_hand_count: document.getElementById("role_stat_com"), - deck_length: document.getElementById("deck_length"), - played_card: 0, - table_panel: document.getElementById("table_panel"), - hand_panel: document.getElementById("hand_panel"), - turn: document.getElementById("turn-tracker"), - round: document.getElementById("action-round-tracker"), - stability: document.getElementById("stability-track"), - dem_TST: document.getElementById("dem-TST"), - com_TST: document.getElementById("com-TST"), - vp: document.getElementById("vp"), - spaces: document.getElementsByClassName("space-area") +function layout_turn_marker() { + let x = 654 + 24 + (view.turn - 1) * 53 + let y = 80 + 24 + ui.turn.style.left = (x - 25) + "px" + ui.turn.style.top = (y - 25) + "px" +} +function layout_round_marker() { + let x = 709 + 24 + (view.turn - 1) * 53 + let y = 142 + 24 + ui.round.style.left = (x - 25) + "px" + ui.round.style.top = (y - 25) + "px" + if (view.round_player === "Democrat") // TODO: bit flag? + ui.round.className = "marker dem" + else + ui.round.className = "marker com" } +function layout_stability_marker() { + let x = 24 + 1381 + let y = 24 + 1081 + view.stability * 54 + ui.stability.style.left = (x - 25) + "px" + ui.stability.style.top = (y - 25) + "px" +} -function on_update() { - //console.log('on_update called') - //console.log('view.valid_spaces: ', view.valid_spaces) - //console.log('view.actions: ', view.actions) - //console.log('view.power_cards:', view.power_cards) - document.querySelectorAll('[id^="space_"].selected').forEach(spaceElement => {spaceElement.classList.remove('selected');}); - document.getElementById("power_hand")?.querySelectorAll('.selected').forEach(cardElement => {cardElement.classList.remove('selected');}); - view.valid_spaces.forEach(space_id => { - const spaceElementId = `space_${space_id}`; - const spaceElement = document.getElementById(spaceElementId); - - if (spaceElement) { - spaceElement.classList.add('selected'); - } - }); - - //Check influence values - - for (let i = 1; i < spaces.length; i ++) { - - const space = spaces[i] - const demInfl = view.demInfl[i] - const comInfl = view.comInfl[i] - //console.log('piece', piece) - //console.log('space', space) - const dem_marker = document.getElementById(`${space.name_unique}_demInfl`); - const dem_number = document.getElementById(`${space.name_unique}_demInflValue`); - const com_marker = document.getElementById(`${space.name_unique}_comInfl`); - const com_number = document.getElementById(`${space.name_unique}_comInflValue`); - - dem_number.innerText=demInfl - if (demInfl > 0) { - dem_marker.style.display = 'block'; - dem_number.style.display = 'block'; - - if (demInfl > 9) { - dem_number.classList.remove('demInflValue') - dem_number.classList.add('demInflValue_10') - } else { - dem_number.classList.add('demInflValue') - dem_number.classList.remove('demInflValue_10') - } - - if(check_dem_control(demInfl, comInfl, space)){ - dem_marker.classList.add('controlled') - dem_number.classList.add('outlined_text') - dem_marker.classList.remove('uncontrolled') - } else { - dem_marker.classList.add('uncontrolled') - dem_marker.classList.remove('controlled') - dem_number.classList.remove('outlined_text') - } - } else { - dem_marker.style.display = 'none'; - dem_number.style.display = 'none'; - } - com_number.innerText=comInfl - if (comInfl > 0) { - com_marker.style.display = 'block'; - com_number.style.display = 'block'; - - if (comInfl > 9) { - com_number.classList.remove('comInflValue') - com_number.classList.add('comInflValue_10') - } else { - com_number.classList.add('comInflValue') - com_number.classList.remove('comInflValue_10') - } - - if(check_com_control(demInfl, comInfl, space)){ - com_marker.classList.add('controlled') - com_number.classList.add('controlled') - com_marker.classList.remove('uncontrolled') - com_number.classList.remove('uncontrolled') - } else { - com_marker.classList.add('uncontrolled') - com_number.classList.add('uncontrolled') - com_marker.classList.remove('controlled') - com_number.classList.remove('controlled') - } - } else { - com_marker.style.display = 'none'; - com_number.style.display = 'none'; - } - - } +let TST_X = [ 53, 53+69, 53+69*2, 53+69*3, 53+69*4, 53+69*5, 53+69*6, 556 ] +let TST_Y = [ 2128, 2257 ] -// UPDATE COUNTRY MARKERS - for (let i = 0; i < countries.length; i++) { - const country = countries[i]; - const marker = document.getElementById(country) - const times_held = document.getElementById(`${country}_times_held`) - - if (view.revolutions[find_country_index(country)]) { - marker.classList.add('revolution') - marker.classList.remove('held') - marker.style.display = 'block' - times_held.classList.add('outlined_text') - times_held.classList.remove('hide') - } else if (view.times_held[find_country_index(country)] > 0 ) { - //console.log('setting ', country) - marker.classList.add('held') - marker.style.display = 'block' - times_held.classList.remove('hide') - times_held.innerHTML = view.times_held[find_country_index(country)] - } - else {marker.style.display = 'none'} - } +function layout_tst_marker(e, v, top) { + let x = TST_X[v] + 24 + let y = TST_Y[top] + 24 + e.style.left = (x - 25) + "px" + e.style.top = (y - 25) + "px" +} -// UPDATE ASIDE - if (view.is_pwr_struggle) { - ui.dem_hand_count.innerText = `${view.democrat_power_hand} Power cards` - ui.com_hand_count.innerText = `${view.communist_power_hand} Power cards` - } else{ - ui.dem_hand_count.innerText = `${view.democrat_hand} cards` - ui.com_hand_count.innerText = `${view.communist_hand} cards` +function layout_vp_marker() { + let x, y + if (view.vp === 0) { + y = 2425 + 25 + x = 843 + 28 } - ui.deck_length.innerText = `${view.strategy_deck} cards` - -// UPDATE HAND - document.getElementById("hand").replaceChildren() - document.getElementById("played_card").replaceChildren() - - if (view.hand.length && view.is_pwr_struggle === false) { - document.getElementById("hand_panel").classList.remove("hide") - //console.log('view.actions.card', view.actions.card) - for (let c of view.hand) { - let card = ui.cards[c] - document.getElementById("hand").appendChild(card); - if (view.actions && view.actions.card && view.actions.card.includes(c)) { - card.classList.add('action') - } else { - card.classList.remove('action') - } - if (view.valid_cards.includes(c)) { - card.classList.add('selected') - } else { - card.classList.remove('selected') - } - card.classList.remove('discard_card') + else if (view.vp < 0) { + if (view.vp & 1) { + y = 2456 + 25 + x = 803 + 28 - (-view.vp - 1)/2 * 62 + } else { + y = 2395 + 25 + x = 772 + 28 - (-view.vp - 2)/2 * 62 } - } else { - document.getElementById("hand_panel").classList.add("hide") - } - -// UPDATE DISCARD -document.getElementById("discard").replaceChildren() -if (!view.is_pwr_struggle) { - for (let c of view.strategy_discard) { - let discard_card = ui.cards[c] - document.getElementById("discard").appendChild(discard_card) - discard_card.classList.add('discard_card') - discard_card.classList.remove('selected') - } -} else if (view.is_pwr_struggle) { - for (let c of view.strategy_discard) { - let discard_card = ui.power_cards[c] - document.getElementById("discard").appendChild(discard_card) - discard_card.classList.add('discard_card') - discard_card.classList.remove('selected') } -} - -// DISCARD FOR EVENTS -//console.log('view.discard',view.discard) -if(view.discard) { - //document.getElementById("discard").replaceChildren() - document.getElementById("discard_panel").classList.remove("hide") - for (let c of view.strategy_discard) { - let discard_card = ui.cards[c] - document.getElementById("discard").appendChild(discard_card) - discard_card.classList.add('discard_card') - if (view.valid_cards.includes(c)) { - discard_card.classList.add('selected') + else if (view.vp > 0) { + if (view.vp & 1) { + y = 2396 + 25 + x = 883 + 28 + (view.vp - 1)/2 * 62 } else { - discard_card.classList.remove('selected') + y = 2455 + 25 + x = 913 + 28 + (view.vp - 2)/2 * 62 } - } -} else { - if (!show_discard) { - document.getElementById("discard_panel").classList.add("hide") + } + ui.vp.style.left = (x - 25) + "px" + ui.vp.style.top = (y - 25) + "px" +} + +function layout_country(id) { + for (let i = 0; i < 6; i++) { + // TODO: what number to display? + if (view.revolutions[id]) + ui.countries[id].className = "marker comInfl ctl v" + view.times_held[id] + else if (view.times_held[id] > 0) + ui.countries[id].className = "marker demInfl ctl v" + view.times_held[id] + else + ui.countries[id].className = "marker hide" } } -// UPDATE PERMANENTLY REMOVED CARDS -document.getElementById("removed").replaceChildren() -for (let c of view.strategy_removed) { - let discard_card = ui.cards[c] - document.getElementById("removed").appendChild(discard_card) - discard_card.classList.add('discard_card') - discard_card.classList.remove('selected') -} - - -// PLAYED CARD PANEL -if (view.played_card > 0) { - document.getElementById("played_card_panel").classList.remove("hide") - document.getElementById("played_card").appendChild(ui.cards[view.played_card]); - document.getElementById("played_card").classList.remove("hand_card") -} else { - document.getElementById("played_card_panel").classList.add("hide") -} - -// TABLE CARDS PANEL -document.getElementById("table_cards").replaceChildren() -if (view.table_cards.length > 0) { - document.getElementById("table_panel").classList.remove("hide") - for (let c of view.table_cards) { - let card = ui.cards[c] - document.getElementById("table_cards").appendChild(card); - card.classList.remove("hand_card") - card.classList.add('event_card'); - } - } else { - document.getElementById("table_panel").classList.add("hide") -} +function on_update() { + if (!ui.spaces) + create_ui() -// OPPONENT HAND -document.getElementById("opp_hand").replaceChildren() -if (!view.is_pwr_struggle) { - if (view.show_opp_hand && view.opp_hand.length >0) { - document.getElementById("opp_hand_panel").classList.remove("hide") - for (let c of view.opp_hand) { - let card = ui.cards[c] - document.getElementById("opp_hand").appendChild(card); - card.classList.remove('discard_card') - if (!view.is_pwr_struggle) { - if (view.valid_cards.includes(c)) { - card.classList.add('selected') - } else { - card.classList.remove('selected') - } - } - } + // UPDATE ASIDE + if (view.is_pwr_struggle) { + roles.Democrat.stat.textContent = `${view.democrat_power_hand} Power cards` + roles.Communist.stat.textContent = `${view.communist_power_hand} Power cards` } else { - document.getElementById("opp_hand_panel").classList.add("hide") + roles.Democrat.stat.textContent = `${view.democrat_hand} cards` + roles.Communist.stat.innerText = `${view.communist_hand} cards` } -} else { - //console.log('power struggle, show opp hand', view.show_opp_hand, 'view opp hand', view.opp_hand ) - if (view.show_opp_hand && view.opp_hand && view.opp_hand.length > 0) { - document.getElementById("opp_hand_panel").classList.remove("hide") - for (let c of view.opp_hand) { - let card = ui.power_cards[c] - //console.log('power_card:', power_card) - document.getElementById("opp_hand").appendChild(card); - card.classList.remove('discard_card') - } + ui.turn_info.innerText = `Strategy deck: ${view.strategy_deck} cards` + + // UPDATE TRACK MARKERS + layout_turn_marker() + layout_round_marker() + layout_stability_marker() + layout_vp_marker() + layout_tst_marker(ui.dem_tst, view.dem_tst, 0) + layout_tst_marker(ui.com_tst, view.com_tst, 1) + + // UPDATE EVENT MARKERS ON THE BOARD + + if (view.persistent_events.includes(2)) + ui.events[2].style.display = "block" + else + ui.events[2].style.display = "none" + + if (view.persistent_events.includes(9)) + ui.events[9].style.display = "block" + else + ui.events[9].style.display = "none" + + if (view.persistent_events.includes(69)) { + ui.events[69].style.display = "block" + ui.events[69].style.left = ui.layout_xy[view.systematization][0] - 25 + "px" + ui.events[69].style.top = ui.layout_xy[view.systematization][1] - 25 + "px" } else { - document.getElementById("opp_hand_panel").classList.add("hide") + ui.events[69].style.display = "none" } -} -// POWER STRUGGLE HAND - document.getElementById("power_hand").replaceChildren() - - if (view.power_hand.length && view.is_pwr_struggle) { - document.getElementById("power_panel").classList.remove("hide") - for (let c of view.power_hand) { - let power_card = ui.power_cards[c] - document.getElementById("power_hand").appendChild(power_card); - power_card.classList.remove('discard_card') - if (view.valid_cards.includes(c)) { - power_card.classList.add('selected'); - } - } + if (view.persistent_events.includes(97)) { + ui.events[97].style.display = "block" + ui.events[97].style.left = ui.layout_xy[view.the_tyrant_is_gone][0] - 25 + "px" + ui.events[97].style.top = ui.layout_xy[view.the_tyrant_is_gone][1] - 25 + "px" } else { - document.getElementById("power_panel").classList.add("hide") + ui.events[97].style.display = "none" } -// CEAUSESCU + // EVENT REMINDER LIST + + ui.event_reminder_list.replaceChildren() + for (let id of box_events) + if (view.persistent_events.includes(id)) + ui.event_reminder_list.appendChild(ui.events[id]) + + // UPDATE INFLUENCE VALUES + for (let s = 1; s <= last_space; ++s) { + const demInfl = view.demInfl[s] + const comInfl = view.comInfl[s] + + if (demInfl - comInfl >= spaces[s].stability) + ui.dem_inf[s].className = "marker demInfl ctl v" + demInfl + else if (demInfl > 0) + ui.dem_inf[s].className = "marker demInfl v" + demInfl + else + ui.dem_inf[s].className = "marker demInfl hide" + + if (comInfl - demInfl >= spaces[s].stability) + ui.com_inf[s].className = "marker comInfl ctl v" + comInfl + else if (comInfl > 0) + ui.com_inf[s].className = "marker comInfl v" + comInfl + else + ui.com_inf[s].className = "marker comInfl hide" + } -if (view.ceausescu_cards && view.ceausescu_cards.length > 0 && view.is_pwr_struggle === true) { - document.getElementById("ceausescu_panel").classList.remove("hide") - for (let c of view.ceausescu_cards) { - let power_card = ui.power_cards[c] - document.getElementById("ceausescu_hand").appendChild(power_card); - power_card.classList.remove('discard_card') + // UPDATE COUNTRY MARKERS - } -} else { - document.getElementById("ceausescu_panel").classList.add("hide") -} + for (let i = 0; i < 6; ++i) + layout_country(i) -// SAMIZDAT CARD -if (view.samizdat > 0 ) { - let samizdat_card = ui.cards[view.samizdat] - document.getElementById("samizdat_panel").classList.remove("hide") - document.getElementById("samizdat_card").appendChild(samizdat_card) -} else { - document.getElementById("samizdat_panel").classList.add("hide") -} + // UPDATE CARD DISPLAYS -// UPDATE BOARD MARKERS - ui.turn.className = `t${view.turn}` - if (view.round_player === 'Democrat') { - ui.round.className = `dem-action-round-tracker r${view.round}` - } else { - ui.round.className = `com-action-round-tracker r${view.round}` - } - ui.stability.className = `s${view.stability}` - ui.dem_TST.className = `tst${view.dem_tst}` - ui.com_TST.className = `tst${view.com_tst}` - if (view.vp >= -20 && view.vp <= 20) { - ui.vp.className = `vp${view.vp}` - } else if (view.vp > 20) { - ui.vp.className = `vp21` - } else if (view.vp < -20) { - ui.vp.className = `vp-21` - } - -//console.log('strategy discard: ', view.strategy_discard) -//console.log('valid spaces: ', view.valid_spaces) - -//console.log('view.persistent_events', view.persistent_events) + ui.played_card.replaceChildren() + if (view.played_card > 0) + ui.played_card.appendChild(ui.cards[view.played_card]) -// UPDATE EVENT MARKERS ON THE BOARD + ui.samizdat_card.replaceChildren() + if (view.samizdat > 0) + ui.samizdat_card.appendChild(ui.cards[view.samizdat]) -for (let id of board_events) { - let marker = document.getElementById(`event_${id}`) - //console.log('event', id, marker) - if (view.persistent_events.includes(id)) { - marker.style.display = 'block' - } else { - marker.style.display = 'none' - } -} + ui.hand.replaceChildren() + for (let c of view.hand) + ui.hand.appendChild(ui.cards[c]) + ui.power_hand.replaceChildren() + if (view.power_hand) + for (let c of view.power_hand) + ui.hand.appendChild(ui.power_cards[c]) -// UPDATE EVENT MARKERS BELOW THE BOARD + ui.opp_hand.replaceChildren() + if (view.opp_hand) + for (let c of view.opp_hand) + ui.opp_hand.appendChild(ui.cards[c]) -for (let id of box_events) { - let marker = document.getElementById(`event_${id}`) - //console.log('event', id, marker) - if (view.persistent_events.includes(id)) { - marker.style.display = 'block' - } else { - marker.style.display = 'none' - } -} + // TODO: fix rules to set view.opp_power_hand + ui.opp_power_hand.replaceChildren() + if (view.opp_power_hand) + for (let c of view.opp_power_hand) + ui.opp_hand.appendChild(ui.power_cards[c]) + ui.ceausescu_hand.replaceChildren() + if (view.ceausescu_cards) + for (let c of view.ceausescu_cards) + ui.ceausescu_hand.appendChild(ui.power_cards[c]) -// CHECK WHETHER ANY EVENT MARKERS ARE SHOWING IN THE EVENTS BOX -box_events_showing = false -for (let id of box_events) { - if (view.persistent_events.includes(id)) { - box_events_showing = true; - } -/* - //Special check for events which are not true/false - if (view.persistent_events['foreign_currency_debt_burden'] !== '') { - aside_events_showing = true - } - if (view.persistent_events['stand_fast'] !== '') { - aside_events_showing = true - } - */ -} + ui.discard.replaceChildren() + for (let c of view.strategy_discard) + ui.discard.appendChild(ui.cards[c]) -if (box_events_showing) { - document.getElementById('events_panel').classList.remove("hide") -} else { - document.getElementById('events_panel').classList.add("hide") -} + ui.removed.replaceChildren() + for (let c of view.strategy_removed) + ui.discard.appendChild(ui.cards[c]) -let systematization = document.getElementById('event_69') -if (view.persistent_events.includes(69)) { - systematization.style.left = (spaces[view.systematization].box.x +20) + 'px'; - systematization.style.top = spaces[view.systematization].box.y + 'px'; -} + ui.table_cards.replaceChildren() + if (view.table_cards) + for (let c of view.table_cards) + ui.table_cards.appendChild(ui.cards[c]) -let tyrant = document.getElementById('event_97') -if (view.persistent_events.includes(97)) { - tyrant.style.left = (spaces[view.the_tyrant_is_gone].box.x - 41) + 'px'; - tyrant.style.top = (spaces[view.the_tyrant_is_gone].box.y + 23) + 'px'; -} else {tyrant.style.display = 'none'} + for (let e of action_register) + e.classList.toggle("action", is_action(e.my_action, e.my_id)) action_button("yes", "Yes") action_button("no", "No") @@ -696,7 +436,7 @@ if (view.persistent_events.includes(97)) { action_button("strike", "Strike") action_button("march", "March") action_button("rally", "Rally in the Square") - action_button("petition", "Petition") + action_button("petition", "Petition") action_button("bonus", "Calculate VP bonus") action_button("scoring", "Score country") action_button("retain", "Retain Power") @@ -704,9 +444,9 @@ if (view.persistent_events.includes(97)) { action_button("take", "Take Power") action_button("concede", "Concede") action_button("struggle", "Begin power struggle") - action_button("raise", "Raise the stakes") - action_button("draw", "Draw") - action_button("scoring", "Scoring") + action_button("raise", "Raise the stakes") + action_button("draw", "Draw") + action_button("scoring", "Scoring") action_button("event", "Event") action_button("opp_event", "Resolve opponent event") action_button("influence", "Place SPs") @@ -716,8 +456,6 @@ if (view.persistent_events.includes(97)) { action_button("done", "Done") action_button("end_round", "End Round") action_button("undo", "Undo") - -console.log('view.actions', view.actions) } // =========================== LOG FUNCTIONS ============================================== @@ -738,9 +476,8 @@ function sub_power_card_value(match, p1) { } function sub_space_name(match, p1) { - let x = p1 | 0 - let id = spaces[x].space_id - let name = spaces[x].name_unique + let id = p1 | 0 + let name = spaces[id].name_unique return `${name}` } @@ -754,45 +491,32 @@ const die = { D3: '', D4: '', D5: '', - D6: '' + D6: '', } // =========================== VISUAL FUNCTIONS ==========================================# -function on_focus_card_tip(card_number) { - document.getElementById("tooltip").className = "card card_" + card_number +function on_focus_card_tip(card_number) { + document.getElementById("tooltip").className = "card event_" + card_number } -function on_blur_card_tip() { +function on_blur_card_tip() { document.getElementById("tooltip").classList = "card hide" } function on_focus_space_tip(id) { - space = document.getElementById(`space_${id}`) - space.classList.add("tip") -} - -function on_click_space_tip(id) { - space = document.getElementById(`space_${id}`) - scroll_into_view(space) + ui.spaces[id].classList.add("tip") } function on_blur_space_tip(id) { - space = document.getElementById(`space_${id}`) - space.classList.remove("tip") + ui.spaces[id].classList.remove("tip") } -function toggle_pieces() { - document.getElementById("pieces").classList.toggle("hide") +function on_click_space_tip(id) { + scroll_into_view(ui.spaces[id]) } - function toggle_discard() { - if (show_discard) { - show_discard = false - } else { - show_discard = true - } document.getElementById("discard_panel").classList.toggle("hide") } @@ -800,20 +524,118 @@ function toggle_removed() { document.getElementById("removed_panel").classList.toggle("hide") } -function check_dem_control(demInfl, comInfl, space) { - if ((demInfl - comInfl) >= space.stability) { - return true - } else{ false} -} - -function check_com_control(demInfl, comInfl, space) { - if ((comInfl - demInfl) >= space.stability) { - return true - } else{ false} -} - function find_country_index(country) { return countries.indexOf(country) } -create_ui() +// #region GENERATED LAYOUT DATA + +var LAYOUT = { + "Babes-Bolyai University": [958,1529,127,75], + "Berlin": [329,148,127,75], + "Bialystok": [1202,436,127,76], + "Brasov": [1339,1556,127,75], + "Bratislava": [539,1013,127,76], + "Brno": [521,904,127,76], + "Bucuresti": [1186,1837,127,76], + "Budapest": [809,1249,127,76], + "Bulgarian Writers": [838,2192,127,76], + "Burgas": [1289,2152,127,76], + "Bydgoszcz": [872,388,127,76], + "Catholic Church, Czechoslovakia": [692,1010,127,75], + "Catholic Church, Hungary": [409,1126,127,76], + "Catholic Church, Poland": [802,558,127,75], + "Ceske Budejovice": [260,765,127,77], + "Charles University": [491,677,128,76], + "Cluj-Napoca": [970,1429,127,76], + "Constanta": [1443,1925,127,76], + "Craiova": [977,1793,127,76], + "Czech Writers": [573,773,127,76], + "Debrecen": [1000,1192,127,76], + "Dresden": [343,479,127,76], + "Eotvos Lorand University": [658,1314,127,76], + "Erfurt": [38,455,127,76], + "Galati": [1409,1778,127,76], + "Gdansk": [896,277,127,76], + "German Writers": [81,239,127,76], + "Gyor": [560,1129,127,76], + "Halle": [231,357,127,75], + "Harghita/Covasna": [1186,1560,127,75], + "Hungarian Writers": [452,1322,127,76], + "Iasi": [1369,1395,127,76], + "Jagiellonian University": [870,867,127,76], + "Karl-Marx-Stadt": [184,492,127,75], + "Katowice": [733,723,127,76], + "Kosice": [995,1037,127,76], + "Krakow": [911,761,127,76], + "Leipzig": [387,379,127,76], + "Lodz": [959,620,127,76], + "Lublin": [1124,754,127,76], + "Lutheran Church": [391,271,127,76], + "Magdeburg": [79,352,127,75], + "Miskolc": [851,1146,127,76], + "Orthodox Church, Bulgaria": [1130,1956,127,76], + "Orthodox Church, Romania": [1094,1700,127,76], + "Ostrava": [673,868,127,75], + "Pecs": [626,1406,127,75], + "Pleven": [979,1948,127,76], + "Ploiesti": [1356,1671,127,76], + "Plovdiv": [987,2209,127,75], + "Plzen": [211,615,127,76], + "Polish Writers": [1051,883,127,75], + "Poznan": [671,452,127,76], + "Praha": [412,782,127,75], + "Presov": [844,1010,127,75], + "Razgrad": [1219,2057,127,76], + "Romanian Writers": [947,1625,127,75], + "Rostock": [299,53,127,76], + "Ruse": [1277,1956,127,76], + "Schwerin": [148,86,127,76], + "Sliven": [1144,2251,127,75], + "Sofia": [983,2098,127,76], + "Sofia University": [828,2095,127,76], + "Stara Zagora": [1133,2153,127,75], + "Szczecin": [574,263,127,75], + "Szeged": [812,1364,127,76], + "Szekesfehervar": [571,1223,127,75], + "Szombathely": [410,1224,127,76], + "Targu Mures": [1169,1443,127,76], + "Tatabanya": [706,1126,127,75], + "Timisoara": [767,1531,127,76], + "Varna": [1387,2051,127,76], + "Walter Ulbricht Academy": [234,240,127,76], + "Warszawa": [1032,490,127,75], + "Wroclaw": [595,565,127,75], + "action_1": [708,143,48,44], + "action_8": [1080,143,47,43], + "country_bulgaria": [915,1999,46,41], + "country_czechoslovakia": [463,624,44,39], + "country_east_germany": [560,160,43,37], + "country_hungary": [1034,1319,44,39], + "country_poland": [1188,292,44,39], + "country_romania": [1287,1349,44,39], + "event_solidarity_legalized": [779,270,44,43], + "event_the_wall": [222,179,40,41], + "tst_com_1": [53,2257,47,47], + "tst_com_7": [469,2257,47,47], + "tst_com_8": [556,2257,47,47], + "tst_dem_1": [53,2128,47,47], + "tst_dem_7": [469,2128,47,47], + "tst_dem_8": [556,2128,47,47], + "turn_1": [655,81,47,48], + "turn_10": [1133,80,48,48], + "ussr_1": [1381,1080,48,48], + "ussr_2": [1381,1134,48,48], + "ussr_3": [1381,1188,48,48], + "ussr_4": [1381,1243,48,48], + "ussr_5": [1381,1297,48,48], + "vp_0": [843,2425,55,51], + "vp_1": [883,2395,55,50], + "vp_19": [1440,2395,55,50], + "vp_2": [913,2455,56,51], + "vp_20": [1471,2455,55,51], + "vp_neg_1": [803,2455,56,51], + "vp_neg_19": [246,2456,55,50], + "vp_neg_2": [772,2395,56,51], + "vp_neg_20": [215,2395,55,51], +} diff --git a/rules.js b/rules.js index 877c4d8..6ce54dd 100644 --- a/rules.js +++ b/rules.js @@ -268,18 +268,13 @@ exports.view = function(state, player) { // === ACTIONS =========== function gen_action(action, argument) { -//console.log('gen_action called with ', action, ' and ', argument) if (argument === undefined) { - //console.log('argument undefined') view.actions[action] = 1 } else { - if (!(action in view.actions)) { - //console.log('push argument') + if (!(action in view.actions)) view.actions[action] = [] - } view.actions[action].push(argument) } - //console.log('view.actions: ', view.actions, 'view.actions[action]: ', view.actions[action]) } function gen_action_space(space){ @@ -9013,6 +9008,7 @@ states.vm_support_falters = { /* =================== EVENTS ================================ */ // #region GENERATED EVENT CODE + const CODE = [] CODE[1] = [ // Legacy of Martial Law* @@ -9875,43 +9871,44 @@ CODE[110] = [ // Malta Summit* [ vm_remove_opp_infl, 5 ], [ vm_return ], ] -// #endregion - -// ============= TIANANMEN SQUARE TRACK AWARDS ==================== -CODE[203] = [//Tiananmen Square space 3 award - [vm_tst_3], - [vm_return] -] -CODE[204] = [//Tiananmen Square space 4 award - [vm_valid_spaces_opponent], - [vm_tst_4], - [vm_return] +CODE[203] = [ // Tiananmen Square space 3 award + [ vm_tst_3 ], + [ vm_return ], ] -CODE[206] = [//Tiananmen Square space 6 - [vm_valid_spaces_sc], - [vm_tst_6], - [vm_return] + +CODE[204] = [ // Tiananmen Square space 4 award + [ vm_valid_spaces_opponent ], + [ vm_tst_4 ], + [ vm_return ], ] -CODE[208] = [//Tiananmen Square space 8 event - [vm_tst_8], - [vm_return] + +CODE[206] = [ // Tiananmen Square space 6 + [ vm_valid_spaces_sc ], + [ vm_tst_6 ], + [ vm_return ], ] -// ============= POWER STRUGGLE WILDCARDS ========================= +CODE[208] = [ // Tiananmen Square space 8 event + [ vm_tst_8 ], + [ vm_return ], +] -CODE[349] = [//Scare Tactics - [vm_scare_tactics], - [vm_valid_spaces_country_opp], - [vm_prompt, ()=>` from ${country_name(game.vm_active_country)}`], - [vm_remove_opp_infl, 1], - [vm_return] +CODE[349] = [ // Scare Tactics + [ vm_scare_tactics ], + [ vm_valid_spaces_country_opp ], + [ vm_prompt, ()=>` from ${country_name(game.vm_active_country)}` ], + [ vm_remove_opp_infl, 1 ], + [ vm_return ], ] -CODE[350] = [//Support Surges - [vm_support_surges], - [vm_return] + +CODE[350] = [ // Support Surges + [ vm_support_surges ], + [ vm_return ], ] -CODE[351] = [//Support Falters - [vm_support_falters], - [vm_return] + +CODE[351] = [ // Support Falters + [ vm_support_falters ], + [ vm_return ], ] +// #endregion diff --git a/tools/colors.js b/tools/colors.js new file mode 100644 index 0000000..f8f7ace --- /dev/null +++ b/tools/colors.js @@ -0,0 +1,110 @@ +"use strict" + +function rgb_from_any(color) { + switch (color.mode) { + case "rgb": return color + case "lrgb": return rgb_from_lrgb(color) + case "oklab": return rgb_from_oklab(color) + } +} + +function lrgb_from_any(color) { + switch (color.mode) { + case "rgb": return lrgb_from_rgb(color) + case "lrgb": return color + case "oklab": return lrgb_from_oklab(color) + } +} + +function oklab_from_any(color) { + switch (color.mode) { + case "rgb": return oklab_from_rgb(color) + case "lrgb": return oklab_from_lrgb(color) + case "oklab": return color + } +} + +function format_hex(color) { + let {r, g, b} = rgb_from_any(color) + let adj = 1 + r = Math.round(Math.max(0, Math.min(1, r)) * 255) + g = Math.round(Math.max(0, Math.min(1, g)) * 255) + b = Math.round(Math.max(0, Math.min(1, b)) * 255) + let x = (r << 16) | (g << 8) | b + return "#" + x.toString(16).padStart(6, "0") +} + +function parse_hex(str) { + let x = parseInt(str.substring(1), 16) + return { + mode: "rgb", + r: ((x >> 16) & 255) / 255.0, + g: ((x >> 8) & 255) / 255.0, + b: ((x) & 255) / 255.0 + } +} + +function lrgb_from_rgb({ r, g, b }) { + function to_linear(c) { + let ac = Math.abs(c) + if (ac < 0.04045) + return c / 12.92 + return (Math.sign(c) || 1) * Math.pow((ac + 0.055) / 1.055, 2.4) + } + return { + mode: "lrgb", + r: to_linear(r), + g: to_linear(g), + b: to_linear(b) + } +} + +function rgb_from_lrgb({ r, g, b }) { + function from_linear(c) { + let ac = Math.abs(c) + if (ac > 0.0031308) + return (Math.sign(c) || 1) * (1.055 * Math.pow(ac, 1 / 2.4) - 0.055) + return c * 12.92 + } + return { + mode: "rgb", + r: from_linear(r), + g: from_linear(g), + b: from_linear(b) + } +} + +function oklab_from_lrgb({ r, g, b }) { + let L = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b) + let M = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b) + let S = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b) + return { + mode: "oklab", + l: 0.2104542553 * L + 0.793617785 * M - 0.0040720468 * S, + a: 1.9779984951 * L - 2.428592205 * M + 0.4505937099 * S, + b: 0.0259040371 * L + 0.7827717662 * M - 0.808675766 * S + } +} + +function lrgb_from_oklab({ l, a, b }) { + let L = Math.pow(l + 0.3963377774 * a + 0.2158037573 * b, 3) + let M = Math.pow(l - 0.1055613458 * a - 0.0638541728 * b, 3) + let S = Math.pow(l - 0.0894841775 * a - 1.291485548 * b, 3) + return { + mode: "lrgb", + r: +4.0767416621 * L - 3.3077115913 * M + 0.2309699292 * S, + g: -1.2684380046 * L + 2.6097574011 * M - 0.3413193965 * S, + b: -0.0041960863 * L - 0.7034186147 * M + 1.707614701 * S + } +} + +function oklab_from_rgb(rgb) { + return oklab_from_lrgb(lrgb_from_rgb(rgb)) +} + +function rgb_from_oklab(oklab) { + return rgb_from_lrgb(lrgb_from_oklab(oklab)) +} + +if (typeof module === "object") + module.exports = { format_hex, parse_hex, rgb_from_any, lrgb_from_any, oklab_from_any } diff --git a/tools/gencode.js b/tools/gencode.js new file mode 100644 index 0000000..f2e3a26 --- /dev/null +++ b/tools/gencode.js @@ -0,0 +1,106 @@ +"use strict" + +let fs = require("fs") + +let pc = 0 + +function tokenize(s) { + let list = [] + let p = 0, + n = s.length + while (p < n) { + while (p < n && s[p] === " ") + ++p + if (p < n) { + let m = p + while (p < n && s[p] !== " ") { + let q = s[p++] + switch (q) { + case "(": + case "[": + case "{": + for (let x = 1; p < n && x > 0; ++p) { + switch (s[p]) { + case "(": + case "[": + case "{": + ++x + break + case ")": + case "]": + case "}": + --x + break + } + } + break + case '"': + case "'": + case "`": + while (p < n && s[p] !== q) + ++p + break + } + } + list.push(s.substring(m, p)) + } + } + return list +} + +function emit(line) { + ++pc + line[0] = "vm_" + line[0] + for (let i = 1; i < line.length; ++i) { + if (typeof line[i] === "string") { + if (line[i] === "all") + line[i] = 999 + if (line[i][0] === "(" && !line[i].match(/\)=>/)) + line[i] = "()=>" + line[i] + if (line[i][0] === "`") + line[i] = "()=>" + line[i] + } + } + console.log("\t[ " + line.join(", ") + " ],") +} + +console.log("const CODE = []") +let first = false + +for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) { + line = line.trim() + if (line.length === 0 || line[0] === "#") + continue + if (line === "EOF") + break + line = tokenize(line) + switch (line[0]) { + case "CARD": + if (first++) { + emit(["return"]) + console.log("]") + } + console.log("") + console.log("CODE[" + line[1] + "] = [ // " + line.slice(3).join(" ")) + break + + case "log": + case "prompt": + emit([ line[0], line.slice(1).join(" ") ]) + break + + case "asm": + case "if": + case "while": + emit([ line[0], "()=>" + line.slice(1).join(" ") ]) + break + + default: + emit(line) + break + } +} + +emit(["return"]) +console.log("]") +console.log("// #endregion") diff --git a/tools/gencolors.js b/tools/gencolors.js new file mode 100644 index 0000000..5904741 --- /dev/null +++ b/tools/gencolors.js @@ -0,0 +1,78 @@ +const { parse_hex, format_hex, lrgb_from_any, rgb_from_any, oklab_from_any } = require("./colors.js") + +const white = "#ffffff" +const black = "#000000" + +function lerp(a, b, n) { + return a + (b - a) * n +} + +function blend(a, b, n) { + a = lrgb_from_any(parse_hex(a)) + b = lrgb_from_any(parse_hex(b)) + return format_hex({ + mode: "lrgb", + r: lerp(a.r, b.r, n), + g: lerp(a.g, b.g, n), + b: lerp(a.b, b.b, n) + }) +} + +function multiply_luminance(hex, m) { + let oklab = oklab_from_any(parse_hex(hex)) + oklab.l = Math.max(0, Math.min(1, oklab.l * m)) + return format_hex(oklab) +} + +function add_luminance(hex, m) { + let oklab = oklab_from_any(parse_hex(hex)) + oklab.l = Math.max(0, Math.min(1, oklab.l + m)) + return format_hex(oklab) +} + +function make_3d_colors(base) { + return [ + base, + multiply_luminance(base, 0.9), + multiply_luminance(base, 0.8), + multiply_luminance(base, 0.7), + multiply_luminance(base, 0.4) + ] +} + +function make_2d_colors(base) { + return [ + base, + multiply_luminance(base, 1.2), + multiply_luminance(base, 0.8), + multiply_luminance(base, 0.4) + ] +} + +function make_2d_colors_add(base) { + return [ + base, + add_luminance(base, 0.2), + add_luminance(base, -0.2), + add_luminance(base, -0.5), + ] +} + +function print(x) { + console.log(x) +} + +function gencss(color, sel) { + let [ bg, hi, lo, sh ] = make_2d_colors(color) + print(`${sel} { background-color: ${color}; border-color: ${hi} ${lo} ${lo} ${hi}; box-shadow: 0 0 0 1px ${sh}, 1px 2px 4px #0008; }`) +} + +gencss("#bbbbbb", ".marker") +gencss("#c4e2f6", ".demInfl.ctl") +gencss("#c1272d", ".comInfl.ctl") +gencss("#147fc0", "#marker_action_round.com") +gencss("#c1272d", "#marker_action_round.dem") +gencss("#fadb04", "#marker_vp, #marker_turn") +gencss("#f26649", "#marker_com_tst") +gencss("#c4e2f4", "#marker_dem_tst") + diff --git a/tools/genlayout.js b/tools/genlayout.js new file mode 100644 index 0000000..37f419d --- /dev/null +++ b/tools/genlayout.js @@ -0,0 +1,37 @@ +const fs = require("fs") + +let boxes = [] +let mode, name, x, y, w, h + +function flush() { + if (mode === 'rect') { + boxes[name] = [ x |0, y |0, w |0, h |0 ] + } + x = y = w = h = 0 + name = null +} + +for (let line of fs.readFileSync("tools/layout.svg", "utf-8").split("\n")) { + line = line.trim() + if (line.startsWith(" + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3