From fe5b6789ecc6b3f525b162614c270feff830718b Mon Sep 17 00:00:00 2001 From: iainp5 Date: Sun, 14 Jul 2024 14:04:53 +0100 Subject: power struggle added --- rules.js | 1954 +++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 1630 insertions(+), 324 deletions(-) diff --git a/rules.js b/rules.js index 29eab65..67b627b 100644 --- a/rules.js +++ b/rules.js @@ -3,208 +3,271 @@ const { finished } = require("nodemailer/lib/xoauth2/index.js") const data = require("./data.js") -console.log('hello') - var game, view, states = {} const DEM = "Democrat" const COM = "Communist" const first_strategy_card = 1 -const last_strategy_card = 110 /* to check! */ -const hand_limit = 8 +const last_strategy_card = 110 + +const dem_tst_req = [5, 5, 6, 6, 7, 8, 9, 10] +const com_tst_req = [6, 6, 7, 7, 8, 7, 6, 5] +const scoring_cards = [17, 18, 19, 21, 22, 23] +const leaders = [1, 4, 5, 6, 7] +const support_loss_roll = [0, 0, 1, 1, 2, 2, 3, 4] +const vp_roll = [0, 0, 1, 1, 2, 2, 3, 4] +const countries = ['East Germany', 'Poland', 'Czechoslovakia', 'Hungary', 'Romania', 'Bulgaria'] +const all_power_cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52 ] const spaces = [ - {name: 'Schwerin', name_unique: 'Schwerin', space_id: 1, socio: 4, stability: 3, battleground: 0, country: 1, box: {x: 111, y: 61, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [2, 3, , , ]}, - {name: 'Rostock', name_unique: 'Rostock', space_id: 2, socio: 4, stability: 3, battleground: 0, country: 1, box: {x: 228, y: 41, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [1, 3, , , ]}, - {name: 'Berlin', name_unique: 'Berlin', space_id: 3, socio: 2, stability: 3, battleground: 1, country: 1, box: {x: 251, y: 113, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [1, 2, 5, 9, ]}, - {name: 'German Writers', name_unique: 'German Writers', space_id: 4, socio: 5, stability: 2, battleground: 0, country: 1, box: {x: 58, y: 185, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [5, , , , ]}, - {name: 'Walter Ulbricht Academy', name_unique: 'Walter Ulbricht Academy', space_id: 5, socio: 6, stability: 1, battleground: 0, country: 1, box: {x: 175, y: 187, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [3, 4, , , ]}, - {name: 'Lutherian Church', name_unique: 'Lutherian Church', space_id: 6, socio: 7, stability: 5, battleground: 1, country: 1, box: {x: 300, y: 212, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [9, , , , ]}, - {name: 'Magdeburg', name_unique: 'Magdeburg', space_id: 7, socio: 4, stability: 3, battleground: 1, country: 1, box: {x: 58, y: 275, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [8, 10, 11, , ]}, - {name: 'Halle', name_unique: 'Halle', space_id: 8, socio: 4, stability: 3, battleground: 0, country: 1, box: {x: 175, y: 278, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [7, 10, 11, , ]}, - {name: 'Leipzig', name_unique: 'Leipzig', space_id: 9, socio: 4, stability: 3, battleground: 1, country: 1, box: {x: 297, y: 297, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [3, 6, 8, 11, 12]}, - {name: 'Erfurt', name_unique: 'Erfurt', space_id: 10, socio: 3, stability: 4, battleground: 0, country: 1, box: {x: 23, y: 356, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [7, , , , ]}, - {name: 'Karl-Marx-Stadt', name_unique: 'Karl-Marx-Stadt', space_id: 11, socio: 4, stability: 3, battleground: 1, country: 1, box: {x: 138, y: 385, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [7, 8, 9, 12, ]}, - {name: 'Dresden', name_unique: 'Dresden', space_id: 12, socio: 1, stability: 4, battleground: 1, country: 1, box: {x: 262, y: 375, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [9, 11, 19, 27, ]}, - {name: 'Szczecin', name_unique: 'Szczecin', space_id: 13, socio: 4, stability: 3, battleground: 0, country: 2, box: {x: 434, y: 204, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [14, 16, , , ]}, - {name: 'Gdansk', name_unique: 'Gdansk', space_id: 14, socio: 4, stability: 3, battleground: 1, country: 2, box: {x: 699, y: 215, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [13, 15, 16, 17, 18]}, - {name: 'Bydgoszcz', name_unique: 'Bydgoszcz', space_id: 15, socio: 1, stability: 4, battleground: 0, country: 2, box: {x: 679, y: 304, h: 65, w: 105}, demInfl: 0, comInfl: 1, demCtrl: 0, comCtrl: 0, adjacent: [15, 17, , , ]}, - {name: 'Poznan', name_unique: 'Poznan', space_id: 16, socio: 4, stability: 3, battleground: 1, country: 2, box: {x: 521, y: 355, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [13, 14, 19, 20, ]}, - {name: 'Warszawa', name_unique: 'Warszawa', space_id: 17, socio: 2, stability: 3, battleground: 1, country: 2, box: {x: 806, y: 383, h: 65, w: 105}, demInfl: 0, comInfl: 1, demCtrl: 0, comCtrl: 0, adjacent: [14, 15, 18, 21, 24]}, - {name: 'Bialystok', name_unique: 'Bialystok', space_id: 18, socio: 3, stability: 4, battleground: 0, country: 2, box: {x: 940, y: 342, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [14, 17, 24, , ]}, - {name: 'Wroclaw', name_unique: 'Wroclaw', space_id: 19, socio: 4, stability: 3, battleground: 1, country: 2, box: {x: 462, y: 443, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [12, 16, 20, 22, ]}, - {name: 'Catholic Church', name_unique: 'Catholic Church Poland', space_id: 20, socio: 7, stability: 5, battleground: 0, country: 2, box: {x: 625, y: 437, h: 65, w: 105}, demInfl: 5, comInfl: 0, demCtrl: 1, comCtrl: 0, adjacent: [16, 19, 21, 22, 23]}, - {name: 'Lodz', name_unique: 'Lodz', space_id: 21, socio: 4, stability: 3, battleground: 1, country: 2, box: {x: 749, y: 486, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [17, 20, 23, 24, ]}, - {name: 'Katowice', name_unique: 'Katowice', space_id: 22, socio: 4, stability: 3, battleground: 0, country: 2, box: {x: 570, y: 569, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [19, 20, 21, 33, ]}, - {name: 'Krakow', name_unique: 'Krakow', space_id: 23, socio: 4, stability: 3, battleground: 1, country: 2, box: {x: 711, y: 598, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [20, 21, 23, 25, ]}, - {name: 'Lublin', name_unique: 'Lublin', space_id: 24, socio: 3, stability: 4, battleground: 0, country: 2, box: {x: 879, y: 603, h: 65, w: 105}, demInfl: 0, comInfl: 1, demCtrl: 0, comCtrl: 0, adjacent: [17, 18, 21, , ]}, - {name: 'Jagiellian University', name_unique: 'Jagiellian University', space_id: 25, socio: 6, stability: 1, battleground: 0, country: 2, box: {x: 679, y: 681, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [23, 26, , , ]}, - {name: 'Polish Writers', name_unique: 'Polish Writers', space_id: 26, socio: 5, stability: 2, battleground: 0, country: 2, box: {x: 832, y: 694, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [25, , , , ]}, - {name: 'Plzen', name_unique: 'Plzen', space_id: 27, socio: 1, stability: 4, battleground: 0, country: 3, box: {x: 159, y: 483, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [12, 29, , , ]}, - {name: 'Ceske Budejovice', name_unique: 'Ceske Budejovice', space_id: 28, socio: 3, stability: 3, battleground: 0, country: 3, box: {x: 196, y: 601, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [28, 29, , , ]}, - {name: 'Praha', name_unique: 'Praha', space_id: 29, socio: 2, stability: 3, battleground: 1, country: 3, box: {x: 317, y: 614, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [27, 28, 30, 32, ]}, - {name: 'Charles University', name_unique: 'Charles University', space_id: 30, socio: 6, stability: 1, battleground: 1, country: 3, box: {x: 380, y: 532, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [29, 31, , , ]}, - {name: 'Czech Writers', name_unique: 'Czech Writers', space_id: 31, socio: 5, stability: 2, battleground: 1, country: 3, box: {x: 444, y: 607, h: 65, w: 105}, demInfl: 2, comInfl: 0, demCtrl: 1, comCtrl: 0, adjacent: [30, , , , ]}, - {name: 'Brno', name_unique: 'Brno', space_id: 32, socio: 4, stability: 3, battleground: 1, country: 3, box: {x: 403, y: 711, h: 65, w: 105}, demInfl: 0, comInfl: 1, demCtrl: 0, comCtrl: 0, adjacent: [29, 33, 34, , ]}, - {name: 'Ostrava', name_unique: 'Ostrava', space_id: 33, socio: 4, stability: 3, battleground: 1, country: 3, box: {x: 523, y: 681, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [22, 32, 34, 35, ]}, - {name: 'Bratislava', name_unique: 'Bratislava', space_id: 34, socio: 4, stability: 3, battleground: 1, country: 3, box: {x: 417, y: 797, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [32, 33, 35, , ]}, - {name: 'Catholic Church', name_unique: 'Catholic Church Czech', space_id: 35, socio: 7, stability: 5, battleground: 0, country: 3, box: {x: 538, y: 794, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [33, 34, 36, , ]}, - {name: 'Presov', name_unique: 'Presov', space_id: 36, socio: 3, stability: 4, battleground: 0, country: 3, box: {x: 658, y: 794, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [35, 37, , , ]}, - {name: 'Kosice', name_unique: 'Kosice', space_id: 37, socio: 3, stability: 4, battleground: 0, country: 3, box: {x: 777, y: 815, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [36, 42, , , ]}, - {name: 'Catholic Church', name_unique: 'Catholic Church Hungary', space_id: 38, socio: 7, stability: 5, battleground: 0, country: 4, box: {x: 314, y: 886, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [39, 43, , , ]}, - {name: 'Gyor', name_unique: 'Gyor', space_id: 39, socio: 4, stability: 3, battleground: 0, country: 4, box: {x: 434, y: 887, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [38, 40, 43, 44, ]}, - {name: 'Tatabanya', name_unique: 'Tatabanya', space_id: 40, socio: 4, stability: 3, battleground: 0, country: 4, box: {x: 549, y: 886, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [39, 41, 45, , ]}, - {name: 'Miskolc', name_unique: 'Miskolc', space_id: 41, socio: 4, stability: 3, battleground: 1, country: 4, box: {x: 664, y: 901, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [40, 42, 45, , ]}, - {name: 'Debrecen', name_unique: 'Debrecen', space_id: 42, socio: 4, stability: 3, battleground: 1, country: 4, box: {x: 781, y: 938, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [37, 41, , , ]}, - {name: 'Szombathely', name_unique: 'Szombathely', space_id: 43, socio: 1, stability: 4, battleground: 0, country: 4, box: {x: 316, y: 963, h: 65, w: 105}, demInfl: 0, comInfl: 1, demCtrl: 0, comCtrl: 0, adjacent: [38, 39, 44, , ]}, - {name: 'Szekesfehervar', name_unique: 'Szekesfehervar', space_id: 44, socio: 4, stability: 3, battleground: 0, country: 4, box: {x: 442, y: 962, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [39, 43, 45, , ]}, - {name: 'Budapest', name_unique: 'Budapest', space_id: 45, socio: 2, stability: 3, battleground: 1, country: 4, box: {x: 630, y: 983, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [4, 41, 44, 47, 48]}, - {name: 'Hungarian Writers', name_unique: 'Hungarian Writers', space_id: 46, socio: 5, stability: 2, battleground: 0, country: 4, box: {x: 348, y: 1040, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [47, , , , ]}, - {name: 'Eotvos Lorand University', name_unique: 'Eotvos Lorand University', space_id: 47, socio: 6, stability: 1, battleground: 0, country: 4, box: {x: 512, y: 1034, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [46, 45, , , ]}, - {name: 'Szeged', name_unique: 'Szeged', space_id: 48, socio: 3, stability: 4, battleground: 1, country: 4, box: {x: 632, y: 1073, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [45, 49, 50, , ]}, - {name: 'Pecs', name_unique: 'Pecs', space_id: 49, socio: 3, stability: 4, battleground: 1, country: 4, box: {x: 486, y: 1105, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [48, , , , ]}, - {name: 'Timisoara', name_unique: 'Timisoara', space_id: 50, socio: 4, stability: 3, battleground: 1, country: 5, box: {x: 597, y: 1204, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [48, 51, 60, , ]}, - {name: 'Cluj-Napoca', name_unique: 'Cluj-Napoca', space_id: 51, socio: 1, stability: 4, battleground: 1, country: 5, box: {x: 756, y: 1125, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [50, 54, 58, , ]}, - {name: 'Targu Mures', name_unique: 'Targu Mures', space_id: 52, socio: 3, stability: 4, battleground: 0, country: 5, box: {x: 915, y: 1136, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [53, 56, , , ]}, - {name: 'Iasi', name_unique: 'Iasi', space_id: 53, socio: 4, stability: 3, battleground: 1, country: 5, box: {x: 1072, y: 1097, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [52, 57, 62, , ]}, - {name: 'Babes-Bolyai University', name_unique: 'Babes-Bolyai University', space_id: 54, socio: 6, stability: 1, battleground: 0, country: 5, box: {x: 746, y: 1203, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [51, 55, , , ]}, - {name: 'Romanian Writers', name_unique: 'Romanian Writers', space_id: 55, socio: 5, stability: 2, battleground: 0, country: 5, box: {x: 739, y: 1278, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [54, , , , ]}, - {name: 'Hargita/Covasna', name_unique: 'Hargita/Covasna', space_id: 56, socio: 8, stability: 4, battleground: 0, country: 5, box: {x: 928, y: 1227, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [52, , , , ]}, - {name: 'Brasov', name_unique: 'Brasov', space_id: 57, socio: 4, stability: 3, battleground: 1, country: 5, box: {x: 1049, y: 1225, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [53, 59, 61, , ]}, - {name: 'Orthodox Church', name_unique: 'Orthodox Church Romania', space_id: 58, socio: 7, stability: 3, battleground: 0, country: 5, box: {x: 855, y: 1338, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [51, 60, , , ]}, - {name: 'Ploiesti', name_unique: 'Ploiesti', space_id: 59, socio: 4, stability: 3, battleground: 0, country: 5, box: {x: 1061, y: 1316, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [57, 61, 62, , ]}, - {name: 'Craiova', name_unique: 'Craiova', space_id: 60, socio: 3, stability: 4, battleground: 0, country: 5, box: {x: 763, y: 1411, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [50, 58, 61, , ]}, - {name: 'Bucuresti', name_unique: 'Bucuresti', space_id: 61, socio: 2, stability: 3, battleground: 1, country: 5, box: {x: 929, y: 1445, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [51, 57, 59, 60, 63]}, - {name: 'Galatii', name_unique: 'Galatii', space_id: 62, socio: 4, stability: 3, battleground: 1, country: 5, box: {x: 1104, y: 1399, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [53, 59, 63, , ]}, - {name: 'Constanta', name_unique: 'Constanta', space_id: 63, socio: 4, stability: 3, battleground: 0, country: 5, box: {x: 1130, y: 1517, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [61, 62, 72, , ]}, - {name: 'Pleven', name_unique: 'Pleven', space_id: 64, socio: 3, stability: 4, battleground: 0, country: 6, box: {x: 764, y: 1534, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [67, , , , ]}, - {name: 'Orthodox Church', name_unique: 'Orthodox Church Bulgaria', space_id: 65, socio: 7, stability: 3, battleground: 0, country: 6, box: {x: 882, y: 1540, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [66, 68, , , ]}, - {name: 'Ruse', name_unique: 'Ruse', space_id: 66, socio: 4, stability: 3, battleground: 1, country: 6, box: {x: 998, y: 1540, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [65, 69, 70, 71, 72]}, - {name: 'Sofia University', name_unique: 'Sofia University', space_id: 67, socio: 6, stability: 1, battleground: 0, country: 6, box: {x: 645, y: 1650, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [68, 73, , , ]}, - {name: 'Sofia', name_unique: 'Sofia', space_id: 68, socio: 2, stability: 3, battleground: 1, country: 6, box: {x: 768, y: 1653, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [64, 65, 67, 69, 74]}, - {name: 'Stara Zagora', name_unique: 'Stara Zagora', space_id: 69, socio: 1, stability: 4, battleground: 0, country: 6, box: {x: 886, y: 1694, h: 65, w: 105}, demInfl: 0, comInfl: 1, demCtrl: 0, comCtrl: 0, adjacent: [66, 68, 71, , ]}, - {name: 'Razgrad', name_unique: 'Razgrad', space_id: 70, socio: 8, stability: 4, battleground: 0, country: 6, box: {x: 954, y: 1620, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [66, , , , ]}, - {name: 'Burgas', name_unique: 'Burgas', space_id: 71, socio: 4, stability: 3, battleground: 1, country: 6, box: {x: 1004, y: 1695, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [66, 69, 72, , ]}, - {name: 'Varna', name_unique: 'Varna', space_id: 72, socio: 4, stability: 3, battleground: 1, country: 6, box: {x: 1086, y: 1613, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [63, 66, 71, , ]}, - {name: 'Bulgarian Writers', name_unique: 'Bulgarian Writers', space_id: 73, socio: 5, stability: 2, battleground: 0, country: 6, box: {x: 652, y: 1726, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [67, , , , ]}, - {name: 'Plovdiv', name_unique: 'Plovdiv', space_id: 74, socio: 4, stability: 3, battleground: 1, country: 6, box: {x: 771, y: 1739, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [68, 75, , , ]}, - {name: 'Sliven', name_unique: 'Sliven', space_id: 75, socio: 3, stability: 4, battleground: 0, country: 6, box: {x: 894, y: 1768, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [75, , , , ]}, - ] +{name: 'Schwerin', name_unique: 'Schwerin', space_id: 1, socio: 4, stability: 3, battleground: 0, country: 'East Germany', box: {x: 111, y: 61, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [2, 3, , , ]}, +{name: 'Rostock', name_unique: 'Rostock', space_id: 2, socio: 4, stability: 3, battleground: 0, country: 'East Germany', box: {x: 228, y: 41, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [1, 3, , , ]}, +{name: 'Berlin', name_unique: 'Berlin', space_id: 3, socio: 2, stability: 3, battleground: 1, country: 'East Germany', box: {x: 251, y: 113, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [1, 2, 5, 9, ]}, +{name: 'German Writers', name_unique: 'German Writers', space_id: 4, socio: 5, stability: 2, battleground: 0, country: 'East Germany', box: {x: 58, y: 185, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [5, , , , ]}, +{name: 'Walter Ulbricht Academy', name_unique: 'Walter Ulbricht Academy', space_id: 5, socio: 6, stability: 1, battleground: 0, country: 'East Germany', box: {x: 175, y: 187, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [3, 4, , , ]}, +{name: 'Lutherian Church', name_unique: 'Lutherian Church', space_id: 6, socio: 7, stability: 5, battleground: 1, country: 'East Germany', box: {x: 300, y: 212, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [9, , , , ]}, +{name: 'Magdeburg', name_unique: 'Magdeburg', space_id: 7, socio: 4, stability: 3, battleground: 1, country: 'East Germany', box: {x: 58, y: 275, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [8, 10, 11, , ]}, +{name: 'Halle', name_unique: 'Halle', space_id: 8, socio: 4, stability: 3, battleground: 0, country: 'East Germany', box: {x: 175, y: 278, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [7, 10, 11, , ]}, +{name: 'Leipzig', name_unique: 'Leipzig', space_id: 9, socio: 4, stability: 3, battleground: 1, country: 'East Germany', box: {x: 297, y: 297, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [3, 6, 8, 11, 12]}, +{name: 'Erfurt', name_unique: 'Erfurt', space_id: 10, socio: 3, stability: 4, battleground: 0, country: 'East Germany', box: {x: 23, y: 356, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [7, , , , ]}, +{name: 'Karl-Marx-Stadt', name_unique: 'Karl-Marx-Stadt', space_id: 11, socio: 4, stability: 3, battleground: 1, country: 'East Germany', box: {x: 138, y: 385, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [7, 8, 9, 12, ]}, +{name: 'Dresden', name_unique: 'Dresden', space_id: 12, socio: 1, stability: 4, battleground: 1, country: 'East Germany', box: {x: 262, y: 375, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [9, 11, 19, 27, ]}, +{name: 'Szczecin', name_unique: 'Szczecin', space_id: 13, socio: 4, stability: 3, battleground: 0, country: 'Poland', box: {x: 434, y: 204, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [14, 16, , , ]}, +{name: 'Gdansk', name_unique: 'Gdansk', space_id: 14, socio: 4, stability: 3, battleground: 1, country: 'Poland', box: {x: 699, y: 215, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [13, 15, 16, 17, 18]}, +{name: 'Bydgoszcz', name_unique: 'Bydgoszcz', space_id: 15, socio: 1, stability: 4, battleground: 0, country: 'Poland', box: {x: 679, y: 304, h: 65, w: 105}, demInfl: 0, comInfl: 1, demCtrl: 0, comCtrl: 0, adjacent: [15, 17, , , ]}, +{name: 'Poznan', name_unique: 'Poznan', space_id: 16, socio: 4, stability: 3, battleground: 1, country: 'Poland', box: {x: 521, y: 355, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [13, 14, 19, 20, ]}, +{name: 'Warszawa', name_unique: 'Warszawa', space_id: 17, socio: 2, stability: 3, battleground: 1, country: 'Poland', box: {x: 806, y: 383, h: 65, w: 105}, demInfl: 0, comInfl: 1, demCtrl: 0, comCtrl: 0, adjacent: [14, 15, 18, 21, 24]}, +{name: 'Bialystok', name_unique: 'Bialystok', space_id: 18, socio: 3, stability: 4, battleground: 0, country: 'Poland', box: {x: 940, y: 342, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [14, 17, 24, , ]}, +{name: 'Wroclaw', name_unique: 'Wroclaw', space_id: 19, socio: 4, stability: 3, battleground: 1, country: 'Poland', box: {x: 462, y: 443, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [12, 16, 20, 22, ]}, +{name: 'Catholic Church', name_unique: 'Catholic Church Poland', space_id: 20, socio: 7, stability: 5, battleground: 0, country: 'Poland', box: {x: 625, y: 437, h: 65, w: 105}, demInfl: 5, comInfl: 0, demCtrl: 1, comCtrl: 0, adjacent: [16, 19, 21, 22, 23]}, +{name: 'Lodz', name_unique: 'Lodz', space_id: 21, socio: 4, stability: 3, battleground: 1, country: 'Poland', box: {x: 749, y: 486, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [17, 20, 23, 24, ]}, +{name: 'Katowice', name_unique: 'Katowice', space_id: 22, socio: 4, stability: 3, battleground: 0, country: 'Poland', box: {x: 570, y: 569, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [19, 20, 21, 33, ]}, +{name: 'Krakow', name_unique: 'Krakow', space_id: 23, socio: 4, stability: 3, battleground: 1, country: 'Poland', box: {x: 711, y: 598, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [20, 21, 23, 25, ]}, +{name: 'Lublin', name_unique: 'Lublin', space_id: 24, socio: 3, stability: 4, battleground: 0, country: 'Poland', box: {x: 879, y: 603, h: 65, w: 105}, demInfl: 0, comInfl: 1, demCtrl: 0, comCtrl: 0, adjacent: [17, 18, 21, , ]}, +{name: 'Jagiellian University', name_unique: 'Jagiellian University', space_id: 25, socio: 6, stability: 1, battleground: 0, country: 'Poland', box: {x: 679, y: 681, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [23, 26, , , ]}, +{name: 'Polish Writers', name_unique: 'Polish Writers', space_id: 26, socio: 5, stability: 2, battleground: 0, country: 'Poland', box: {x: 832, y: 694, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [25, , , , ]}, +{name: 'Plzen', name_unique: 'Plzen', space_id: 27, socio: 1, stability: 4, battleground: 0, country: 'Czechoslovakia', box: {x: 159, y: 483, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [12, 29, , , ]}, +{name: 'Ceske Budejovice', name_unique: 'Ceske Budejovice', space_id: 28, socio: 3, stability: 3, battleground: 0, country: 'Czechoslovakia', box: {x: 196, y: 601, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [28, 29, , , ]}, +{name: 'Praha', name_unique: 'Praha', space_id: 29, socio: 2, stability: 3, battleground: 1, country: 'Czechoslovakia', box: {x: 317, y: 614, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [27, 28, 30, 32, ]}, +{name: 'Charles University', name_unique: 'Charles University', space_id: 30, socio: 6, stability: 1, battleground: 1, country: 'Czechoslovakia', box: {x: 380, y: 532, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [29, 31, , , ]}, +{name: 'Czech Writers', name_unique: 'Czech Writers', space_id: 31, socio: 5, stability: 2, battleground: 1, country: 'Czechoslovakia', box: {x: 444, y: 607, h: 65, w: 105}, demInfl: 2, comInfl: 0, demCtrl: 1, comCtrl: 0, adjacent: [30, , , , ]}, +{name: 'Brno', name_unique: 'Brno', space_id: 32, socio: 4, stability: 3, battleground: 1, country: 'Czechoslovakia', box: {x: 403, y: 711, h: 65, w: 105}, demInfl: 0, comInfl: 1, demCtrl: 0, comCtrl: 0, adjacent: [29, 33, 34, , ]}, +{name: 'Ostrava', name_unique: 'Ostrava', space_id: 33, socio: 4, stability: 3, battleground: 1, country: 'Czechoslovakia', box: {x: 523, y: 681, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [22, 32, 34, 35, ]}, +{name: 'Bratislava', name_unique: 'Bratislava', space_id: 34, socio: 4, stability: 3, battleground: 1, country: 'Czechoslovakia', box: {x: 417, y: 797, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [32, 33, 35, , ]}, +{name: 'Catholic Church', name_unique: 'Catholic Church Czech', space_id: 35, socio: 7, stability: 5, battleground: 0, country: 'Czechoslovakia', box: {x: 538, y: 794, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [33, 34, 36, , ]}, +{name: 'Presov', name_unique: 'Presov', space_id: 36, socio: 3, stability: 4, battleground: 0, country: 'Czechoslovakia', box: {x: 658, y: 794, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [35, 37, , , ]}, +{name: 'Kosice', name_unique: 'Kosice', space_id: 37, socio: 3, stability: 4, battleground: 0, country: 'Czechoslovakia', box: {x: 777, y: 815, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [36, 42, , , ]}, +{name: 'Catholic Church', name_unique: 'Catholic Church Hungary', space_id: 38, socio: 7, stability: 5, battleground: 0, country: 'Hungary', box: {x: 314, y: 886, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [39, 43, , , ]}, +{name: 'Gyor', name_unique: 'Gyor', space_id: 39, socio: 4, stability: 3, battleground: 0, country: 'Hungary', box: {x: 434, y: 887, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [38, 40, 43, 44, ]}, +{name: 'Tatabanya', name_unique: 'Tatabanya', space_id: 40, socio: 4, stability: 3, battleground: 0, country: 'Hungary', box: {x: 549, y: 886, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [39, 41, 45, , ]}, +{name: 'Miskolc', name_unique: 'Miskolc', space_id: 41, socio: 4, stability: 3, battleground: 1, country: 'Hungary', box: {x: 664, y: 901, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [40, 42, 45, , ]}, +{name: 'Debrecen', name_unique: 'Debrecen', space_id: 42, socio: 4, stability: 3, battleground: 1, country: 'Hungary', box: {x: 781, y: 938, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [37, 41, , , ]}, +{name: 'Szombathely', name_unique: 'Szombathely', space_id: 43, socio: 1, stability: 4, battleground: 0, country: 'Hungary', box: {x: 316, y: 963, h: 65, w: 105}, demInfl: 0, comInfl: 1, demCtrl: 0, comCtrl: 0, adjacent: [38, 39, 44, , ]}, +{name: 'Szekesfehervar', name_unique: 'Szekesfehervar', space_id: 44, socio: 4, stability: 3, battleground: 0, country: 'Hungary', box: {x: 442, y: 962, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [39, 43, 45, , ]}, +{name: 'Budapest', name_unique: 'Budapest', space_id: 45, socio: 2, stability: 3, battleground: 1, country: 'Hungary', box: {x: 630, y: 983, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [41, 42, 44, 47, 48]}, +{name: 'Hungarian Writers', name_unique: 'Hungarian Writers', space_id: 46, socio: 5, stability: 2, battleground: 0, country: 'Hungary', box: {x: 348, y: 1040, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [47, , , , ]}, +{name: 'Eotvos Lorand University', name_unique: 'Eotvos Lorand University', space_id: 47, socio: 6, stability: 1, battleground: 0, country: 'Hungary', box: {x: 512, y: 1034, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [46, 45, , , ]}, +{name: 'Szeged', name_unique: 'Szeged', space_id: 48, socio: 3, stability: 4, battleground: 1, country: 'Hungary', box: {x: 632, y: 1073, h: 65, w: 105}, demInfl: 1, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [45, 49, 50, , ]}, +{name: 'Pecs', name_unique: 'Pecs', space_id: 49, socio: 3, stability: 4, battleground: 1, country: 'Hungary', box: {x: 486, y: 1105, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [48, , , , ]}, +{name: 'Timisoara', name_unique: 'Timisoara', space_id: 50, socio: 4, stability: 3, battleground: 1, country: 'Romania', box: {x: 597, y: 1204, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [48, 51, 60, , ]}, +{name: 'Cluj-Napoca', name_unique: 'Cluj-Napoca', space_id: 51, socio: 1, stability: 4, battleground: 1, country: 'Romania', box: {x: 756, y: 1125, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [50, 54, 58, , ]}, +{name: 'Targu Mures', name_unique: 'Targu Mures', space_id: 52, socio: 3, stability: 4, battleground: 0, country: 'Romania', box: {x: 915, y: 1136, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [53, 56, , , ]}, +{name: 'Iasi', name_unique: 'Iasi', space_id: 53, socio: 4, stability: 3, battleground: 1, country: 'Romania', box: {x: 1072, y: 1097, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [52, 57, 62, , ]}, +{name: 'Babes-Bolyai University', name_unique: 'Babes-Bolyai University', space_id: 54, socio: 6, stability: 1, battleground: 0, country: 'Romania', box: {x: 746, y: 1203, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [51, 55, , , ]}, +{name: 'Romanian Writers', name_unique: 'Romanian Writers', space_id: 55, socio: 5, stability: 2, battleground: 0, country: 'Romania', box: {x: 739, y: 1278, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [54, , , , ]}, +{name: 'Hargita/Covasna', name_unique: 'Hargita/Covasna', space_id: 56, socio: 8, stability: 4, battleground: 0, country: 'Romania', box: {x: 928, y: 1227, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [52, , , , ]}, +{name: 'Brasov', name_unique: 'Brasov', space_id: 57, socio: 4, stability: 3, battleground: 1, country: 'Romania', box: {x: 1049, y: 1225, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [53, 59, 61, , ]}, +{name: 'Orthodox Church', name_unique: 'Orthodox Church Romania', space_id: 58, socio: 7, stability: 3, battleground: 0, country: 'Romania', box: {x: 855, y: 1338, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [51, 60, , , ]}, +{name: 'Ploiesti', name_unique: 'Ploiesti', space_id: 59, socio: 4, stability: 3, battleground: 0, country: 'Romania', box: {x: 1061, y: 1316, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [57, 61, 62, , ]}, +{name: 'Craiova', name_unique: 'Craiova', space_id: 60, socio: 3, stability: 4, battleground: 0, country: 'Romania', box: {x: 763, y: 1411, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [50, 58, 61, , ]}, +{name: 'Bucuresti', name_unique: 'Bucuresti', space_id: 61, socio: 2, stability: 3, battleground: 1, country: 'Romania', box: {x: 929, y: 1445, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [51, 57, 59, 60, 63]}, +{name: 'Galatii', name_unique: 'Galatii', space_id: 62, socio: 4, stability: 3, battleground: 1, country: 'Romania', box: {x: 1104, y: 1399, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [53, 59, 63, , ]}, +{name: 'Constanta', name_unique: 'Constanta', space_id: 63, socio: 4, stability: 3, battleground: 0, country: 'Romania', box: {x: 1130, y: 1517, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [61, 62, 72, , ]}, +{name: 'Pleven', name_unique: 'Pleven', space_id: 64, socio: 3, stability: 4, battleground: 0, country: 'Bulgaria', box: {x: 764, y: 1534, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [67, , , , ]}, +{name: 'Orthodox Church', name_unique: 'Orthodox Church Bulgaria', space_id: 65, socio: 7, stability: 3, battleground: 0, country: 'Bulgaria', box: {x: 882, y: 1540, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [66, 68, , , ]}, +{name: 'Ruse', name_unique: 'Ruse', space_id: 66, socio: 4, stability: 3, battleground: 1, country: 'Bulgaria', box: {x: 998, y: 1540, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [65, 69, 70, 71, 72]}, +{name: 'Sofia University', name_unique: 'Sofia University', space_id: 67, socio: 6, stability: 1, battleground: 0, country: 'Bulgaria', box: {x: 645, y: 1650, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [68, 73, , , ]}, +{name: 'Sofia', name_unique: 'Sofia', space_id: 68, socio: 2, stability: 3, battleground: 1, country: 'Bulgaria', box: {x: 768, y: 1653, h: 65, w: 105}, demInfl: 0, comInfl: 2, demCtrl: 0, comCtrl: 0, adjacent: [64, 65, 67, 69, 74]}, +{name: 'Stara Zagora', name_unique: 'Stara Zagora', space_id: 69, socio: 1, stability: 4, battleground: 0, country: 'Bulgaria', box: {x: 886, y: 1694, h: 65, w: 105}, demInfl: 0, comInfl: 1, demCtrl: 0, comCtrl: 0, adjacent: [66, 68, 71, , ]}, +{name: 'Razgrad', name_unique: 'Razgrad', space_id: 70, socio: 8, stability: 4, battleground: 0, country: 'Bulgaria', box: {x: 954, y: 1620, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [66, , , , ]}, +{name: 'Burgas', name_unique: 'Burgas', space_id: 71, socio: 4, stability: 3, battleground: 1, country: 'Bulgaria', box: {x: 1004, y: 1695, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [66, 69, 72, , ]}, +{name: 'Varna', name_unique: 'Varna', space_id: 72, socio: 4, stability: 3, battleground: 1, country: 'Bulgaria', box: {x: 1086, y: 1613, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [63, 66, 71, , ]}, +{name: 'Bulgarian Writers', name_unique: 'Bulgarian Writers', space_id: 73, socio: 5, stability: 2, battleground: 0, country: 'Bulgaria', box: {x: 652, y: 1726, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [67, , , , ]}, +{name: 'Plovdiv', name_unique: 'Plovdiv', space_id: 74, socio: 4, stability: 3, battleground: 1, country: 'Bulgaria', box: {x: 771, y: 1739, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [68, 75, , , ]}, +{name: 'Sliven', name_unique: 'Sliven', space_id: 75, socio: 3, stability: 4, battleground: 0, country: 'Bulgaria', box: {x: 894, y: 1768, h: 65, w: 105}, demInfl: 0, comInfl: 0, demCtrl: 0, comCtrl: 0, adjacent: [75, , , , ]}, + ] const cards = [ null, - {number: 1, period: 1, side: 'C', name: 'Legacy of Martial Law*', ops: 2, remove: 1}, - {number: 2, period: 1, side: 'D', name: 'Solidarity Legalized*', ops: 4, remove: 1}, - {number: 3, period: 1, side: 'D', name: 'Walesa*', ops: 3, remove: 1}, - {number: 4, period: 1, side: 'D', name: 'Michnik*', ops: 1, remove: 1}, - {number: 5, period: 1, side: 'D', name: 'General Strike', ops: 3, remove: 0}, - {number: 6, period: 1, side: 'C', name: 'Brought in for Questioning', ops: 3, remove: 0}, - {number: 7, period: 1, side: 'C', name: 'State Run Media*', ops: 2, remove: 1}, - {number: 8, period: 1, side: 'N', name: 'Prudence', ops: 4, remove: 0}, - {number: 9, period: 1, side: 'C', name: 'The Wall*', ops: 1, remove: 1}, - {number: 10, period: 1, side: 'C', name: 'Cult of Personality*', ops: 3, remove: 1}, - {number: 11, period: 1, side: 'C', name: 'Dissident Arrested', ops: 2, remove: 0}, - {number: 12, period: 1, side: 'C', name: 'Apparatchiks*', ops: 2, remove: 1}, - {number: 13, period: 1, side: 'C', name: 'Stasi*', ops: 1, remove: 1}, - {number: 14, period: 1, side: 'N', name: 'Gorbachev Charms the West', ops: 4, remove: 0}, - {number: 15, period: 1, side: 'C', name: 'Honecker*', ops: 3, remove: 1}, - {number: 16, period: 1, side: 'C', name: 'Nomenklatura*', ops: 2, remove: 1}, - {number: 17, period: 1, side: 'D', name: 'Roundtable Talks', ops: 3, remove: 0}, - {number: 18, period: 1, side: 'C', name: 'Poszgay Defends the Revolution*', ops: 2, remove: 1}, - {number: 19, period: 1, side: 'D', name: 'Papal Visit*', ops: 2, remove: 1}, - {number: 20, period: 1, side: 'C', name: 'Deutsche Marks*', ops: 4, remove: 1}, - {number: 21, period: 1, side: 'N', name: 'Common European Home', ops: 2, remove: 0}, - {number: 22, period: 1, side: 'N', name: 'Power Struggle - Poland', ops: 0, remove: 0}, - {number: 23, period: 1, side: 'N', name: 'Power Struggle - Hungary', ops: 0, remove: 0}, - {number: 24, period: 1, side: 'D', name: 'St. Nicholas Church*', ops: 1, remove: 1}, - {number: 25, period: 1, side: 'C', name: 'Perestroika*', ops: 3, remove: 1}, - {number: 26, period: 1, side: 'D', name: 'Helsinki Final Act*', ops: 1, remove: 1}, - {number: 27, period: 1, side: 'D', name: 'Consumerism', ops: 3, remove: 0}, - {number: 28, period: 1, side: 'C', name: 'Factory Party Cells', ops: 3, remove: 0}, - {number: 29, period: 1, side: 'D', name: 'Jan Palach Week*', ops: 1, remove: 1}, - {number: 30, period: 1, side: 'C', name: 'Tear Gas*', ops: 1, remove: 1}, - {number: 31, period: 1, side: 'D', name: 'Intelligentsia', ops: 2, remove: 0}, - {number: 32, period: 1, side: 'C', name: 'Peasant Parties*', ops: 2, remove: 1}, - {number: 33, period: 1, side: 'D', name: 'Sajudis*', ops: 2, remove: 1}, - {number: 34, period: 1, side: 'D', name: 'Fidesz*', ops: 2, remove: 1}, - {number: 35, period: 1, side: 'C', name: 'Heal Our Bleeding Wound', ops: 3, remove: 0}, - {number: 36, period: 1, side: 'D', name: 'Dash for the West*', ops: 3, remove: 1}, - {number: 37, period: 1, side: 'C', name: 'Nagy Reburied*', ops: 3, remove: 1}, - {number: 38, period: 1, side: 'C', name: 'The July Concept*', ops: 3, remove: 1}, - {number: 39, period: 1, side: 'D', name: 'Eco-Glasnost*', ops: 2, remove: 1}, - {number: 40, period: 1, side: 'D', name: 'Hungarian Democratic Forum*', ops: 3, remove: 1}, - {number: 41, period: 2, side: 'C', name: 'Ceausescu*', ops: 3, remove: 1}, - {number: 42, period: 2, side: 'N', name: 'Power Struggle - East Germany', ops: 0, remove: 0}, - {number: 43, period: 2, side: 'N', name: 'Power Struggle - Bulgaria', ops: 0, remove: 0}, - {number: 44, period: 2, side: 'N', name: 'Inflationary Currency*', ops: 3, remove: 1}, - {number: 45, period: 2, side: 'D', name: 'Soviet Troop Withdrawals*', ops: 4, remove: 1}, - {number: 46, period: 2, side: 'D', name: 'Goodbye Lenin!*', ops: 3, remove: 1}, - {number: 47, period: 2, side: 'C', name: 'Bulgarian Turks expelled*', ops: 3, remove: 1}, - {number: 48, period: 2, side: 'D', name: '\"We are the People!\"', ops: 3, remove: 0}, - {number: 49, period: 2, side: 'D', name: 'Foreign Currency Debt Burden', ops: 1, remove: 0}, - {number: 50, period: 2, side: 'D', name: 'This Sinatra Doctrine*', ops: 3, remove: 1}, - {number: 51, period: 2, side: 'C', name: '40th Anniversary Celebration*', ops: 2, remove: 1}, - {number: 52, period: 2, side: 'C', name: 'Normalization*', ops: 3, remove: 1}, - {number: 53, period: 2, side: 'C', name: 'Li Peng*', ops: 2, remove: 1}, - {number: 54, period: 3, side: 'D', name: 'The Crowd Turns Against Ceausescu*', ops: 3, remove: 1}, - {number: 55, period: 2, side: 'N', name: 'Power Struggle - Czechoslovakia', ops: 0, remove: 0}, - {number: 56, period: 2, side: 'D', name: 'Foreign Television*', ops: 2, remove: 1}, - {number: 57, period: 2, side: 'C', name: 'Central Committee Reshuffle*', ops: 2, remove: 1}, - {number: 58, period: 2, side: 'D', name: 'Austria-Hungary Border Reopened*', ops: 2, remove: 1}, - {number: 59, period: 2, side: 'C', name: 'GrenzTruppen*', ops: 2, remove: 1}, - {number: 60, period: 2, side: 'D', name: 'Toxic Waste*', ops: 2, remove: 1}, - {number: 61, period: 2, side: 'D', name: 'The Monday Demonstrations*', ops: 4, remove: 1}, - {number: 62, period: 2, side: 'D', name: 'Yakovlev Counsels Gorbachev*', ops: 2, remove: 1}, - {number: 63, period: 2, side: 'D', name: 'Genscher*', ops: 2, remove: 1}, - {number: 64, period: 2, side: 'D', name: 'Legacy of 1968*', ops: 4, remove: 1}, - {number: 65, period: 2, side: 'D', name: 'Presidential Visit*', ops: 3, remove: 1}, - {number: 66, period: 2, side: 'D', name: 'New Forum*', ops: 1, remove: 1}, - {number: 67, period: 2, side: 'N', name: 'Reformer Rehabilitated*', ops: 2, remove: 1}, - {number: 68, period: 2, side: 'D', name: 'Klaus and Komarek*', ops: 3, remove: 1}, - {number: 69, period: 2, side: 'C', name: 'Systematization*', ops: 3, remove: 1}, - {number: 70, period: 3, side: 'C', name: 'Securitate*', ops: 2, remove: 1}, - {number: 71, period: 2, side: 'D', name: 'Kiss of Death*', ops: 3, remove: 1}, - {number: 72, period: 2, side: 'D', name: 'Peasant Parties Revolt*', ops: 3, remove: 1}, - {number: 73, period: 2, side: 'D', name: 'Laszlo Tokes*', ops: 2, remove: 1}, - {number: 74, period: 2, side: 'D', name: 'FRG Embassies*', ops: 3, remove: 1}, - {number: 75, period: 2, side: 'D', name: 'Exit Visas*', ops: 3, remove: 1}, - {number: 76, period: 2, side: 'C', name: 'Warsaw Pact Summit*', ops: 2, remove: 1}, - {number: 77, period: 2, side: 'D', name: 'Samizdat*', ops: 3, remove: 1}, - {number: 78, period: 2, side: 'N', name: 'Workers Revolt', ops: 2, remove: 0}, - {number: 79, period: 2, side: 'C', name: 'The Third Way*', ops: 2, remove: 1}, - {number: 80, period: 2, side: 'C', name: 'Nepotism*', ops: 3, remove: 1}, - {number: 81, period: 2, side: 'D', name: 'The Baltic Way*', ops: 3, remove: 1}, - {number: 82, period: 3, side: 'C', name: 'Spitzel*', ops: 1, remove: 1}, - {number: 83, period: 3, side: 'C', name: 'Modrow*', ops: 2, remove: 1}, - {number: 84, period: 3, side: 'D', name: 'Breakaway Baltic Republics*', ops: 4, remove: 1}, - {number: 85, period: 3, side: 'N', name: 'Tank Column/Tank Man*', ops: 2, remove: 1}, - {number: 86, period: 3, side: 'D', name: '\"The Wall Must Go!*\"', ops: 3, remove: 0}, - {number: 87, period: 3, side: 'D', name: 'Kohl Proposes Reunification*', ops: 3, remove: 1}, - {number: 88, period: 3, side: 'C', name: 'Adamec*', ops: 2, remove: 1}, - {number: 89, period: 3, side: 'D', name: 'Domino Theory*', ops: 3, remove: 1}, - {number: 90, period: 3, side: 'D', name: 'Civic Forum*', ops: 4, remove: 1}, - {number: 91, period: 3, side: 'D', name: 'My First Banana*', ops: 3, remove: 1}, - {number: 92, period: 3, side: 'C', name: 'Betrayal*', ops: 3, remove: 1}, - {number: 93, period: 3, side: 'D', name: 'Shock Therapy*', ops: 3, remove: 1}, - {number: 94, period: 3, side: 'D', name: 'Union of Democratic Forces*', ops: 4, remove: 1}, - {number: 95, period: 3, side: 'N', name: 'Power Struggle - Romania', ops: 0, remove: 0}, - {number: 96, period: 3, side: 'C', name: 'The Chinese Solution*', ops: 1, remove: 1}, - {number: 97, period: 3, side: 'D', name: 'The Tyrant is Gone*', ops: 2, remove: 1}, - {number: 98, period: 3, side: 'C', name: 'Politburo Intrigue*', ops: 2, remove: 1}, - {number: 99, period: 3, side: 'C', name: 'Ligachev*', ops: 3, remove: 1}, - {number: 100, period: 3, side: 'N', name: 'Stand Fast*', ops: 3, remove: 1}, - {number: 101, period: 3, side: 'C', name: 'Elena*', ops: 1, remove: 1}, - {number: 102, period: 3, side: 'C', name: 'National Salvation Front*', ops: 3, remove: 1}, - {number: 103, period: 3, side: 'D', name: 'Government Resigns*', ops: 3, remove: 1}, - {number: 104, period: 3, side: 'C', name: 'New Year\'s Eve Party*', ops: 2, remove: 1}, - {number: 105, period: 3, side: 'D', name: 'Public Against Violence*', ops: 3, remove: 1}, - {number: 106, period: 3, side: 'C', name: 'Social Democratic Platform Adopted*', ops: 2, remove: 1}, - {number: 107, period: 3, side: 'C', name: 'Massacre in Timisoara*', ops: 3, remove: 1}, - {number: 108, period: 3, side: 'D', name: 'Army Backs Revolution*', ops: 3, remove: 1}, - {number: 109, period: 3, side: 'C', name: 'Kremlin Coup!*', ops: 3, remove: 1}, - {number: 110, period: 3, side: 'D', name: 'Malta Summit*', ops: 3, remove: 1}, - + {number: 1, period: 1, side: 'C', name: 'Legacy of Martial Law*', ops: 2, remove: 1, playable: 1}, + {number: 2, period: 1, side: 'D', name: 'Solidarity Legalized*', ops: 4, remove: 1, playable: 1}, + {number: 3, period: 1, side: 'D', name: 'Walesa*', ops: 3, remove: 1, playable: 0}, + {number: 4, period: 1, side: 'D', name: 'Michnik*', ops: 1, remove: 1, playable: 1}, + {number: 5, period: 1, side: 'D', name: 'General Strike', ops: 3, remove: 0, playable: 1}, + {number: 6, period: 1, side: 'C', name: 'Brought in for Questioning', ops: 3, remove: 0, playable: 1}, + {number: 7, period: 1, side: 'C', name: 'State Run Media*', ops: 2, remove: 1, playable: 1}, + {number: 8, period: 3, side: 'C', name: 'The Chinese Solution*', ops: 1, remove: 1, playable: 1}, + {number: 9, period: 1, side: 'C', name: 'The Wall*', ops: 1, remove: 1, playable: 1}, + {number: 10, period: 1, side: 'C', name: 'Cult of Personality*', ops: 3, remove: 1, playable: 1}, + {number: 11, period: 1, side: 'C', name: 'Dissident Arrested', ops: 2, remove: 0, playable: 1}, + {number: 12, period: 1, side: 'C', name: 'Apparatchiks*', ops: 2, remove: 1, playable: 1}, + {number: 13, period: 1, side: 'C', name: 'Stasi*', ops: 1, remove: 1, playable: 1}, + {number: 14, period: 2, side: 'C', name: 'Ceausescu*', ops: 3, remove: 1, playable: 1}, + {number: 15, period: 1, side: 'C', name: 'Honecker*', ops: 3, remove: 1, playable: 1}, + {number: 16, period: 1, side: 'C', name: 'Nomenklatura*', ops: 2, remove: 1, playable: 1}, + {number: 17, period: 2, side: 'N', name: 'Power Struggle - East Germany', ops: 0, remove: 0, playable: 1}, + {number: 18, period: 2, side: 'N', name: 'Power Struggle - Czechoslovakia', ops: 0, remove: 0, playable: 1}, + {number: 19, period: 2, side: 'N', name: 'Power Struggle - Bulgaria', ops: 0, remove: 0, playable: 1}, + {number: 20, period: 2, side: 'N', name: 'Workers Revolt', ops: 2, remove: 0, playable: 1}, + {number: 21, period: 3, side: 'N', name: 'Power Struggle - Romania', ops: 0, remove: 0, playable: 1}, + {number: 22, period: 1, side: 'N', name: 'Power Struggle - Poland', ops: 0, remove: 0, playable: 1}, + {number: 23, period: 1, side: 'N', name: 'Power Struggle - Hungary', ops: 0, remove: 0, playable: 1}, + {number: 24, period: 3, side: 'C', name: 'Betrayal*', ops: 3, remove: 1, playable: 1}, + {number: 25, period: 2, side: 'D', name: 'Genscher*', ops: 2, remove: 1, playable: 1}, + {number: 26, period: 2, side: 'C', name: 'Securitate*', ops: 2, remove: 1, playable: 1}, + {number: 27, period: 1, side: 'D', name: 'Consumerism', ops: 3, remove: 0, playable: 1}, + {number: 28, period: 1, side: 'C', name: 'Factory Party Cells', ops: 3, remove: 0, playable: 1}, + {number: 29, period: 1, side: 'D', name: 'Jan Palach Week*', ops: 1, remove: 1, playable: 1}, + {number: 30, period: 1, side: 'C', name: 'Tear Gas*', ops: 1, remove: 1, playable: 1}, + {number: 31, period: 1, side: 'D', name: 'Intelligentsia', ops: 2, remove: 0, playable: 1}, + {number: 32, period: 1, side: 'C', name: 'Peasant Parties*', ops: 2, remove: 1, playable: 1}, + {number: 33, period: 2, side: 'D', name: 'Legacy of 1968*', ops: 4, remove: 1, playable: 1}, + {number: 34, period: 1, side: 'D', name: 'Fidesz*', ops: 2, remove: 1, playable: 1}, + {number: 35, period: 2, side: 'C', name: 'Systematization*', ops: 3, remove: 1, playable: 1}, + {number: 36, period: 3, side: 'D', name: 'Public Against Violence*', ops: 3, remove: 1, playable: 1}, + {number: 37, period: 1, side: 'C', name: 'Nagy Reburied*', ops: 3, remove: 1, playable: 1}, + {number: 38, period: 1, side: 'D', name: 'Roundtable Talks', ops: 3, remove: 0, playable: 1}, + {number: 39, period: 2, side: 'D', name: 'Toxic Waste*', ops: 2, remove: 1, playable: 1}, + {number: 40, period: 3, side: 'C', name: 'Adamec*', ops: 2, remove: 1, playable: 1}, + {number: 41, period: 3, side: 'D', name: 'My First Banana*', ops: 3, remove: 1, playable: 1}, + {number: 42, period: 1, side: 'D', name: 'St. Nicholas Church*', ops: 1, remove: 1, playable: 1}, + {number: 43, period: 3, side: 'N', name: 'Tank Column/Tank Man*', ops: 2, remove: 1, playable: 1}, + {number: 44, period: 2, side: 'N', name: 'Inflationary Currency*', ops: 3, remove: 1, playable: 1}, + {number: 45, period: 2, side: 'D', name: 'Soviet Troop Withdrawals*', ops: 4, remove: 1, playable: 1}, + {number: 46, period: 2, side: 'D', name: 'Goodbye Lenin!*', ops: 3, remove: 1, playable: 1}, + {number: 47, period: 2, side: 'C', name: 'Bulgarian Turks expelled*', ops: 3, remove: 1, playable: 1}, + {number: 48, period: 3, side: 'D', name: 'Shock Therapy*', ops: 3, remove: 1, playable: 1}, + {number: 49, period: 3, side: 'N', name: 'Stand Fast*', ops: 3, remove: 1, playable: 1}, + {number: 50, period: 2, side: 'D', name: 'This Sinatra Doctrine*', ops: 3, remove: 1, playable: 1}, + {number: 51, period: 2, side: 'C', name: '40th Anniversary Celebration*', ops: 2, remove: 1, playable: 1}, + {number: 52, period: 2, side: 'C', name: 'Normalization*', ops: 3, remove: 1, playable: 1}, + {number: 53, period: 2, side: 'C', name: 'Li Peng*', ops: 2, remove: 1, playable: 1}, + {number: 54, period: 2, side: 'D', name: 'The Crowd Turns Against Ceausescu*', ops: 3, remove: 1, playable: 1}, + {number: 55, period: 1, side: 'C', name: 'Perestroika*', ops: 3, remove: 1, playable: 1}, + {number: 56, period: 2, side: 'D', name: 'Foreign Television*', ops: 2, remove: 1, playable: 1}, + {number: 57, period: 2, side: 'C', name: 'Central Committee Reshuffle*', ops: 2, remove: 1, playable: 1}, + {number: 58, period: 2, side: 'D', name: 'Austria-Hungary Border Reopened*', ops: 2, remove: 1, playable: 1}, + {number: 59, period: 3, side: 'C', name: 'Massacre in Timisoara*', ops: 3, remove: 1, playable: 0}, + {number: 60, period: 1, side: 'D', name: 'Hungarian Democratic Forum*', ops: 3, remove: 1, playable: 1}, + {number: 61, period: 2, side: 'D', name: 'The Monday Demonstrations*', ops: 4, remove: 1, playable: 0}, + {number: 62, period: 1, side: 'N', name: 'Prudence', ops: 4, remove: 0, playable: 1}, + {number: 63, period: 3, side: 'D', name: 'Army Backs Revolution*', ops: 3, remove: 1, playable: 1}, + {number: 64, period: 1, side: 'D', name: 'Papal Visit*', ops: 2, remove: 1, playable: 1}, + {number: 65, period: 3, side: 'C', name: 'Politburo Intrigue*', ops: 2, remove: 1, playable: 1}, + {number: 66, period: 3, side: 'D', name: 'Civic Forum*', ops: 4, remove: 1, playable: 1}, + {number: 67, period: 2, side: 'N', name: 'Reformer Rehabilitated*', ops: 2, remove: 1, playable: 1}, + {number: 68, period: 2, side: 'D', name: 'Klaus and Komarek*', ops: 3, remove: 1, playable: 1}, + {number: 69, period: 3, side: 'C', name: 'New Year\'s Eve Party*', ops: 2, remove: 1, playable: 1}, + {number: 70, period: 3, side: 'D', name: 'Government Resigns*', ops: 3, remove: 1, playable: 1}, + {number: 71, period: 2, side: 'D', name: 'Kiss of Death*', ops: 3, remove: 1, playable: 1}, + {number: 72, period: 2, side: 'D', name: 'Peasant Parties Revolt*', ops: 3, remove: 1, playable: 1}, + {number: 73, period: 1, side: 'C', name: 'Poszgay Defends the Revolution*', ops: 2, remove: 1, playable: 1}, + {number: 74, period: 2, side: 'D', name: 'FRG Embassies*', ops: 3, remove: 1, playable: 1}, + {number: 75, period: 2, side: 'D', name: 'Exit Visas*', ops: 3, remove: 1, playable: 1}, + {number: 76, period: 2, side: 'C', name: 'Warsaw Pact Summit*', ops: 2, remove: 1, playable: 1}, + {number: 77, period: 3, side: 'C', name: 'Social Democratic Platform Adopted*', ops: 2, remove: 1, playable: 1}, + {number: 78, period: 1, side: 'N', name: 'Gorbachev Charms the West', ops: 4, remove: 0, playable: 1}, + {number: 79, period: 2, side: 'C', name: 'The Third Way*', ops: 2, remove: 1, playable: 1}, + {number: 80, period: 3, side: 'D', name: 'Domino Theory*', ops: 3, remove: 1, playable: 1}, + {number: 81, period: 3, side: 'C', name: 'Modrow*', ops: 2, remove: 1, playable: 1}, + {number: 82, period: 3, side: 'C', name: 'Spitzel*', ops: 1, remove: 1, playable: 1}, + {number: 83, period: 2, side: 'D', name: 'The Baltic Way*', ops: 3, remove: 1, playable: 0}, + {number: 84, period: 3, side: 'D', name: 'Breakaway Baltic Republics*', ops: 4, remove: 1, playable: 0}, + {number: 85, period: 1, side: 'N', name: 'Common European Home', ops: 2, remove: 0, playable: 1}, + {number: 86, period: 3, side: 'D', name: '\"The Wall Must Go!*\"', ops: 3, remove: 0, playable: 1}, + {number: 87, period: 3, side: 'D', name: 'Kohl Proposes Reunification*', ops: 3, remove: 1, playable: 1}, + {number: 88, period: 1, side: 'D', name: 'Sajudis*', ops: 2, remove: 1, playable: 1}, + {number: 89, period: 1, side: 'D', name: 'Eco-Glasnost*', ops: 2, remove: 1, playable: 1}, + {number: 90, period: 2, side: 'C', name: 'GrenzTruppen*', ops: 2, remove: 1, playable: 1}, + {number: 91, period: 1, side: 'D', name: 'Dash for the West*', ops: 3, remove: 1, playable: 1}, + {number: 92, period: 1, side: 'C', name: 'Deutsche Marks*', ops: 4, remove: 1, playable: 1}, + {number: 93, period: 2, side: 'D', name: 'New Forum*', ops: 1, remove: 1, playable: 1}, + {number: 94, period: 3, side: 'D', name: 'Union of Democratic Forces*', ops: 4, remove: 1, playable: 1}, + {number: 95, period: 1, side: 'C', name: 'The July Concept*', ops: 3, remove: 1, playable: 1}, + {number: 96, period: 1, side: 'D', name: 'Helsinki Final Act*', ops: 1, remove: 1, playable: 1}, + {number: 97, period: 3, side: 'D', name: 'The Tyrant is Gone*', ops: 2, remove: 1, playable: 0}, + {number: 98, period: 2, side: 'D', name: 'Laszlo Tokes*', ops: 2, remove: 1, playable: 1}, + {number: 99, period: 3, side: 'C', name: 'Ligachev*', ops: 3, remove: 1, playable: 1}, + {number: 100, period: 2, side: 'D', name: 'Yakovlev Counsels Gorbachev*', ops: 2, remove: 1, playable: 1}, + {number: 101, period: 3, side: 'C', name: 'Elena*', ops: 1, remove: 1, playable: 1}, + {number: 102, period: 3, side: 'C', name: 'National Salvation Front*', ops: 3, remove: 1, playable: 1}, + {number: 103, period: 2, side: 'C', name: 'Nepotism*', ops: 3, remove: 1, playable: 1}, + {number: 104, period: 2, side: 'D', name: 'Presidential Visit*', ops: 3, remove: 1, playable: 1}, + {number: 105, period: 2, side: 'D', name: 'Samizdat*', ops: 3, remove: 1, playable: 1}, + {number: 106, period: 2, side: 'D', name: '\"We are the People!\"', ops: 3, remove: 0, playable: 1}, + {number: 107, period: 2, side: 'D', name: 'Foreign Currency Debt Burden', ops: 1, remove: 0, playable: 1}, + {number: 108, period: 1, side: 'C', name: 'Heal Our Bleeding Wound', ops: 3, remove: 0, playable: 1}, + {number: 109, period: 3, side: 'C', name: 'Kremlin Coup!*', ops: 3, remove: 1, playable: 0}, + {number: 110, period: 3, side: 'D', name: 'Malta Summit*', ops: 3, remove: 1, playable: 1}, + ] + +const power_cards = [ +null, +{number: 1, name: 'Strike', value: 6, socio: 0, url: 'ps2'}, +{number: 2, name: 'Strike', value: 6, socio: 0, url: 'ps2'}, +{number: 3, name: 'Strike', value: 5, socio: 0, url: 'ps3'}, +{number: 4, name: 'Strike', value: 5, socio: 0, url: 'ps3'}, +{number: 5, name: 'Strike', value: 4, socio: 0, url: 'ps4'}, +{number: 6, name: 'Strike', value: 4, socio: 0, url: 'ps4'}, +{number: 7, name: 'Strike', value: 4, socio: 0, url: 'ps4'}, +{number: 8, name: 'Strike', value: 4, socio: 0, url: 'ps4'}, +{number: 9, name: 'Strike', value: 3, socio: 0, url: 'ps5'}, +{number: 10, name: 'Strike', value: 3, socio: 0, url: 'ps5'}, +{number: 11, name: 'Strike', value: 3, socio: 0, url: 'ps5'}, +{number: 12, name: 'Strike', value: 3, socio: 0, url: 'ps5'}, +{number: 13, name: 'March', value: 6, socio: 0, url: 'ps6'}, +{number: 14, name: 'March', value: 6, socio: 0, url: 'ps6'}, +{number: 15, name: 'March', value: 5, socio: 0, url: 'ps7'}, +{number: 16, name: 'March', value: 5, socio: 0, url: 'ps7'}, +{number: 17, name: 'March', value: 4, socio: 0, url: 'ps8'}, +{number: 18, name: 'March', value: 4, socio: 0, url: 'ps8'}, +{number: 19, name: 'March', value: 4, socio: 0, url: 'ps8'}, +{number: 20, name: 'March', value: 4, socio: 0, url: 'ps8'}, +{number: 21, name: 'March', value: 3, socio: 0, url: 'ps9'}, +{number: 22, name: 'March', value: 3, socio: 0, url: 'ps9'}, +{number: 23, name: 'March', value: 3, socio: 0, url: 'ps9'}, +{number: 24, name: 'March', value: 3, socio: 0, url: 'ps9'}, +{number: 25, name: 'Rally in the Square', value: 1, socio: 0, url: 'ps1'}, +{number: 26, name: 'Rally in the Square', value: 1, socio: 0, url: 'ps1'}, +{number: 27, name: 'Rally in the Square', value: 1, socio: 0, url: 'ps1'}, +{number: 28, name: 'Rally in the Square', value: 1, socio: 0, url: 'ps1'}, +{number: 29, name: 'Rally in the Square', value: 1, socio: 0, url: 'ps1'}, +{number: 30, name: 'Rally in the Square', value: 1, socio: 0, url: 'ps1'}, +{number: 31, name: 'Petition', value: 6, socio: 0, url: 'ps10'}, +{number: 32, name: 'Petition', value: 6, socio: 0, url: 'ps10'}, +{number: 33, name: 'Petition', value: 6, socio: 0, url: 'ps10'}, +{number: 34, name: 'Petition', value: 5, socio: 0, url: 'ps11'}, +{number: 35, name: 'Petition', value: 5, socio: 0, url: 'ps11'}, +{number: 36, name: 'Petition', value: 5, socio: 0, url: 'ps11'}, +{number: 37, name: 'Elite Leader', value: 3, socio: 1, url: 'ps16'}, +{number: 38, name: 'Elite Leader', value: 3, socio: 1, url: 'ps17'}, +{number: 39, name: 'Elite Leader', value: 3, socio: 1, url: 'ps18'}, +{number: 40, name: 'Elite Leader', value: 3, socio: 1, url: 'ps19'}, +{number: 41, name: 'Intellectual Leader', value: 3, socio: 5, url: 'ps12'}, +{number: 42, name: 'Intellectual Leader', value: 3, socio: 5, url: 'ps13'}, +{number: 43, name: 'Intellectual Leader', value: 3, socio: 5, url: 'ps14'}, +{number: 44, name: 'Intellectual Leader', value: 3, socio: 5, url: 'ps15'}, +{number: 45, name: 'Worker Leader', value: 3, socio: 4, url: 'ps20'}, +{number: 46, name: 'Worker Leader', value: 3, socio: 4, url: 'ps21'}, +{number: 47, name: 'Church Leader', value: 3, socio: 7, url: 'ps23'}, +{number: 48, name: 'Student Leader', value: 3, socio: 6, url: 'ps22'}, +{number: 49, name: 'Scare Tactics', value: 0, socio: 0, url: 'ps26'}, +{number: 50, name: 'Support Surges', value: 0, socio: 0, url: 'ps25'}, +{number: 51, name: 'Support Falters', value: 0, socio: 0, url: 'ps24'}, +{number: 52, name: 'Tactic Fails', value: 0, socio: 0, url: 'ps27'}, +{number: 53, name: 'Rally in the Square', value: 3, socio: 0, url: 'ps1'}, +{number: 54, name: 'Petition', value: 3, socio: 0, url: 'ps10'} ] exports.scenarios = [ "Standard" ] @@ -216,8 +279,6 @@ exports.roles = [ DEM, COM ] // --- SET UP --- exports.setup = function (seed, scenario, options) { - console.log('setup ran') - game = { seed: seed, log: [], @@ -231,27 +292,56 @@ exports.setup = function (seed, scenario, options) { com_starting_infl: 0, dem_starting_infl: 0 }, + valid_spaces: [], + valid_cards: [], turn: 0, round: 0, + round_player: COM, stability: 0, - dem_TST: 0, - com_TST: 0, + dem_tst_position: 0, + com_tst_position: 0, + dem_tst_attempted: 0, + com_tst_attempted: 0, + dem_tst_attempted_this_turn: 0, + com_tst_attempted_this_turn:0, vp: 0, pieces: [], strategy_deck: [], strategy_discard: [], - + strategy_removed: [], + power_struggle_deck: [], + power_struggle_discard: [], + dem_hand_limit: 8, + com_hand_limit: 8, democrat_hand: [], communist_hand: [], democrat_set_aside: [], + pwr_struggle_in: [], + is_pwr_struggle: false, + dem_pwr_hand_limit: 0, + com_pwr_hand_limit: 0, + dem_pwr_hand: [], + com_pwr_hand: [], + raised_stakes_discard: 0, + raised_stakes: 0, + raised_stakes_round: 0, + rally_win: 0, + petition_win: 0, + respond: 0, + times_held: {'East Germany': 0, 'Poland': 0, 'Czechoslovakia': 0, 'Hungary': 0, 'Romania': 0, 'Bulgaria': 0}, + revolutions: {'East Germany': false, 'Poland': false, 'Czechoslovakia': false, 'Hungary': false, 'Romania': false, 'Bulgaria': false}, + remove_opponent_infl: false, + tactics_fails: '' } log_h1("1989 Dawn of Freedom") + console.log('game.raised_stakes_discard: ', game.raised_stakes_discard) + game.active = COM start_game() @@ -260,24 +350,29 @@ exports.setup = function (seed, scenario, options) { function start_game() { //starting influence - console.log('start_game called') // Draw cards + /* const card_numbers = cards.filter(card => card !== null && card !== undefined).map(card => card.number); + console.log('card numbers: ', card_numbers) */ game.strategy_deck = draw_deck(cards) - console.log('starting deck: ', game.strategy_deck.length) - draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, hand_limit) + reset_power() + console.log('game.strategy_deck: ', game.strategy_deck[1]) + draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.dem_hand_limit, game.com_hand_limit) + console.log('game.strategy_deck: ', game.strategy_deck[1], 'democrat_hand:', game.democrat_hand) - console.log('democrat_hand: ', game.democrat_hand, 'communist hand: ', game.communist_hand) - console.log('updated deck: ', game.strategy_deck.length) - spaces.forEach(space => { game.pieces.push({ name_unique: space.name_unique, + space_id: space.space_id, demInfl: space.demInfl, comInfl: space.comInfl, + demCtrl: space.demCtrl, + comCtrl: space.comCtrl, stability: space.stability }); }); + game.valid_spaces = valid_spaces(); + console.log('game.valid_spaces: ', game.valid_spaces) //console.log('game.pieces: ', game.pieces) //Communist starts by placing 2 influence game.available_ops = 2 @@ -297,24 +392,31 @@ exports.view = function(state, player) { played_card: game.played_card, selected_space: game.selected_space, - valid_spaces: [], + valid_spaces: game.valid_spaces, + valid_cards: game.valid_cards, pieces: game.pieces, turn: game.turn, round: game.round, + round_player: game.round_player, vp: game.vp, stability: game.stability, - dem_TST: game.dem_TST, - com_TST: game.com_TST, + dem_tst: game.dem_tst_position, + com_tst: game.com_tst_position, strategy_deck: game.strategy_deck.length, + strategy_discard: game.strategy_discard, democrat_hand: game.democrat_hand.length, communist_hand: game.communist_hand.length, + is_pwr_struggle: game.is_pwr_struggle, + times_held: game.times_held, + revolutions: game.revolutions, hand: [], set_aside: [], + pwr_hand: [], } @@ -322,11 +424,20 @@ exports.view = function(state, player) { if (player === game.active && game.vm && game.vm.draw) view.drawn = game.vm.draw + if (player === game.active) { + view.valid_spaces = game.valid_spaces + } else { + view.valid_spaces = [] + } + if (player === DEM) { view.hand = game.democrat_hand view.set_aside = game.democrat_set_aside + view.power_hand = game.dem_pwr_hand + } else if (player === COM) { view.hand = game.communist_hand + view.power_hand = game.com_pwr_hand } if (game.state === "game_over") { @@ -382,6 +493,14 @@ function gen_action_card(card){ gen_action("card", card) } +function gen_action_sc(space){ + gen_action("sc", space) +} + +function gen_action_scoring(){ + gen_action("scoring") +} + exports.action = function (state, player, action, arg) { //console.log('exports.action called with state:' , state, 'player:', player, 'action: ', action, 'arg: ', arg) game = state @@ -408,41 +527,31 @@ states.com_init = { } view.prompt = `Place ${game.available_ops} starting influence` - let available_spaces = spaces.slice() - for (let space of available_spaces) { - //May not add where there is opposition influence - const clicked_space = find_space_index(space.name_unique) - if (game.pieces[clicked_space].demInfl === 0) { - gen_action_infl(space.name_unique) - } - //console.log('state: com_init_1') - //console.log('space: ', space) + for (let space_id of game.valid_spaces) { + const space = spaces.find(s => s.space_id === space_id); + if (space) { + gen_action_infl(space.name_unique); + } } }, infl(space) { add_infl(space) - if (game.available_ops === 0) { - view.prompt= 'Place starting influence: done.' - gen_action("done") - } }, - done() { view.prompt='Influence added' game.starting_infl.com_starting_infl++ - console.log('game.starting_infl.com_starting_infl: ', game.starting_infl.com_starting_infl) if (game.starting_infl.com_starting_infl == 1){ game.available_ops = 3 game.state = 'dem_init' + valid_spaces() next_player() - log_side() } else if (game.starting_infl.com_starting_infl == 2) { game.available_ops = 4 game.state = 'dem_init' + valid_spaces() next_player() - log_side() } else if (game.starting_infl.com_starting_infl == 3) { new_turn() clear_undo() @@ -461,55 +570,36 @@ states.dem_init = { } view.prompt = `Place ${game.available_ops} starting influence` - let available_spaces = spaces.slice() - for (let space of available_spaces) { - //May not add where there is opposition influence - const clicked_space = find_space_index(space.name_unique) - if (game.pieces[clicked_space].comInfl === 0) { - gen_action_infl(space.name_unique) + for (let space_id of game.valid_spaces) { + const space = spaces.find(s => s.space_id === space_id); + if (space) { + gen_action_infl(space.name_unique); } - //console.log('state: com_init_1') - //console.log('space: ', space) } }, infl(space) { - add_infl(space) -/* - if (game.available_ops === 0) { - view.prompt= 'Place starting influence: done.' - gen_action("done") - } */ }, done() { view.prompt='Influence added' game.starting_infl.dem_starting_infl++ - console.log('game.starting_infl.com_starting_infl: ', game.starting_infl.com_starting_infl) if (game.starting_infl.dem_starting_infl == 1){ game.available_ops = 3 } else if (game.starting_infl.dem_starting_infl == 2) { game.available_ops = 2 } - next_player() - log_side() game.state = 'com_init' + valid_spaces() + next_player() } } -/*states.start_new_turn = { - inactive: 'to choose a card', - prompt() { - view.prompt = 'Choose a card', - new_turn() - game.state = 'select_card' - }, -}*/ - states.choose_card = { inactive: 'choose a card', prompt() { if (game.played_card > 0) { + game.state = 'play_card' view.prompt = 'Choose a card: done' gen_action("done"); return; @@ -522,13 +612,12 @@ states.choose_card = { } else { available_cards = game.communist_hand } - console.log(available_cards) for (let card of available_cards) { gen_action_card(card) } }, card(card) { - console.log('card number: ', card) + push_undo() log(`Played ${cards[card].name}`) game.played_card = card let find_card @@ -540,12 +629,8 @@ states.choose_card = { const [playedCard] = game.democrat_hand.splice(find_card, 1); } game.strategy_discard.push(card) - console.log('discard: ', game.strategy_discard) game.available_ops = cards[card].ops - console.log('game.available_ops: ', game.available_ops) - view.prompt = 'Choose a card: done' - gen_action("done") - + }, done () { game.state = 'play_card' @@ -555,48 +640,102 @@ states.choose_card = { states.play_card ={ inactive: 'play a card', prompt () { + if (game.is_pwr_struggle) { + console.log('in is_pwr_struggle') + view.prompt = 'Draw cards' + gen_action('draw') + return + } + view.prompt = 'Play for:' - clear_undo() - gen_action('event') - gen_action('influence') - gen_action('tst') - gen_action('support_check') + + if (scoring_cards.includes(game.played_card)) { + gen_action('scoring'); + } else { + + if (cards[game.played_card].playable ===1) { + gen_action('event') + } + gen_action('influence') + if (game.active === DEM && game.dem_tst_attempted_this_turn === 0 || game.active === COM && game.com_tst_attempted_this_turn === 0) { + gen_action('tst') + } + gen_action('support_check') + } }, - event() { + scoring() { + push_undo() + console.log('in scoring') + if (game.played_card === 17) { game.pwr_struggle_in ="East Germany" } + if (game.played_card === 18) { game.pwr_struggle_in = "Czechoslovakia" } + if (game.played_card === 19) { game.pwr_struggle_in = "Bulgaria"} + if (game.played_card === 21) { game.pwr_struggle_in = "Romania" } + if (game.played_card === 22) { game.pwr_struggle_in = "Poland" } + if (game.played_card === 23) { game.pwr_struggle_in = "Hungary" } + game.is_pwr_struggle = true + }, + draw() { + push_undo() + console.log('game.pwr_struggle_in: ', game.pwr_struggle_in) + let presence = check_presence(game.pwr_struggle_in) + console.log('presence', presence) + if (presence.dem_spaces > 0) { + game.dem_pwr_hand_limit = 6 + 2*(presence.dem_spaces - 1) + } else { + game.dem_pwr_hand_limit = 0 + } + if (presence.com_spaces > 0 ) { + game.com_pwr_hand_limit = 6 + 2*(presence.com_spaces - 1) + } else { + game.com_pwr_hand_limit = 0 + } + + //console.log('dem limit:' , game.dem_pwr_hand_limit, 'com limit: ', game.com_pwr_hand_limit) + console.log(game.power_struggle_deck, game.dem_pwr_hand, game.com_pwr_hand, game.dem_pwr_hand_limit, game.com_pwr_hand_limit) + draw_cards(game.power_struggle_deck, game.dem_pwr_hand, game.com_pwr_hand, game.dem_pwr_hand_limit, game.com_pwr_hand_limit) + game.valid_cards = all_power_cards + game.state = 'raise_stakes' + }, + event() { + push_undo() + console.log('in event()') + call_event(game.played_card) }, influence(influence) { + push_undo() console.log('influence called') game.state='add_influence' + valid_spaces() }, tst(tst) { + push_undo() console.log('tst called') + game.state='tiananmen_square_attempt' }, - support_check() { - + support_check(space) { + push_undo() + console.log('sc called') + game.available_ops = 2 + game.state='support_check_prep' + valid_spaces() } } states.add_influence = { inactive: 'add influence', - valid_spaces: [], prompt () { - if (game.available_ops == 0) { - view.prompt = 'Place starting influence: done.'; + if (game.available_ops == 0) { + view.prompt = 'Place influence: done.'; gen_action("done"); return; } view.prompt = `Add influence: ${game.available_ops} remaining` - //Only do the influence check at the start. No chaining of placing influence - if (this.valid_spaces.length === 0) { - this.valid_spaces = this.get_valid_spaces(); - } - - // Generate actions for initial valid spaces - for (let space_id of this.valid_spaces) { + // Generate actions for valid spaces + for (let space_id of game.valid_spaces) { const space = spaces.find(s => s.space_id === space_id); if (space) { gen_action_infl(space.name_unique); @@ -607,15 +746,500 @@ states.add_influence = { infl(space) { add_infl(space) }, - get_valid_spaces() { - return valid_spaces() - }, done() { view.prompt = 'Influence added' - game.state = 'test' + end_round() + } +} + +states.tiananmen_square_attempt = { + inactive: 'do Tiananmen Square', + prompt () { + if (game.active === DEM && game.dem_tst_attempted_this_turn > 0 || game.active === COM && game.com_tst_attempted_this_turn > 0) { + view.prompt = 'Tiananmen Square Track attempt done' + gen_action('done') + return + } + view.prompt = 'Roll a die' + gen_action('roll') + }, + roll(roll) { + do_tst_attempt () + clear_undo() + }, + done () { + game.available_ops = 0 + end_round() + } +} + +states.support_check_prep = { + inactive: 'do support checks', + prompt () { + if (game.available_ops === 0) { + view.prompt = 'Support checks: done' + gen_action('done') + return + } + if (game.available_ops > 1) { + view.prompt = `Select a space. ${game.available_ops} support checks remaining` + } else { + view.prompt = ` Select a space. ${game.available_ops} support check remaining` + } + + for (let space_id of game.valid_spaces) { + const space = spaces.find(s => s.space_id === space_id); + if (space) { + gen_action_sc(space.name_unique); + } + } + }, + sc(space) { + game.selected_space = space + game.state = 'do_support_check' + }, + done () { + game.available_ops = 0 + end_round() + } +} + +states.do_support_check = { + inactive: 'do support checks', + prompt () { + view.prompt = `Target: ${game.selected_space}. Roll a die` + gen_action('roll') + }, + roll() { + do_sc(game.selected_space) + valid_spaces() + game.available_ops-- + game.state = 'support_check_prep' + return + } +} + +states.raise_stakes = { + inactive: 'raise the stakes', + + prompt () { + //console.log('game.raised_stakes_discard: ', game.raised_stakes_discard) + //console.log('game.raised_stakes_round: ', game.raised_stakes_round) + if (game.raised_stakes_round === 2) { + console.log('game raised stakes round == 2') + gen_action('struggle') + return + } + if (game.raised_stakes_discard === 3) { + view.prompt = 'Raise the stakes: done' + gen_action('done') + } else if (game.raised_stakes_discard > 0) { + console.log('in stakes >= 0') + view.prompt = `Discard ${3-game.raised_stakes_discard} cards to raise the stakes` + } else { + view.prompt = `Discard ${3-game.raised_stakes_discard} cards to raise the stakes` + gen_action('done') + } + console.log('game.valid_cards in raise the stakes: ', game.valid_cards) + for (let card of game.valid_cards) { + gen_action_card(card) + } + }, + card(card) { + log(`Discarded ${power_cards[card].name}`) + + let find_card + if (game.active === COM) { + find_card = game.com_pwr_hand.indexOf(card); + const [playedCard] = game.com_pwr_hand.splice(find_card, 1); + } else { + find_card = game.dem_pwr_hand.indexOf(card); + const [playedCard] = game.dem_pwr_hand.splice(find_card, 1); + } + game.power_struggle_discard.push(card) + + game.raised_stakes_discard ++ + if (game.raised_stakes_discard === 3) { + game.raised_stakes++ + } + + }, + done () { + if (game.raised_stakes_discard === 0 ) { + log('Did not raise the stakes') + } + game.raised_stakes_discard = 0 + game.raised_stakes_round ++ + next_player() + }, + struggle () { + do_valid_cards() + + /*let presence = check_presence(game.pwr_struggle_in) + if (game.active === DEM) { + valid_cards(game.dem_pwr_hand, presence.dem_leaders) + + } else { + valid_cards(game.com_pwr_hand, presence.com_leaders)} + //console.log('presence.dem_leaders: ', presence.dem_leaders, 'presence.com_leaders: ', presence.com_leaders)*/ + game.state = 'power_struggle' + } + +} + +states.power_struggle = { + inactive: 'play a card', + prompt () { + if (game.respond === 0 && game.valid_cards.length > 0) { + view.prompt = "Play a card" + console.log('game.valid_cards: ', game.valid_cards) + //console.log('dem_pwr_hand: ', game.dem_pwr_hand, 'com_pwr_hand: ', game.com_pwr_hand) + //console.log('game.valid_cards: ', game.valid_cards, 'view.valid_cards: ', view.valid_cards) + for (let card of game.valid_cards) { + gen_action_card(card) + } + } else if (game.respond === 0 && game.valid_cards.length === 0) { + view.prompt = 'No valid cards. You must concede.' + gen_action('concede') + } + + if (game.respond === 1 && game.valid_cards.length > 0) { + view.prompt = `${power_cards[game.played_power_card].name} played. You must match or concede` + gen_action('concede') + console.log('game.valid_cards: ', game.valid_cards) + for (let card of game.valid_cards) { + gen_action_card(card) + } + } else if (game.respond === 1 && game.valid_cards.length === 0) { + view.prompt = `${power_cards[game.played_power_card].name} played. You must concede` + gen_action('concede') + + } else if (game.respond === 2) { + view.prompt = 'You matched. Roll a die' + gen_action('roll') + } else if (game.respond === 3) { + view.prompt = 'Play leader as:' + if (game.tactics_fails !== "Strike") {gen_action('strike')} + if (game.tactics_fails !== "March") {gen_action('march')} + if (game.tactics_fails !== "Rally in the Square") {gen_action('rally')} + if (game.tactics_fails !== "Petition") {gen_action('petition')} + } else if (game.respond === 4) { + view.prompt = 'Draw 2 cards' + gen_action('draw') + } else if (game.respond === 5) { + view.prompt = 'Remove 1 opponent influence' + + for (let space_id of game.valid_spaces) { + const space = spaces.find(s => s.space_id === space_id); + if (space) { + gen_action_infl(space.name_unique); + } + } + } else if (game.respond === 6) { + view.prompt = 'Remove influence: done' + gen_action('done') + } else if (game.respond === 7 && game.available_ops > 0) { + view.prompt = 'Discard 2 cards' + for (let card of game.valid_cards) { + gen_action_card(card) + } + } else if (game.respond === 7 && game.available_ops === 0) { + view.prompt = 'Discard cards: done' + gen_action('done') + } + }, + card(card) { + push_undo() + console.log('game.respond: ', game.respond) + discard(card) + if (game.respond === 0 && card >= 37 && card <= 48) { + game.played_power_card = card + game.respond = 3 + } else if (game.respond === 0 && card === 49){ + log(`Played: ${power_cards[card].name}`) + game.played_power_card = card + game.respond = 5 + valid_spaces() + } else if (game.respond === 0 && card === 50) { + log(`Played: ${power_cards[card].name}`) + game.played_power_card = card + game.respond = 4 + } else if (game.respond === 0 && card === 51) { + log(`Played: ${power_cards[card].name}`) + game.played_power_card = card + game.respond = 7 + game.available_ops = 2 + next_player() + if (game.active === DEM) {game.valid_cards = game.dem_pwr_hand} + else {game.valid_cards = game.com_pwr_hand} + } + else if (game.respond === 0) { + log(`Played: ${power_cards[card].name} ${power_cards[card].value}`) + game.played_power_card = card + console.log('played power card when game respond 0:' , game.played_power_card) + game.respond = 1 + next_player() + do_valid_cards() + /*let presence = check_presence(game.pwr_struggle_in) + if (game.active === DEM) { + valid_cards(game.dem_pwr_hand, presence.dem_leaders) + } else {valid_cards(game.com_pwr_hand, presence.com_leaders)}*/ + + } else if (game.respond === 1) { + if (card === 52) { + log(`Played Tactic Fails: ${power_cards[game.played_power_card].name} no longer playable`) + game.tactics_fails = power_cards[game.played_power_card].name + game.respond = 0 + next_player() + do_valid_cards() + } else { + log(`Played: ${power_cards[card].name} ${power_cards[card].value}. Roll for initiative`) + game.respond = 2} + } else if (game.respond === 7) { + discard(card) + game.available_ops -- + } + }, + roll () { + let roll = Math.floor(Math.random() * 6) + 1 + log(`Rolled a ${roll}`) + if (roll >= power_cards[game.played_power_card].value) { + log('Initiative roll successful') + game.respond = 0 + do_valid_cards() + } else { + log(`Initiative roll failed. Required ${power_cards[game.played_power_card].value} or more`) + game.respond = 0 + next_player() + do_valid_cards() + } + }, + concede () { + log('Condeded') + log_h2('Aftermath') + log_h3('Support Loss') + if (game.played_power_card >= 25 && game.played_power_card <= 30) {game.rally_win = 2} + if (game.played_power_card >= 31 && game.played_power_card <= 36) {game.petition_win = 2} + game.respond = 0 + game.state = 'support_loss' + }, + strike () { + log(`Played: ${power_cards[game.played_power_card].name} as a Strike`) + game.played_power_card = 9 + game.respond = 1 + next_player() + do_valid_cards() + }, + march () { + log(`Played: ${power_cards[game.played_power_card].name} as a Strike`) + game.played_power_card = 21 + game.respond = 1 + next_player() + do_valid_cards() + }, + rally () { + log(`Played: ${power_cards[game.played_power_card].name} as a Rally in the Square`) + game.played_power_card = 53 + game.respond = 1 + next_player() + do_valid_cards() + }, + petition () { + log(`Played: ${power_cards[game.played_power_card].name} as a Strike`) + game.played_power_card = 54 + game.respond = 1 + next_player() + do_valid_cards() + }, + draw () { + if (game.active === DEM) { + draw_cards(game.power_struggle_deck, game.dem_pwr_hand, game.com_pwr_hand, game.dem_pwr_hand.length+2, game.com_pwr_hand.length) + } else {draw_cards(game.power_struggle_deck, game.dem_pwr_hand, game.com_pwr_hand, game.dem_pwr_hand.length, game.com_pwr_hand.length+2)} + game.respond = 0 + next_player() + do_valid_cards() + }, + infl(space) { + game.remove_opponent_infl = true + remove_infl(space) + game.respond = 6 + }, + /* Think the code below is now redundant */ + discard () { + if (game.active === DEM) {discard_card(game.dem_pwr_hand)} + else {discard_card(game.com_pwr_hand)} + }, + done () { + if (game.respond === 7) { + game.respond = 0 + do_valid_cards() + } else { + game.respond = 0 + next_player() + do_valid_cards() + } + } +} + +states.support_loss ={ + inactive: 'do Support Loss', + prompt () { + if (game.respond === 0) { + view.prompt = 'You lost the Power Struggle. Roll a die for Support Loss' + gen_action('roll') + } else if (game.respond === 1 && game.available_ops > 0 && game.valid_spaces.length > 0) { + view.prompt = `Remove ${game.available_ops} influence` + + for (let space_id of game.valid_spaces) { + const space = spaces.find(s => s.space_id === space_id); + if (space) { + gen_action_infl(space.name_unique); + } + } + } else if (game.respond === 1 && game.available_ops === 0 ) { + view.prompt = 'Support Loss: finished' + gen_action('done') + } else if (game.respond === 1 && game.valid_spaces.length === 0) { + view.prompt = 'No remaining influence to remove.' + gen_action('done') + } + }, + roll () { + let roll = Math.floor(Math.random() * 6) + log(`Rolled a ${roll}`) + roll = roll + game.raised_stakes + game.rally_win - game.petition_win + if (roll < 0) {roll = 0} + else if (roll > 7) {roll = 7} + + if (game.raised_stakes !== 0) { + log(`+${game.raised_stakes} from raising the stakes`) + } + if (game.rally_win !== 0) { + log('+2 from winning on a Rally in the Square') + } + if (game.petition_win !== 0) { + log('-2 from winning on a Petition') + } + log(`Modified roll: ${roll}`) + game.available_ops = support_loss_roll[roll] + game.respond++ + console.log('game.respond: ', game.respond) + valid_spaces() + }, + infl (space) { + remove_infl(space) + valid_spaces() + }, + done () { + next_player() + log_h3('Victory Point') + game.respond = 0 + game.state = 'vp_roll' + } +} + +states.vp_roll = { + inactive: 'do VP Roll', + prompt () { + if (game.respond === 0) { + view.prompt = 'Roll a die for Victory' + gen_action('roll') + } else if (game.respond === 1) { + view.prompt = 'Take power' + gen_action('take') + } else if (game.respond === 4) { + view.prompt = 'Proceed to scoring' + gen_action('scoring') + } + }, + roll () { + let roll = Math.floor(Math.random() * 6) + 1 + log(`Rolled a ${roll}`) + roll = roll + game.raised_stakes + game.rally_win - game.petition_win + if (roll < 0) {roll = 0} + else if (roll > 7) {roll = 7} + + if (game.raised_stakes !== 0) { + log(`+${game.raised_stakes} from raising the stakes`) + } + if (game.rally_win !== 0) { + log('+2 from winning on a Rally in the Square') + } + if (game.petition_win !== 0) { + log('-2 from winning on a Petition') + } + log(`Modified roll: ${roll}`) + let vp_change = vp_roll[roll] + log(`Gain ${vp_change} VP`) + if (roll >= 4) {console.log('Democrat takes power')} + console.log('starting VP: ', game.vp) + console.log('change VP:', vp_change) + if (game.active === DEM) {game.vp += vp_change} + else {game.vp -= vp_change} + if (game.active === DEM && roll >= 4) { + game.respond = 1 + } else { + game.respond = 0 + game.state = 'choose_power' + } + + console.log('game.respond: ', game.respond) + }, + take () { + console.log('game.revolutions: ', game.revolutions) + take_power(game.pwr_struggle_in) + game.respond = 4 + }, + scoring () { + console.log('in scoring') + console.log('game.pwr_struggle_in: ', game.pwr_struggle_in) + score_country(game.pwr_struggle_in) + game.state = 'score_country' + }, +} + +states.choose_power = { + inactive: 'choose whether to remain in power.', + prompt () { + if (game.respond === 0) { + view.prompt = 'Choose whether to remain in power' + gen_action('retain') + gen_action('surrender') + } else if (game.respond === 1) { + view.prompt = 'Proceed to scoring.' + gen_action('scoring') + } + }, + retain() { + retain_power(game.pwr_struggle_in) + game.respond = 1 + }, + surrender () { + take_power(game.pwr_struggle_in) + game.respond = 1 + }, + scoring () { + score_country(game.pwr_struggle_in) + if (game_over()) { + game.state = 'game_over' + } else {game.state = 'score_country'} } +} +states.score_country = { + inactive: `score country`, + prompt () { + view.prompt = 'Scoring: done' + gen_action('done') + }, + done () { + reset_power() + end_round() + } +} +states.game_over = { + inactive: 'victory' } states.test = { @@ -625,78 +1249,564 @@ states.test = { } } + +// ==================== SUPPORTING STATE FUNCTIONS ============================= + + function add_infl(space) { log(`Added 1 influence in ${space}.`) push_undo() - console.log('space clicked was: ', space) const clicked_space = find_space_index(space) - const opponent_control = game.active === COM ? game.pieces[clicked_space].demCtrl : game.pieces[clicked_space].comCtrl - - console.log('clicked_space: ', clicked_space) - console.log('game.pieces.space', game.pieces[clicked_space]) - console.log('initial influence: ', game.pieces[clicked_space] ) + + console.log('space:', space, 'opponent control: ', check_control(space)) + if (check_control(space)) { + game.available_ops -= 2 + } else { + game.available_ops-- + } if (game.active === COM) { game.pieces[clicked_space].comInfl++ } else { game.pieces[clicked_space].demInfl++ } - if (opponent_control) { - game.available_ops -= 2 + + game.pieces[clicked_space].demCtrl = 0 + game.pieces[clicked_space].comCtrl = 0 + + if ((game.pieces[clicked_space].demInfl - game.pieces[clicked_space].comInfl) >= game.pieces[clicked_space].stability) { + game.pieces[clicked_space].demCtrl = 1 + } + if ((game.pieces[clicked_space].comInfl - game.pieces[clicked_space].demInfl) >= game.pieces[clicked_space].stability) { + game.pieces[clicked_space].comCtrl = 1 + } + +} + +function remove_infl(space) { + console.log('remove influence called with ', space) + log(`Removed 1 influence from ${space}.`) + push_undo() + const clicked_space = find_space_index(space) + + if (game.remove_opponent_infl === true) { + console.log('in remove opponenet infl true') + if (game.active === COM) { + game.pieces[clicked_space].demInfl-- + } else { + game.pieces[clicked_space].comInfl-- + } + + if ((game.pieces[clicked_space].demInfl - game.pieces[clicked_space].comInfl) < game.pieces[clicked_space].stability) { + game.pieces[clicked_space].demCtrl = 0 + } + if ((game.pieces[clicked_space].comInfl - game.pieces[clicked_space].demInfl) < game.pieces[clicked_space].stability) { + game.pieces[clicked_space].comCtrl = 0 + } } else { + console.log('remove opponenet infl not true') + if (game.active === COM) { + game.pieces[clicked_space].comInfl-- + } else { + game.pieces[clicked_space].demInfl-- + } + + if ((game.pieces[clicked_space].demInfl - game.pieces[clicked_space].comInfl) < game.pieces[clicked_space].stability) { + game.pieces[clicked_space].demCtrl = 0 + } + if ((game.pieces[clicked_space].comInfl - game.pieces[clicked_space].demInfl) < game.pieces[clicked_space].stability) { + game.pieces[clicked_space].comCtrl = 0 + } + } game.available_ops-- +} + +function do_sc(space) { + log(`Target: ${space}`) + let roll = Math.floor(Math.random() * 6) + 1 + log(`Rolled a ${roll}`) + + roll += cards[game.played_card].ops + log(`+${cards[game.played_card].ops} from card ops`) + + const adj = count_adj(space) + console.log('adj: ', adj) + if (adj.dem_adj > 0 || adj.com_adj > 0 ){ + if (game.active === DEM) { + roll += adj.dem_adj + roll -= adj.com_adj + if (adj.dem_adj > 0) { + log(`+${adj.dem_adj} from adjacent control`) + } + if (adj.com_adj > 0) { + log(`-${adj.com_adj} from adjacent opponent control`) + } + } else { + roll += adj.com_adj + roll -= adj.dem_adj + if (adj.com_adj > 0) { + log(`+${adj.com_adj} from adjacent control`) + } + if (adj.dem_adj > 0) { + log(`-${adj.dem_adj} from adjacent opponent control`) + } + } + } + + log(`Total support check strength: ${roll}`) + const stability = spaces[find_space_index(space)].stability + log(`Stability is ${stability}. Defence is ${stability*2}`) + const change_infl = Math.max(0, roll - stability*2) + if (change_infl > 0) { + log(`${change_infl} point swing`) + console.log('change_infl: ', change_infl) + let clicked_space = find_space_index(space) + if(game.active === DEM) { + if (change_infl > game.pieces[clicked_space].comInfl) { + const residual = change_infl - game.pieces[clicked_space].comInfl + game.pieces[clicked_space].comInfl = 0 + game.pieces[clicked_space].demInfl += residual + } else { + game.pieces[clicked_space].comInfl -= change_infl + } + } else { + if (change_infl > game.pieces[clicked_space].demInfl) { + const residual = change_infl - game.pieces[clicked_space].demInfl + game.pieces[clicked_space].demInfl = 0 + game.pieces[clicked_space].comInfl += residual + } else { + game.pieces[clicked_space].demInfl -= change_infl + } + } + game.pieces[clicked_space].demCtrl = 0 + game.pieces[clicked_space].comCtrl = 0 + if ((game.pieces[clicked_space].demInfl - game.pieces[clicked_space].comInfl) >= game.pieces[clicked_space].stability) { + game.pieces[clicked_space].demCtrl = 1 + } + if ((game.pieces[clicked_space].comInfl - game.pieces[clicked_space].demInfl) >= game.pieces[clicked_space].stability) { + game.pieces[clicked_space].comCtrl = 1 + } + } else { + log('No change in influence') } - console.log('new influence: ', game.pieces[clicked_space]) - console.log('available_ops: ', game.available_ops) + clear_undo() } + function valid_spaces() { let valid_spaces_set = new Set(); + if (game.state === 'com_init') { + //console.log('Valid spaces calculated for communist. Before run game.valid_spaces = ', game.valid_spaces, 'and game.valid_spaces.length = ',game.valid_spaces.length); + for (let space of game.pieces) { + if (space.demInfl === 0) { + valid_spaces_set.add(space.space_id); + } + } + } else if (game.state === 'dem_init') { + //console.log('Valid spaces calculated for democrat'); + for (let space of game.pieces) { + if (space.comInfl === 0) { + valid_spaces_set.add(space.space_id); + } + } + } else if (game.state === 'support_check_prep' || game.state === 'do_support_check') { + //console.log('valid spaces calculated for support check') + if (game.active === DEM) { + for (let space of game.pieces) { + if (space.comInfl !== 0) { + valid_spaces_set.add(space.space_id); + } + } + } else { + for (let space of game.pieces) { + if (space.demInfl !== 0) { + valid_spaces_set.add(space.space_id); + } + } + } + } else if (game.state === 'support_loss') { + if (game.active === DEM) { + for (let piece of game.pieces) { + let space = spaces.find(s => s.space_id === piece.space_id); + if (space && piece.demInfl > 0 && space.country === game.pwr_struggle_in) { + valid_spaces_set.add(space.space_id); + } + } + } else { + for (let piece of game.pieces) { + let space = spaces.find(s => s.space_id === piece.space_id); + if (space && piece.comInfl > 0 && space.country === game.pwr_struggle_in) { + valid_spaces_set.add(space.space_id); + } + } + } + } else if (game.state === 'power_struggle') { + if (game.active === DEM) { + for (let piece of game.pieces) { + let space = spaces.find(s => s.space_id === piece.space_id); + if (space && piece.comInfl > 0 && space.country === game.pwr_struggle_in) { + valid_spaces_set.add(space.space_id); + } + } + } else { + for (let piece of game.pieces) { + let space = spaces.find(s => s.space_id === piece.space_id); + if (space && piece.demInfl > 0 && space.country === game.pwr_struggle_in) { + valid_spaces_set.add(space.space_id); + } + } + } + } + + else { // Iterate over all spaces to find the ones with the player's influence - for (let space of spaces) { - const player_influence = game.active === COM ? space.comInfl : space.demInfl; - - // If the space has the player's influence, add it and its adjacent spaces to the set - if (player_influence > 0) { - valid_spaces_set.add(space.space_id); - for (let adj_space_id of space.adjacent) { - if (adj_space_id) { - const adj_space = spaces.find(s => s.space_id === adj_space_id); - - // Check if the adjacent space is controlled by the opponent - const opponent_control = game.active === COM ? adj_space.demCtrl : adj_space.comCtrl; - - // Only add the adjacent space if the available_ops >= 2 or the space is not controlled by the opponent - if (game.available_ops >= 2 || !opponent_control) { - valid_spaces_set.add(adj_space.space_id); + for (let piece of game.pieces) { + const player_influence = game.active === COM ? piece.comInfl : piece.demInfl; + + // If the piece has the player's influence, add it and its adjacent spaces to the set + if (player_influence > 0) { + valid_spaces_set.add(piece.space_id); + + // Find the corresponding space in the `spaces` array to get the adjacency information + const space = spaces.find(s => s.space_id === piece.space_id); + if (space) { + for (let adj_space_id of space.adjacent) { + if (adj_space_id) { + const adj_piece = game.pieces.find(p => p.space_id === adj_space_id); + const adj_space = spaces.find(s => s.space_id === adj_space_id); + + // Check if the adjacent space is controlled by the opponent + const opponent_control = game.active === COM ? adj_piece.demCtrl : adj_piece.comCtrl; + + // Only add the adjacent space if the available_ops >= 2 or the space is not controlled by the opponent + if (game.available_ops >= 2 || !opponent_control) { + valid_spaces_set.add(adj_space.space_id); + } + } } + } + } + } + } + // Convert the set to an array before returning + game.valid_spaces = Array.from(valid_spaces_set); + console.log('game.valid_spaces: ', game.valid_spaces); + return game.valid_spaces; +} + +function valid_cards(player_hand, presence) { + const valid_cards_set= new Set(); + if (game.respond === 0) { + console.log('player hand: ', player_hand) + for (let c of player_hand) { + let card = power_cards.find(card => card && card.number === c); + if (card.number === 52) {continue} // Never add tactics fails + if (card.name === game.tactics_fails) {continue} + if (card.socio === 0) { + valid_cards_set.add(card.number); + } else if (leaders.includes(card.socio) && presence[card.socio]) { + valid_cards_set.add(card.number); + } + } + } else if (game.respond === 1) { + for (let c of player_hand) { + let card = power_cards.find(card => card && card.number === c); + if (card.name === power_cards[game.played_power_card].name) { + valid_cards_set.add(card.number); + } else if (leaders.includes(card.socio) && presence[card.socio]) { + valid_cards_set.add(card.number); + } else if (card.number === 52) {valid_cards_set.add(card.number)} + } + } + game.valid_cards = Array.from(valid_cards_set); + return game.valid_cards; +} + +function do_valid_cards() { + let presence = check_presence(game.pwr_struggle_in) + if (game.active === DEM) { + valid_cards(game.dem_pwr_hand, presence.dem_leaders) + + } else { + valid_cards(game.com_pwr_hand, presence.com_leaders)} +} + +function count_adj(name_unique) { + const space = spaces[find_space_index(name_unique)] + //console.log('space: ', space) + let dem_adj = 0 + let com_adj = 0 + + for (let adj_space_id of space.adjacent) { + if (adj_space_id) { + const adj_piece = game.pieces.find(piece => piece.space_id === adj_space_id); + if (adj_piece) { + if (adj_piece.demCtrl === 1) { + dem_adj++ + } + if (adj_piece.comCtrl === 1) { + com_adj++ + } + } + } + } + console.log('dem_adj: ', dem_adj, 'com_adj: ', com_adj) + return {dem_adj, com_adj} +} + +function check_control(space) { + if (game.active === 'COM' && space.demCtrl === 1) { + return true; + } else if (game.active === 'DEM' && space.comCtrl === 1) { + return true; + } else { + return false; + } +} + +function do_tst_attempt() { + let roll = Math.floor(Math.random() * 6) + 1; + log(`Rolled a ${roll}`); + + roll += game.available_ops + log(`+${game.available_ops} from the card operations value`) + if (game.active === DEM && game.dem_tst_attempted === 1 || game.active === COM && game.com_tst_attempted === 1) { + roll += 1; + log('+1 modifier from previous Tiananmen Square Track attempts') + } + if ((game.active === DEM && cards[game.played_card].side === 'D') || (game.active === COM && cards[game.played_card].side === 'C')) { + roll += 1; + log('+1 for playing own card'); + } + log(`Modified die roll: ${roll}`) + if (game.active === DEM) { + game.dem_tst_attempted_this_turn = 1 + if (roll >= dem_tst_req[game.dem_tst_position]) { + log(`${dem_tst_req[game.dem_tst_position]} required: success`) + game.dem_tst_position++ + game.dem_tst_attempted = 0 + } else { + log(`${dem_tst_req[game.dem_tst_position]} required: fail`) + game.dem_tst_attempted = 1 + } + } else { + game.com_tst_attempted_this_turn = 1 + if (roll >= com_tst_req[game.com_tst_position]) { + log(`${com_tst_req[game.com_tst_position]} required: success`) + game.com_tst_position++ + game.com_tst_attempted = 0 + } else { + log(`${com_tst_req[game.com_tst_position]} required: fail`) + game.com_tst_attempted = 1 + } + } +} + +function check_presence(country) { + + let dem_spaces = 0; + let com_spaces = 0; + let dem_battlegrounds = 0; + let com_battlegrounds = 0; + let dem_leaders = {1: false, 4: false, 5: false, 6: false, 7: false}; + let com_leaders = {1: false, 4: false, 5: false, 6: false, 7: false}; + + + for (let space of spaces) { + if (space.country === country) { + + let piece = game.pieces.find(p => p.space_id === space.space_id); + + if (piece.demCtrl === 1) { + dem_spaces++; + if (space.battleground === 1) { + dem_battlegrounds++; + } + if ([1, 4, 5, 6, 7].includes(space.socio)) { + dem_leaders[space.socio] = true; + } + } + if (piece.comCtrl === 1) { + com_spaces++; + if (space.battleground === 1) { + com_battlegrounds++; + } + if ([1, 4, 5, 6, 7].includes(space.socio)) { + com_leaders[space.socio] = true; } } } } - // Convert the set to an array before returning - view.valid_spaces = Array.from(valid_spaces_set) - return Array.from(valid_spaces_set); + + // Determine domination + let dem_domination = dem_battlegrounds > com_battlegrounds && dem_spaces > com_spaces && dem_spaces - dem_battlegrounds > 0; + let com_domination = com_battlegrounds > dem_battlegrounds && com_spaces > dem_spaces && com_spaces - com_battlegrounds > 0; + + // Determine control + let total_battlegrounds = battlegrounds(country); + let dem_control = dem_battlegrounds === total_battlegrounds && dem_spaces > com_spaces; + let com_control = com_battlegrounds === total_battlegrounds && com_spaces > dem_spaces; + + return { + dem_spaces: dem_spaces, + com_spaces: com_spaces, + dem_battlegrounds: dem_battlegrounds, + com_battlegrounds: com_battlegrounds, + dem_domination: dem_domination, + com_domination: com_domination, + dem_control: dem_control, + com_control: com_control, + dem_leaders: dem_leaders, + com_leaders: com_leaders + }; +} + +function battlegrounds(country) { + let battlegrounds = 0; + if (country === "Hungary") { + battlegrounds = 4 + } else if (country === "Bulgaria") { + battlegrounds = 5 + } else { + battlegrounds = 6 + } + return battlegrounds; +} + +function take_power(country) { + console.log('game.revolutions: ', game.revolutions) + log(`Democrat takes power in ${game.pwr_struggle_in}`) + game.revolutions[country] = true + console.log('game.revolutions: ', game.revolutions) +} + +function retain_power(country){ + game.times_held[country]++ + let vp_gain = get_value(country)*game.times_held[country] + log(`Communist gains ${vp_gain}VP from holding power`) + game.vp -= vp_gain + console.log('times_held: ', game.times_held) +} + +function find_country(country) { + return countries.indexOf(country) +} + +function score_country(country) { + log_h3('Scoring') + let status + let presence = check_presence(country) + console.log('presence: ', presence) + if (presence.dem_domination) {status = "Democrat has domination"} + else if (presence.com_domination) {status = "Communist has domination"} + else if (presence.dem_control) {status = "Democrat has control"} + else if (presence.com_control) {status = "Communist has control"} + else {status = "No domination or control"} + log(`${status}`) + log(`${presence.dem_battlegrounds} Democrat battlegrounds`) + log(`${presence.com_battlegrounds} Communist battlegrounds`) + + let value = get_value(country) + console.log('value: ', value) + let dem_vp = 0 + if (presence.dem_spaces > 0) {dem_vp += value} + console.log('dem_vp after presence: ', dem_vp) + if (presence.dem_domination) {dem_vp += value} + console.log('dem_vp after domination: ', dem_vp) + if (presence.dem_control && country !== "Hungary") { + dem_vp += value + console.log('dem_vp after control: ', dem_vp)} + else if (presence.dem_control && country === "Hungary") {dem_vp += 2} + dem_vp += presence.dem_battlegrounds + console.log('dem_vp after battlegrounds: ', dem_vp) + + let com_vp = 0 + if (presence.com_spaces > 0) {com_vp += value} + if (presence.com_domination) {com_vp += value} + if (presence.com_control && country !== "Hungary") {com_vp += value} + else if (presence.com_control && country === "Hungary") {com_vp += 2} + com_vp += presence.com_battlegrounds + let change_vp = dem_vp - com_vp + game.vp += change_vp + log(`Final VP: ${change_vp} VP`) + + console.log('dem_vp: ', dem_vp) + console.log('com_vp: ', com_vp) + console.log('change_vp: ', change_vp) +} + +function get_value(country) { + let value + console.log('get_value country: ', country) + if (country === "East Germany" || country === "Poland") {value = 3} + else if (country === "Czechoslovakia" || country === "Romania" || country === "Bulgaria") {value = 2} + else value = 1 + return value +} + +function game_over() { + if (game.vp >= 20 || game.vp <= -20) { + return true + } else { return false} } // =========== MOVING THROUGH TURNS ============ +function end_round() { + game.played_card = 0 + game.is_pwr_struggle = false + if (game.active === DEM && game.round === 7) { + new_turn() + game.state = 'choose_card' + return + } + + if (game.active===COM) { + game.round_player = DEM + } else { + game.round_player = COM + game.round ++ + log_h2(`Action Round ${game.round}`) + } + next_player() + game.state = 'choose_card' + game.valid_spaces = [] +} + function new_turn() { + clear_undo() game.turn ++ game.round = 1 + game.valid_spaces=[] + game.active = COM + game.round_player = COM + game.dem_tst_attempted_this_turn = 0 + game.com_tst_attempted_this_turn = 0 log_h1("Turn " + game.turn) + + if (game.turn === 4) { + add_midyear() + } + if (game.turn === 8) { + add_lateyear() + } + if (game.turn > 1) { + draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.dem_hand_limit, game.com_hand_limit) + } log_h2("Action Round " + game.round) log_side() } function next_player() { clear_undo() - + if (game.active === DEM) game.active = COM else game.active = DEM + + log_side() } function find_space_index(name_unique) { @@ -708,31 +1818,98 @@ function find_card_index(card) { } function draw_deck(deck) { - return deck.filter(card => card && card.period === 1); + return deck.filter(card => card && card.period === 1).map(card => card.number) } -function draw_cards(deck, democrat_hand, communist_hand, hand_limit) { +function draw_cards(deck, democrat_hand, communist_hand, dem_hand_limit, com_hand_limit) { + console.log('game.valid_cards at start of draw cards: ', game.valid_cards) let turn = 'communist'; // Start with the communist player - - while (democrat_hand.length < hand_limit || communist_hand.length < hand_limit) { - if (deck.length === 0) { - console.log('No more cards in the deck.'); - break; - } - - if (turn === 'communist' && communist_hand.length < hand_limit) { - communist_hand.push(draw_card(deck).number); - turn = 'democrat'; // Switch turn - } else if (turn === 'democrat' && democrat_hand.length < hand_limit) { - democrat_hand.push(draw_card(deck).number); - turn = 'communist'; // Switch turn + while (democrat_hand.length < dem_hand_limit || communist_hand.length < com_hand_limit) { + //console.log('deck.length: ', deck.length) + if (deck.length === 0) { + log_h3('--- Reshuffle ---') + + deck.push(...game.strategy_discard) + game.strategy_discard = [] + } + + else if (turn === 'communist' && communist_hand.length < com_hand_limit) { + communist_hand.push(draw_card(deck)); + console.log('game.valid_cards after communist draw: ', JSON.stringify(game.valid_cards)); + turn = 'democrat'; + } else if(turn === 'communist' && communist_hand.length === com_hand_limit) { + turn = 'democrat'; + } + else if (turn === 'democrat' && democrat_hand.length < dem_hand_limit) { + democrat_hand.push(draw_card(deck)); + //console.log('democrat_hand: ', democrat_hand) + + console.log('game.valid_cards after democrat draw: ', JSON.stringify(game.valid_cards)); + turn = 'communist'; } - } + else if (turn === 'democrat' && democrat_hand.length === dem_hand_limit) { + turn = 'communist'; + } + } + console.log('game.valid_cards at end of draw cards: ', game.valid_cards) + clear_undo() } function draw_card(deck) { const randomIndex = Math.floor(Math.random() * deck.length); - return deck.splice(randomIndex, 1)[0]; + return deck.splice(randomIndex, 1)[0]; +} + +function discard(card) { + console.log('in discard(card)') + let find_card + if (!game.is_pwr_struggle) { + if (game.active === COM) { + find_card = game.communist_hand.indexOf(card); + game.communist_hand.splice(find_card, 1); + } else { + find_card = game.democrat_hand.indexOf(card); + game.democrat_hand.splice(find_card, 1); + } + game.strategy_discard.push(card) + + } else if (game.is_pwr_struggle) { + log(`Discarded ${power_cards[card].name}`) + console.log('dem hand before:', game.dem_pwr_hand) + console.log('card to be discarded:', card) + if (game.active === COM) { + find_card = game.com_pwr_hand.indexOf(card); + game.com_pwr_hand.splice(find_card, 1); + } else { + find_card = game.dem_pwr_hand.indexOf(card); + game.dem_pwr_hand.splice(find_card, 1); + } + game.power_struggle_discard.push(card) + console.log('dem hand after: ', game.dem_pwr_hand) + } + +} + +function add_midyear() { + const mid_year = cards.filter(card => card && card.period === 2).map(card => card.number); + game.strategy_deck.push(...mid_year); + log_h3('Mid-year cards added to draw deck') +} + + +function add_lateyear() { + const late_year = cards.filter(card => card && card.period === 2).map(card => card.number); + game.strategy_deck.push(...late_year); +} + +function reset_power() { + game.power_struggle_deck = power_cards.filter(card => card !== null).map(card => card.number) + game.dem_pwr_hand = [] + game.com_pwr_hand = [] + game.respond = 0 + game.raised_stakes_round = 0 + game.raise_stakes = 0 + game.tactics_fails = '' } // === COMMON LIBRARY === @@ -748,6 +1925,9 @@ function shuffle(list) { return list } + + + // ======== LOG COMMANDS ============= function log(msg) { @@ -849,3 +2029,129 @@ function object_copy(original) { return copy } } + + +/* =================== EVENTS ================================ */ + +global.event_1 = function() {console.log('event 1 called')} +global.event_2 = function() {console.log('event 2 called')} +global.event_3 = function() {console.log('event 3 called')} +global.event_4 = function() {console.log('event 4 called')} +global.event_5 = function() {console.log('event 5 called')} +global.event_6 = function() {console.log('event 6 called')} +global.event_7 = function() {console.log('event 7 called')} +global.event_8 = function() {console.log('event 8 called')} +global.event_9 = function() {console.log('event 9 called')} +global.event_10 = function() {console.log('event 10 called')} +global.event_11 = function() {console.log('event 11 called')} +global.event_12 = function() {console.log('event 12 called')} +global.event_13 = function() {console.log('event 13 called')} +global.event_14 = function() {console.log('event 14 called')} +global.event_15 = function() {console.log('event 15 called')} +global.event_16 = function() {console.log('event 16 called')} +global.event_17 = function() {console.log('event 17 called')} +global.event_18 = function() {console.log('event 18 called')} +global.event_19 = function() {console.log('event 19 called')} +global.event_20 = function() {console.log('event 20 called')} +global.event_21 = function() {console.log('event 21 called')} +global.event_22 = function() {console.log('event 22 called')} +global.event_23 = function() {console.log('event 23 called')} +global.event_24 = function() {console.log('event 24 called')} +global.event_25 = function() {console.log('event 25 called')} +global.event_26 = function() {console.log('event 26 called')} +global.event_27 = function() {console.log('event 27 called')} +global.event_28 = function() {console.log('event 28 called')} +global.event_29 = function() {console.log('event 29 called')} +global.event_30 = function() {console.log('event 30 called')} +global.event_31 = function() {console.log('event 31 called')} +global.event_32 = function() {console.log('event 32 called')} +global.event_33 = function() {console.log('event 33 called')} +global.event_34 = function() {console.log('event 34 called')} +global.event_35 = function() {console.log('event 35 called')} +global.event_36 = function() {console.log('event 36 called')} +global.event_37 = function() {console.log('event 37 called')} +global.event_38 = function() {console.log('event 38 called')} +global.event_39 = function() {console.log('event 39 called')} +global.event_40 = function() {console.log('event 40 called')} +global.event_41 = function() {console.log('event 41 called')} +global.event_42 = function() {console.log('event 42 called')} +global.event_43 = function() {console.log('event 43 called')} +global.event_44 = function() {console.log('event 44 called')} +global.event_45 = function() {console.log('event 45 called')} +global.event_46 = function() {console.log('event 46 called')} +global.event_47 = function() {console.log('event 47 called')} +global.event_48 = function() {console.log('event 48 called')} +global.event_49 = function() {console.log('event 49 called')} +global.event_50 = function() {console.log('event 50 called')} +global.event_51 = function() {console.log('event 51 called')} +global.event_52 = function() {console.log('event 52 called')} +global.event_53 = function() {console.log('event 53 called')} +global.event_54 = function() {console.log('event 54 called')} +global.event_55 = function() {console.log('event 55 called')} +global.event_56 = function() {console.log('event 56 called')} +global.event_57 = function() {console.log('event 57 called')} +global.event_58 = function() {console.log('event 58 called')} +global.event_59 = function() {console.log('event 59 called')} +global.event_60 = function() {console.log('event 60 called')} +global.event_61 = function() {console.log('event 61 called')} +global.event_62 = function() {console.log('event 62 called')} +global.event_63 = function() {console.log('event 63 called')} +global.event_64 = function() {console.log('event 64 called')} +global.event_65 = function() {console.log('event 65 called')} +global.event_66 = function() {console.log('event 66 called')} +global.event_67 = function() {console.log('event 67 called')} +global.event_68 = function() {console.log('event 68 called')} +global.event_69 = function() {console.log('event 69 called')} +global.event_70 = function() {console.log('event 70 called')} +global.event_71 = function() {console.log('event 71 called')} +global.event_72 = function() {console.log('event 72 called')} +global.event_73 = function() {console.log('event 73 called')} +global.event_74 = function() {console.log('event 74 called')} +global.event_75 = function() {console.log('event 75 called')} +global.event_76 = function() {console.log('event 76 called')} +global.event_77 = function() {console.log('event 77 called')} +global.event_78 = function() {console.log('event 78 called')} +global.event_79 = function() {console.log('event 79 called')} +global.event_80 = function() {console.log('event 80 called')} +global.event_81 = function() {console.log('event 81 called')} +global.event_82 = function() {console.log('event 82 called')} +global.event_83 = function() {console.log('event 83 called')} +global.event_84 = function() {console.log('event 84 called')} +global.event_85 = function() {console.log('event 85 called')} +global.event_86 = function() {console.log('event 86 called')} +global.event_87 = function() {console.log('event 87 called')} +global.event_88 = function() {console.log('event 88 called')} +global.event_89 = function() {console.log('event 89 called')} +global.event_90 = function() {console.log('event 90 called')} +global.event_91 = function() {console.log('event 91 called')} +global.event_92 = function() {console.log('event 92 called')} +global.event_93 = function() {console.log('event 93 called')} +global.event_94 = function() {console.log('event 94 called')} +global.event_95 = function() {console.log('event 95 called')} +global.event_96 = function() {console.log('event 96 called')} +global.event_97 = function() {console.log('event 97 called')} +global.event_98 = function() {console.log('event 98 called')} +global.event_99 = function() {console.log('event 99 called')} +global.event_100 = function() {console.log('event 100 called')} +global.event_101 = function() {console.log('event 101 called')} +global.event_102 = function() {console.log('event 102 called')} +global.event_103 = function() {console.log('event 103 called')} +global.event_104 = function() {console.log('event 104 called')} +global.event_105 = function() {console.log('event 105 called')} +global.event_106 = function() {console.log('event 106 called')} +global.event_107 = function() {console.log('event 107 called')} +global.event_108 = function() {console.log('event 108 called')} +global.event_109 = function() {console.log('event 109 called')} +global.event_110 = function() {console.log('event 110 called')} + + +function call_event(card) { + const event_function = `event_${card}` + console.log('checking for function: ', event_function) + console.log('available function: ', Object.keys(global)) + if (typeof global[event_function] === 'function') { + global[event_function](); + } else { + console.error(`Event function ${event_function} not found.`); + } +} -- cgit v1.2.3