summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js511
1 files changed, 249 insertions, 262 deletions
diff --git a/rules.js b/rules.js
index b71b09e..0d488d5 100644
--- a/rules.js
+++ b/rules.js
@@ -10,7 +10,7 @@ const DEM = "Democrat"
const COM = "Communist"
const first_strategy_card = 1
-const last_strategy_card = 110
+const last_strategy_card = 110
// BEGIN CONSTANTS {{{
@@ -221,7 +221,7 @@ const elite_spaces = [11, 14, 26, 42, 50, 68]
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 numberless_cards = [1, 2, 3, 4, 5, 6, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52 ]
const auto_resolve_events = [5, 8, 9, 13, 17, 25, 26, 30, 35, 50, 53, 54, 58, 59, 62, 63, 65, 70, 72, 74, 86, 99, 102, 108]
-const switch_events = [6, 20, 71]
+const switch_events = [6, 20, 71]
const one_turn_events = [ 8, 13, 25, 50, 63, 74, 49, 58, 59, 100, 101 ]
const dem_asterisks = [2, 3, 4, 5, 19, 24, 26, 29, 33, 34, 36, 39, 40, 45, 46, 48, 49, 50, 54, 56, 58, 60, 61, 62, 63, 64, 65, 66, 68, 71, 72, 73, 74, 75, 77, 81, 84, 86, 87, 89, 90, 91, 93, 94, 97, 103, 105, 108, 110]
@@ -237,9 +237,9 @@ const S_POLAND = [12,13,14,15,16,17,18,19,20,21,22,23,24,25]
const S_CZECHOSLOVAKIA = [26,27,28,29,30,31,32,33,34,35,36]
const S_HUNGARY = [37,38,39,40,41,42,43,44,45,46,47,48]
const S_ROMANIA = [49,50,51,52,53,54,55,56,57,58,59,60,61,62]
-const S_BULGARIA = [63,64,65,66,67,68,69,70,71,72,73,74]
+const S_BULGARIA = [63,64,65,66,67,68,69,70,71,72,73,74]
-exports.scenarios = [
+exports.scenarios = [
"Standard",
"Democrat +1 SP",
"Democrat +2 SP"
@@ -306,13 +306,13 @@ exports.setup = function (seed, scenario, options) {
log_h1("1989 Dawn of Freedom")
game.active = COM
- if (scenario === "Standard")
+ if (scenario === "Standard")
standard_setup()
else if (scenario === "Democrat +1 SP")
democrat_setup_1()
else if (scenario === "Democrat +2 SP")
democrat_setup_2()
- else
+ else
throw new Error("Unknown scenario:", scenario)
start_game()
return game
@@ -333,7 +333,7 @@ function start_game() {
game.temp = 0
// Set variable event cards where event is playable at start of game
-
+
game.playable_cards = [C_THE_WALL, C_GORBACHEV_CHARMS_THE_WEST, C_HONECKER, C_COMMON_EUROPEAN_HOME, C_MALTA_SUMMIT]
draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.dem_hand_limit, game.com_hand_limit)
@@ -406,10 +406,9 @@ exports.view = function(state, player) {
view.played_power_card = game.played_power_card
view.power_card_1 = game.power_card_1
view.power_card_2 = game.power_card_2
- }
+ }
view.strategy_discard = game.strategy_discard
-
-
+
if (player === game.active && game.vm && game.vm.draw)
view.drawn = game.vm.draw
@@ -425,7 +424,7 @@ exports.view = function(state, player) {
}
view.set_aside = game.democrat_set_aside /*Is this being used? */
view.power_hand = [...game.dem_pwr_hand].sort((a, b) => a - b)
-
+
} else if (player === COM) {
view.hand = game.communist_hand
if (game.opp_power_hand && game.pwr_struggle_in === 'Romania') {view.opp_power_hand = [...game.dem_pwr_hand].sort((a, b) => a - b) }
@@ -434,7 +433,7 @@ exports.view = function(state, player) {
if (player === DEM) {
view.samizdat = game.samizdat_card
- }
+ }
if (game.state === "game_over") {
view.prompt = game.victory
@@ -516,7 +515,7 @@ states.place_starting_infl = {
gen_action("done");
return;
} else if ((game.starting_infl.length === 5 && game.temp > 2) || game.temp > 3) {
- view.prompt = `Place your last ${pluralize(game.available_ops,'starting SP')}.`
+ view.prompt = `Place your last ${pluralize(game.available_ops,'starting SP')}.`
} else {
view.prompt = `Place ${pluralize(game.available_ops,'starting SP')}.`
}
@@ -526,7 +525,7 @@ states.place_starting_infl = {
},
space(space) {
add_infl(space, 'available_ops')
- },
+ },
done() {
do_log_summary()
game.temp ++
@@ -552,7 +551,7 @@ states.choose_card = {
} else {
view.prompt = 'Choose a card.'
let available_cards
- if (game.active === DEM) {
+ if (game.active === DEM) {
available_cards = game.democrat_hand
} else {
available_cards = game.communist_hand
@@ -586,7 +585,7 @@ states.choose_card = {
states.confirm_card = {
inactive: 'choose a card.',
prompt() {
- let scoring_cards_count = count_scoring_cards()
+ let scoring_cards_count = count_scoring_cards()
view.prompt = `${pluralize(scoring_cards_count,'scoring card')} in hand with ${pluralize(8-game.round,'Action Round')} remaining. Scoring cards may not be held. Continue?`
gen_action('continue')
},
@@ -606,7 +605,7 @@ states.play_card ={
gen_action('event')
return
}
-
+
// Check for Reformer Rehabilitated
if (game.played_card === C_REFORMER_REHABILITATED && game.playable_cards.includes(C_REFORMER_REHABILITATED)){
if (game.active === DEM && (game.dem_tst_position > game.com_tst_position)) {
@@ -616,7 +615,7 @@ states.play_card ={
gen_action('event')
}
}
-
+
//Check for events
if (event_is_playable(game.played_card)) {
if ((game.active === DEM && cards[game.played_card].side === 'C' && game.dem_tst_position >= 7 && game.com_tst_position < 7 && !game.tst_7) || (game.active === COM && cards[game.played_card].side === 'D' && game.com_tst_position >= 7 && game.dem_tst_position < 7 && !game.tst_7)){
@@ -628,7 +627,7 @@ states.play_card ={
//Continue with normal logic
get_events(game.played_card)
- }
+ }
gen_action('influence')
gen_action('support_check')
@@ -761,7 +760,7 @@ states.resolve_opponent_event = {
goto_vm(game.vm_event)}
else {
if (game.active === DEM) {
- game.return = COM
+ game.return = COM
} else {
game.return = DEM
}
@@ -801,7 +800,7 @@ states.add_influence = {
},
space(space) {
add_infl(space, 'available_ops')
- },
+ },
end_round() {
push_undo()
do_log_summary()
@@ -836,8 +835,8 @@ states.tiananmen_square_attempt_success = {
} else {
view.prompt = 'Tiananmen Square Track attempt successful.'
gen_action('end_round')
- }
-
+ }
+
},
done () {
push_undo()
@@ -852,7 +851,7 @@ states.tiananmen_square_attempt_success = {
states.tiananmen_square_attempt_fail = {
inactive: 'do Tiananmen Square Attempt.',
prompt () {
- view.prompt = 'Tiananmen Square Track attempt failed.'
+ view.prompt = 'Tiananmen Square Track attempt failed.'
gen_action('end_round')
},
end_round () {
@@ -864,7 +863,7 @@ states.tiananmen_square_attempt_fail = {
states.tiananmen_square_attempt_done = {
inactive: 'do Tiananmen Square Attempt.',
prompt () {
- view.prompt = 'Tiananmen Square Track attempt: done.'
+ view.prompt = 'Tiananmen Square Track attempt: done.'
gen_action('end_round')
},
end_round () {
@@ -943,7 +942,7 @@ states.support_check_prep = {
}
}
}
-
+
game.state = 'do_support_check'
},
end_round() {
@@ -955,9 +954,9 @@ states.support_check_prep = {
if (game.is_pwr_struggle) {/*Crowd Turns Against Ceausescu should be the only time you end up here during a power struggle */
if (game.return !== game.active) {
next_player()
- }
+ }
log_h2('Raise the Stakes')
- game.state = 'raise_stakes_1'
+ game.state = 'raise_stakes_1'
return
}
reset_austria_hungary_border_reopened()
@@ -1143,12 +1142,12 @@ states.vm_the_crowd_turns_against_ceausescu = {
states.the_crowd_turns_against_ceausescu_infl = {
inactive: 'add SPs.',
prompt () {
- if (game.vm_available_ops === 0)
+ if (game.vm_available_ops === 0)
{
view.prompt = 'Place SPs: done.';
gen_action("done");
return;
- }
+ }
view.prompt = `Add SPs: ${game.vm_available_ops} remaining`
for (let space of game.valid_spaces) {
@@ -1157,12 +1156,12 @@ states.the_crowd_turns_against_ceausescu_infl = {
},
space(space) {
add_infl(space, 'vm_available_ops')
- },
+ },
done() {
do_log_summary()
if (game.return !== game.active) {
next_player()
- }
+ }
log_h2('Raise the Stakes')
game.state = 'raise_stakes_1'
}
@@ -1182,7 +1181,7 @@ states.raise_stakes_1 = {
view.prompt = `Discard ${3-game.raised_stakes_discard} cards to raise the stakes.`
if (game.raised_stakes_discard === 0) {
gen_action('pass')
- }
+ }
for (let card of game.valid_cards) {
gen_action_power_card(card)
}
@@ -1194,9 +1193,9 @@ states.raise_stakes_1 = {
log(`Discarded: P${card}`)
} else {
log(`Discarded: P${card} V${power_cards[card].value}`)
- }
+ }
discard(card)
-
+
game.raised_stakes_discard ++
if (game.raised_stakes_discard === 3) {
game.raised_stakes++
@@ -1242,7 +1241,7 @@ states.raise_stakes_2 = {
view.prompt = `Discard ${3-game.raised_stakes_discard} cards to raise the stakes.`
if (game.raised_stakes_discard === 0) {
gen_action('pass')
- }
+ }
for (let card of game.valid_cards) {
gen_action_power_card(card)
}
@@ -1254,7 +1253,7 @@ states.raise_stakes_2 = {
log(`Discarded: P${card}`)
} else {
log(`Discarded: P${card} V${power_cards[card].value}`)
- }
+ }
discard(card)
game.raised_stakes_discard ++
@@ -1278,7 +1277,7 @@ states.power_struggle = {
prompt () {
if (game.phase === 0) {
if (game.valid_cards.length > 0) {
- view.prompt = "Play a card."
+ view.prompt = "Play a card."
for (let card of game.valid_cards) {
gen_action_power_card(card)
}
@@ -1297,19 +1296,19 @@ states.power_struggle = {
} else {
view.prompt = `${base_prompt} You must concede.`;
}
- gen_action('concede')
- }
+ gen_action('concede')
+ }
else if (game.phase === 2) {
view.prompt = 'You matched. Roll a die.'
gen_action('roll')
- }
+ }
else if (game.phase === 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')}
- }
+ }
},
power_card(card) {
push_undo()
@@ -1326,7 +1325,7 @@ states.power_struggle = {
if (game.phase === 0) {delete game.proxy_power_card}
if (card === PC_TACTIC_FAILS) {
if (game.proxy_power_card) {
- log_gap(`Played P${PC_TACTIC_FAILS}: ${game.proxy_power_card} no longer playable`)
+ log_gap(`Played P${PC_TACTIC_FAILS}: ${game.proxy_power_card} no longer playable`)
} else {
log_gap(`Played P${PC_TACTIC_FAILS}: P${game.played_power_card} no longer playable`)
}
@@ -1336,10 +1335,10 @@ states.power_struggle = {
log_gap(`Played: P${card}`)
} else {
log_gap(`Played: P${card} V${power_cards[card].value}`)
- }
+ }
}
if (game.phase === 0) {
- if (leader_cards.includes(card)) {
+ if (leader_cards.includes(card)) {
game.played_power_card = card
game.phase = 3
} else if (card === 51){ /*Scare Tactics */
@@ -1355,7 +1354,7 @@ states.power_struggle = {
} else if (game.phase === 0 && card === 49) { /*Support Falters */
next_player()
goto_vm(349)
- } else {
+ } else {
game.played_power_card = card
game.phase = 1
next_player()
@@ -1364,7 +1363,7 @@ states.power_struggle = {
} else if (game.phase === 1) {
if (card === PC_TACTIC_FAILS) {
if (game.proxy_power_card) {
- game.tactics_fails = game.proxy_power_card
+ game.tactics_fails = game.proxy_power_card
} else {
game.tactics_fails = power_cards[game.played_power_card].name
}
@@ -1377,8 +1376,8 @@ states.power_struggle = {
do_valid_cards()
} else {
game.phase = 2
- }
- }
+ }
+ }
},
roll () {
clear_undo()
@@ -1405,7 +1404,7 @@ states.power_struggle = {
log_h3('Support Loss')
if (game.phase === 0) {
game.played_power_card = 0
- game.proxy_power_card = 0 /*If conceded when held the initiative but had no playable cards, ignore the last played card */
+ game.proxy_power_card = 0 /*If conceded when held the initiative but had no playable cards, ignore the last played card */
}
game.phase = 0
game.state = 'support_loss'
@@ -1529,7 +1528,7 @@ states.vp_roll = {
log_h2('Scoring')
score_country(game.pwr_struggle_in)
resolve_tyrant()
- },
+ },
}
states.choose_power = {
@@ -1614,7 +1613,7 @@ states.end_turn_4_5_4 = {
if (!dem_has_scoring_card && !com_has_scoring_card) {
log('No held scoring cards')
}
-
+
if (dem_has_scoring_card && com_has_scoring_card) {
log('Both players have held scoring cards')
goto_game_over('', `The game is tied due to held scoring cards!`)
@@ -1626,7 +1625,7 @@ states.end_turn_4_5_4 = {
else if (com_has_scoring_card) {
log('Communist player has a held scoring card')
goto_game_over(DEM, `${DEM} won by held scoring card!`)
- }
+ }
else if (game.persistent_events.includes(C_NEW_YEARS_EVE_PARTY)) {
log_h1(`New Year's Eve Party`)
game.vm_event = 104
@@ -1651,7 +1650,7 @@ states.end_turn_4_5_4 = {
log(`Communist receives 2 VP from C97`)
}
game.state = 'final_scoring_held'
-
+
} else {
new_turn()
}
@@ -1736,7 +1735,7 @@ states.game_over = {
},
}
-// ========================== EVENT SPECIFIC STATES =================================
+// ========================== EVENT SPECIFIC STATES =================================
states.general_strike = {
inactive: 'discard a card.',
@@ -1750,7 +1749,7 @@ states.general_strike = {
} else if (game.played_card > 0 ) {
view.prompt = 'General Strike: roll a die.'
gen_action('roll')
- }
+ }
},
card (card) {
push_undo()
@@ -1770,7 +1769,7 @@ states.general_strike = {
},
roll() {
clear_undo()
- let roll = roll_d6()
+ let roll = roll_d6()
log(`Roll: D${roll}`)
logi(`+${game.available_ops} ops`)
let total = roll + game.available_ops
@@ -1784,7 +1783,7 @@ states.general_strike = {
log('The strike continues. Required 6 or more')
}
game.state = 'end_round'
- },
+ },
}
states.honecker ={
@@ -1901,10 +1900,10 @@ states.stasi_end_round = {
return
}
view.prompt = 'Stasi: you must select your next card to play.'
-
+
for (let card of game.democrat_hand) {
gen_action_card(card)
- }
+ }
},
card(card) {
push_undo()
@@ -1926,7 +1925,7 @@ states.stasi_end_round = {
states.stasi_confirm_scoring_card = {
inactive: 'choose a card.',
- prompt() {
+ prompt() {
view.prompt = `${pluralize(count_scoring_cards(),'scoring card')} in hand with ${pluralize(7-game.round,'Action Round')} remaining. Scoring cards may not be held. Continue?`
gen_action('continue')
},
@@ -1962,7 +1961,7 @@ states.stasi_confirm = {
states.stasi_play_card = {
inactive: 'play a card.',
- prompt () {
+ prompt () {
if (game.democrat_hand.length === 0) {
view.prompt = 'Stasi: you must pass.'
gen_action('pass')
@@ -2018,21 +2017,19 @@ states.stasi_resolve_common_european_home = {
}
}
-
// ==================== SUPPORTING STATE FUNCTIONS =============================
-
function add_infl(space, ops) {
push_undo()
log_summary(`Added £ SP in %${space}`)
-
+
//If AHBR - check AHBR conditions
if (game.persistent_events.includes(58)) {
if (spaces[space].country !== 'East_Germany'){
game.austria_hungary_border_reopened_tracker = false
}
}
-
+
// Check Genscher
if (game.persistent_events.includes(C_GENSCHER) && game.active === DEM && spaces[space].country === 'East_Germany' && check_com_control(space)) {
game[ops]--
@@ -2042,7 +2039,7 @@ function add_infl(space, ops) {
//Check if Austria Hungary Border Reopened was used to place last SP in a controlled space in East Germany. If so, game.available_op will be negative
if (game[ops] < 0) {
log_summary(`(Used +1 op from C${C_AUSTRIA_HUNGARY_BORDER_REOPENED})`)
- }
+ }
} else {
game[ops]--
}
@@ -2064,22 +2061,22 @@ function add_infl(space, ops) {
}
// If only 1 IP remaining, may not place in opponent controlled spaces
-
+
// Check for Genscher & Austria Hungary Border Reopened
-
+
if (game[ops] === 1) {
if (game.active === DEM) {
if (game.persistent_events.includes(63) || (game.persistent_events.includes(58) && game.austria_hungary_border_reopened_tracker)) {
game.valid_spaces = game.valid_spaces.filter(n => !(check_opp_control(n) && spaces[n].country !== 'East_Germany'))
- } else {
+ } else {
game.valid_spaces = game.valid_spaces.filter(n => !check_opp_control(n))
}
} else {
game.valid_spaces = game.valid_spaces.filter(n => !check_opp_control(n))
}
- }
+ }
- //Clear valid spaces if no IP remaining.
+ //Clear valid spaces if no IP remaining.
if (game[ops] <= 0 ) {
game.valid_spaces = []
}
@@ -2088,7 +2085,7 @@ function add_infl(space, ops) {
function remove_infl(space, ops) {
push_undo()
log_summary(`Removed £ SP from %${space}`)
-
+
if (game.remove_opponent_infl === true) {
if (game.active === COM) {
game.demInfl[space]--
@@ -2116,7 +2113,7 @@ function remove_infl(space, ops) {
}
}
check_tyrant()
- }
+ }
game[ops]--
if (game.vm_influence_added && game.vm_influence_added[space] >= 0) {game.vm_influence_added[space]++}
if (game[ops]===0) {game.valid_spaces = []}
@@ -2133,12 +2130,12 @@ function do_sc(space) {
if (game.active === COM && game.persistent_events.includes(C_THE_WALL) && spaces[space].country === 'East_Germany') {
logi(`No adjacency for Democrats due to C${C_THE_WALL}`)
log_gap(`Roll: D${roll}`)
- }
+ }
// Continue with Support Check Logic
else { log(`Roll: D${roll}`) }
-
+
// Check for the Crowd Turns Against Ceausescu
-
+
if (game.is_pwr_struggle) {
roll += game.vm_available_ops
logi(`+${game.vm_available_ops} from Ceausescu`)
@@ -2152,7 +2149,7 @@ function do_sc(space) {
logi('+2 TST award')
}
else {
- let card_ops = get_card_ops(this_card())
+ let card_ops = get_card_ops(this_card())
roll += card_ops
logi(`+${card_ops} from card ops`)
}
@@ -2201,8 +2198,8 @@ function do_sc(space) {
logi(`+${adj.com_adj} adjacency`)
}
permanently_remove(C_THE_WALL)
-
- // Standard adjacency
+
+ // Standard adjacency
} else {
if (adj.dem_adj > 0 || adj.com_adj > 0 ){
if (game.active === DEM) {
@@ -2282,7 +2279,6 @@ function do_sc(space) {
log(`C${C_THE_WALL} no longer in effect`)
}
-
// If Austria-Hungary Border Reopened used, all future support checks must be in East Germany
if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)){
if (game.austria_hungary_border_reopened_tracker) {
@@ -2321,14 +2317,14 @@ function valid_spaces_sc() {
let infl = game.comInfl[i]
if (infl !== 0 ) {
valid_spaces_set.add(space.space_id);
- }
+ }
} else {
let infl = game.demInfl[i]
if (infl !== 0 ) {
// Check Events that block support checks in a given space
if (game.persistent_events.includes(C_SOLIDARITY_LEGALIZED) && space.space_id === S_GDANSK) {continue}
if (game.persistent_events.includes(C_WE_ARE_THE_PEOPLE) && space.space_id === S_LEIPZIG) {continue}
- if (game.persistent_events.includes(C_FOREIGN_CURRENCY_DEBT_BURDEN) && space.country === game.foreign_currency_debt_burden) {continue}
+ if (game.persistent_events.includes(C_FOREIGN_CURRENCY_DEBT_BURDEN) && space.country === game.foreign_currency_debt_burden) {continue}
valid_spaces_set.add(space.space_id);
}
@@ -2366,7 +2362,7 @@ function valid_spaces_support_loss() {
function valid_spaces_infl() {
// Check if function is called from the VM or not, take relevant ops variable
let ops = game.state.startsWith('vm') ? game.vm_available_ops : game.available_ops;
-
+
let valid_spaces_set = new Set();
for (let i = 0; i < game.demInfl.length; i++) {
let space = spaces[i]
@@ -2380,23 +2376,22 @@ function valid_spaces_infl() {
for (let adj_space_id of adjacent_spaces) {
if (adj_space_id >= 0) {
const adj_piece = spaces[adj_space_id];
-
+
// Check if the adjacent space is controlled by the opponent
const opponent_control = check_opp_control(adj_piece.space_id)
-
+
//Check for Genscher. Can always place in East Germany even with 1 op
if (game.active === DEM && adj_piece.country === 'East_Germany' && game.persistent_events.includes(C_GENSCHER)){
valid_spaces_set.add(adj_piece.space_id)
}
-
// Otherwise, only add the adjacent space if the available_ops >= 2 or the space is not controlled by the opponent
if (ops >= 2 || !opponent_control) {
valid_spaces_set.add(adj_piece.space_id)
}
}
}
- }
+ }
}
game.valid_spaces = Array.from(valid_spaces_set);
return game.valid_spaces;
@@ -2405,7 +2400,7 @@ function valid_spaces_infl() {
function valid_cards(player_hand, presence) {
const valid_cards_set = new Set()
if (game.phase === 0) {
-
+
for (let c of player_hand) {
let card = power_cards[c]
// Never add tactics fails
@@ -2416,8 +2411,7 @@ function valid_cards(player_hand, presence) {
if (card.name === game.tactics_fails) {
continue
}
-
-
+
if (card.socio === 0) {
valid_cards_set.add(c)
} else if (leaders.includes(card.socio) && presence[card.socio]) {
@@ -2462,7 +2456,7 @@ function count_adj(space_id) {
if (check_com_control(adj_space_id)) {
com_adj++
}
- }
+ }
return {dem_adj, com_adj}
}
@@ -2594,7 +2588,7 @@ function do_tst_attempt() {
//Check if TST events occur
if (game.com_tst_position === 3 && game.dem_tst_position < 3) {game.vm_event = 203}
else if (game.com_tst_position === 4 && game.dem_tst_position < 4) {game.vm_event = 204}
- game.state = 'tiananmen_square_attempt_success'
+ game.state = 'tiananmen_square_attempt_success'
} else {
log(`${com_tst_req[game.com_tst_position]} required: fail`)
game.com_tst_attempted = 1
@@ -2612,7 +2606,6 @@ function check_presence(country) {
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 i = 0; i < spaces.length; i++) {
let space = spaces[i]
if (space.country === country) {
@@ -2732,7 +2725,7 @@ function score_country(country) {
} else {
log('No presence: 0 VP')
}
- }
+ }
else if (presence.com_control || presence.com_domination) {
log('Communist:')
if (presence.com_control) {
@@ -2753,7 +2746,7 @@ function score_country(country) {
dem_vp += value_presence
if (presence.dem_battlegrounds > 0) {
logi(`Battlegrounds: +${presence.dem_battlegrounds} VP`)
- dem_vp += presence.dem_battlegrounds
+ dem_vp += presence.dem_battlegrounds
}
log (`Total: +${dem_vp} VP`)
} else {
@@ -2783,7 +2776,7 @@ function score_country(country) {
logi(`Presence: +${value_presence} VP`)
dem_vp += value_presence
if (presence.dem_battlegrounds > 0) {
- logi(`Battlegrounds: +${presence.dem_battlegrounds} VP`)
+ logi(`Battlegrounds: +${presence.dem_battlegrounds} VP`)
dem_vp += presence.dem_battlegrounds
} else {
logi('No battlegrounds')
@@ -2795,8 +2788,8 @@ function score_country(country) {
}
//Calculate change VP
- let change_vp = dem_vp + com_vp
- game.vp += change_vp
+ let change_vp = dem_vp + com_vp
+ game.vp += change_vp
if (change_vp > 0 ) {
log_gap(`Scoring: +${change_vp} VP`)
} else {
@@ -2823,7 +2816,7 @@ function get_end_infl_prompt() {
function get_aftermath_roll() {
clear_undo()
- let roll = roll_d6()
+ let roll = roll_d6()
log(`Roll: D${roll}`)
let rally_win = 0
let petition_win = 0
@@ -2845,7 +2838,7 @@ function get_aftermath_roll() {
}
if (modified_roll < 0) {modified_roll = 0}
else if (modified_roll > 7) {modified_roll = 7}
-
+
if (game.raised_stakes !== 0) {
logi(`+${game.raised_stakes} from Raising the Stakes`)
}
@@ -2857,7 +2850,7 @@ function get_aftermath_roll() {
}
if (modified_roll !== roll) {
log(`Modified roll: ${modified_roll}`)
- }
+ }
return modified_roll
}
@@ -2938,7 +2931,7 @@ function end_goddess() {
log_h2("Action Round " + game.round)
if (game.active === DEM) {
next_player()
- } else {
+ } else {
log_side()
}
if (game.persistent_events.includes(5)) {
@@ -2961,7 +2954,7 @@ function check_reformer() { /*Is this function still used?*/
function count_scoring_cards() {
let scoring_check
if (game.active === DEM) {
- scoring_check = game.democrat_hand.filter(card => scoring_cards.includes(card)).length
+ scoring_check = game.democrat_hand.filter(card => scoring_cards.includes(card)).length
} else {
scoring_check = game.communist_hand.filter(card => scoring_cards.includes(card)).length
}
@@ -3013,7 +3006,7 @@ function is_auto_resolve(card) {
let ceausecu_events = [10, 41, 69, 101, 107]
if (auto_resolve_events.includes(card)) {
return true
- }
+ }
else if (card === C_THE_TYRANT_IS_GONE) {
if (game.persistent_events.includes(C_THE_CROWD_TURNS_AGAINST_CEAUSESCU)) {
return true
@@ -3024,22 +3017,22 @@ function is_auto_resolve(card) {
}
else if (card === C_KOHL_PROPOSES_REUNIFICATION && !game.persistent_events.includes(C_THE_WALL_MUST_GO)) {
return true
- }
+ }
else if (card === C_BROUGHT_IN_FOR_QUESTIONING && game.active === DEM) {
- if (game.democrat_hand.length === 0) {
+ if (game.democrat_hand.length === 0) {
if (!game.state.startsWith('vm')) { logi('Democrat has no cards to discard') }
return true }
- }
+ }
else if (card === C_DEUTSCHE_MARKS && game.active === DEM) {
- if (game.democrat_hand.length === 0) {
+ if (game.democrat_hand.length === 0) {
if (!game.state.startsWith('vm')) { logi('Democrat has no cards to give') }
return true }
- }
+ }
else if (card === C_KISS_OF_DEATH && game.active === COM) {
- if (game.communist_hand.length === 0) {
+ if (game.communist_hand.length === 0) {
if (!game.state.startsWith('vm')) { logi('Communist has no cards to discard') }
return true }
- }
+ }
else if (card === C_DISSIDENT_ARRESTED && game.active === DEM) {
let dem_intellectual_infl = spaces.filter(space => space.socio === 5 && game.demInfl[space.space_id] > 0).length
if (dem_intellectual_infl === 0) {
@@ -3048,38 +3041,38 @@ function is_auto_resolve(card) {
}
} else if ((card === C_SAJUDIS || card === C_THE_BALTIC_WAY) && game.active === COM) {
if (game.systematization && game.systematization === S_HARGHITA_COVASNA ) {
- if (check_dem_control(S_RAZGRAD)) {
+ if (check_dem_control(S_RAZGRAD)) {
if (!game.state.startsWith('vm')) { logi('Minorities spaces already controlled') }
return true
- }
- } else if (check_dem_control(S_RAZGRAD) && check_dem_control(S_HARGHITA_COVASNA)) {
+ }
+ } else if (check_dem_control(S_RAZGRAD) && check_dem_control(S_HARGHITA_COVASNA)) {
if (!game.state.startsWith('vm')) { logi('Minorities spaces already controlled') }
- return true
+ return true
}
} else if (card === C_CEAUSESCU && game.active === DEM) {
let dem_romania_infl = spaces.filter(space => space.country === 'Romania' && game.demInfl[space.space_id] > 0).length
if (dem_romania_infl === 0) {
if (!game.state.startsWith('vm')) { logi('No influence to remove') }
- return true
+ return true
}
- }
+ }
else if (card === C_WE_ARE_THE_PEOPLE && game.active === COM) {
if (game.demInfl[S_LUTHERAN_CHURCH] === 0) {
if (!game.state.startsWith('vm')) { logi('No influence to remove') }
return true
}
- }
+ }
else if (card === C_BETRAYAL && game.active === DEM) {
if (!game.systematization === S_ORTHODOX_CHURCH_ROMANIA) {
if (game.demInfl[S_ORTHODOX_CHURCH_BULGARIA] === 0) {
if (!game.state.startsWith('vm')) { logi('No influence to remove') }
return true
}
- } else if (game.demInfl[S_ORTHODOX_CHURCH_BULGARIA] === 0 && game.demInfl[S_ORTHODOX_CHURCH_ROMANIA] === 0) {
+ } else if (game.demInfl[S_ORTHODOX_CHURCH_BULGARIA] === 0 && game.demInfl[S_ORTHODOX_CHURCH_ROMANIA] === 0) {
if (!game.state.startsWith('vm')) { logi('No influence to remove') }
- return true
+ return true
}
- }
+ }
else if (card === C_GOVERNMENT_RESIGNS && game.active === COM) {
let uncontrolled_elites = spaces.filter( space => spaces[space.space_id].socio === 1 && game.comInfl[space.space_id] > 0 && !check_control(space.space_id)).length
if (uncontrolled_elites === 0) {
@@ -3108,7 +3101,7 @@ function is_auto_resolve(card) {
return true
}
} else if (card === C_UNION_OF_DEMOCRATIC_FORCES && game.active === COM) {
- let bulgarian_presence = spaces.filter(space => space.country === 'Bulgaria' && game.comInfl[space.space_id] > 0).length
+ let bulgarian_presence = spaces.filter(space => space.country === 'Bulgaria' && game.comInfl[space.space_id] > 0).length
if (bulgarian_presence === 0) {
if (!game.state.startsWith('vm')) { logi('No SPs to remove') }
return true
@@ -3127,38 +3120,38 @@ function is_auto_resolve(card) {
let dem_germany_infl = spaces.filter(space => space.country === 'East_Germany' && game.demInfl[space.space_id] > 0).length
if (dem_germany_infl === 0) {
if (!game.state.startsWith('vm')) { logi('No influence to remove') }
- return true
+ return true
}
} else if (card === C_MY_FIRST_BANANA && game.active === COM) {
let com_germany_infl = spaces.filter(space => space.country === 'East_Germany' && game.comInfl[space.space_id] > 0).length
if (com_germany_infl === 0) {
if (!game.state.startsWith('vm')) { logi('No influence to remove') }
- return true
+ return true
}
} else if (card === C_POLITBURO_INTRIGUE && game.active === DEM) {
let dem_bulgaria_infl = spaces.filter(space => space.country === 'Bulgaria' && game.demInfl[space.space_id] > 0).length
if (dem_bulgaria_infl === 0) {
if (!game.state.startsWith('vm')) { logi('No influence to remove') }
- return true
+ return true
}
} else if (card === C_SOLIDARITY_LEGALIZED) {
let uncontrolled_worker_farmer = vm_valid_spaces_solidarity_legalised()
if (uncontrolled_worker_farmer.length === 0) {
if (!game.state.startsWith('vm')) { logi('No uncontrolled Worker or Farmer spaces in Poland') }
- return true
+ return true
}
}
else {
return false
}
}
-
+
function get_events(card){
if (event_is_playable(card)) {
if (cards[card].side === 'D') {
if (game.active === DEM) {gen_action('event')}
if (game.active === COM) {gen_action('opp_event')}
- }
+ }
else if (cards[card].side === 'C') {
if (game.active === COM) {gen_action('event')}
if (game.active === DEM) {gen_action('opp_event')}
@@ -3177,7 +3170,7 @@ function event_is_playable(card) {
//Check for Common European Home under Stasi
else if (game.stasi_card === C_COMMON_EUROPEAN_HOME && card === C_COMMON_EUROPEAN_HOME && game.active === DEM) {
return false
- }
+ }
//Check for The Chinese Solution
else if (game.com_tst_position >= 7 && card === C_THE_CHINESE_SOLUTION) {
return true
@@ -3203,15 +3196,15 @@ function get_card_ops(card) {
if(game.state === 'choose_card' || game.state === 'stasi_play_card' || game.state === 'vm_common_european_home_play' || game.state === 'general_strike') {
log(`+1 op from C${C_PERESTROIKA}`)
}
- ops ++
- }
+ ops ++
+ }
if (game.persistent_events.includes(C_THE_SINATRA_DOCTRINE) && game.active === DEM) {
if(game.state === 'choose_card' || game.state === 'stasi_play_card' || game.state === 'vm_common_european_home_play' || game.state === 'vm_laszlo_tokes') {
log(`+1 op from C${C_THE_SINATRA_DOCTRINE}`)
}
ops ++
- }
-
+ }
+
if ((game.active === DEM && game.dem_tst_position >= 2 && game.com_tst_position <= 1 && cards[card].ops === 1) || (game.active === COM && game.com_tst_position >=2 && game.dem_tst_position <= 1 && cards[card].ops === 1)) {
if(game.state === 'choose_card' || game.state === 'stasi_play_card' || game.state === 'vm_common_european_home_play') {
log('+1 op from Tiananmen Square Track')
@@ -3255,12 +3248,12 @@ function get_tst_6_ops() {
let ops = 0
if (game.persistent_events.includes(C_PERESTROIKA) && game.active === COM) {
logi(`+1 op from C${C_PERESTROIKA}`)
- ops ++
- }
+ ops ++
+ }
if (game.persistent_events.includes(C_THE_SINATRA_DOCTRINE) && game.active === DEM) {
logi(`+1 op from C${C_THE_SINATRA_DOCTRINE}`)
ops ++
- }
+ }
if ((game.active === DEM && game.prudence && game.prudence.DEM !== 0)) {
if (ops > 0) {
log(`${pluralize(game.prudence.DEM,'op')} from C${C_PRUDENCE}`)
@@ -3305,7 +3298,7 @@ function finish_play_card() {
if (cards[game.played_card].playable || game.playable_cards.includes(game.played_card)) {
if ((game.active === DEM && cards[game.played_card].side === "C" ) || (game.active === COM && cards[game.played_card].side === "D")) {
- game.vm_event_to_do = true
+ game.vm_event_to_do = true
}
}
}
@@ -3360,7 +3353,7 @@ function end_round() {
game.strategy_discard.push(game.played_card)
}
- //Reset
+ //Reset
game.played_card = 0
delete game.temp
delete game.vm_event
@@ -3431,7 +3424,7 @@ function end_round() {
}
game.state = 'honecker'
return
- }
+ }
else if (game.dem_tst_position >= 6 && game.com_tst_position <= 5) {
if (game.active !== DEM) {
next_player()
@@ -3455,9 +3448,9 @@ function end_round() {
clear_undo()
game.state = 'end_turn_4_5_4'
return
- }
+ }
}
-
+
// Resolve end action round
//Stasi check
if(game.round_player === COM && game.persistent_events.includes(C_STASI)) {
@@ -3467,7 +3460,7 @@ function end_round() {
game.state = 'end_turn_4_5_4'
return
}
- //Otherwise go to Stasi
+ //Otherwise go to Stasi
game.round_player = DEM
if (game.active !== DEM) {
next_player()
@@ -3482,13 +3475,13 @@ function end_round() {
game.state = 'choose_card'
}
return
- }
+ }
//Check if in extra Action Round
- else if (game.round_player === COM && game.round === 8) {
+ else if (game.round_player === COM && game.round === 8) {
clear_undo()
game.state = 'end_turn_4_5_4'
return
- }
+ }
//Normal round end
else if (game.round_player===COM) {
game.round_player = DEM
@@ -3582,8 +3575,8 @@ function new_turn() {
}
draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.dem_hand_limit, game.com_hand_limit)
game.com_hand_limit = 8
- }
-
+ }
+
//Check if TST effects need to be resolved
if ((game.dem_tst_position >=5 && game.com_tst_position <= 4) || (game.com_tst_position >= 5 && game.dem_tst_position <= 4)) {
log_h2('Tiananmen Square Track Award')
@@ -3606,13 +3599,13 @@ function new_turn() {
}
else {
game.state = 'choose_card'
- }
+ }
}
}
function end_one_turn_event(event) {
game.persistent_events = game.persistent_events.filter(n => n !== event)
- game.strategy_removed.push(event)
+ game.strategy_removed.push(event)
log_summary(`C${event}`)
}
@@ -3655,7 +3648,7 @@ function draw_deck() {
function draw_cards(deck, democrat_hand, communist_hand, dem_hand_limit, com_hand_limit) {
//Start with the communist player
- let turn = 'communist';
+ let turn = 'communist';
while (democrat_hand.length < dem_hand_limit || communist_hand.length < com_hand_limit) {
if (deck.length === 0) {
log_h3('--- Reshuffle ---')
@@ -3663,20 +3656,20 @@ function draw_cards(deck, democrat_hand, communist_hand, dem_hand_limit, com_han
game.strategy_discard = []
} else if (turn === 'communist' && communist_hand.length < com_hand_limit) {
communist_hand.push(draw_card(deck));
- turn = 'democrat';
+ 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));
- turn = 'communist';
+ turn = 'communist';
}
else if (turn === 'democrat' && democrat_hand.length === dem_hand_limit) {
turn = 'communist';
}
- }
+ }
clear_undo()
-}
+}
function draw_card(deck) {
if (deck.length === 0) {
@@ -3711,7 +3704,7 @@ function discard(card) {
game.dem_pwr_hand.splice(find_card, 1);
}
game.power_struggle_discard.push(card)
- }
+ }
}
function silent_discard(card) {
let find_card
@@ -3725,7 +3718,7 @@ function silent_discard(card) {
}
if (!game.strategy_discard.includes(card)) {
game.strategy_discard.push(card)
- }
+ }
} else if (game.is_pwr_struggle) {
if (game.active === COM) {
find_card = game.com_pwr_hand.indexOf(card);
@@ -3735,7 +3728,7 @@ function silent_discard(card) {
game.dem_pwr_hand.splice(find_card, 1);
}
game.power_struggle_discard.push(card)
- }
+ }
}
function remove_from_discard(card) {
@@ -3785,7 +3778,7 @@ function reset_power() {
delete game.raised_stakes_round
delete game.raised_stakes
delete game.raised_stakes_discard
- delete game.played_power_card
+ delete game.played_power_card
delete game.tactics_fails
delete game.view_opp_power_hand
@@ -3847,7 +3840,7 @@ const pluralize = (count, noun, suffix = 's') => {
if (noun.endsWith('y') && !/[aeiou]y$/.test(noun)) {
noun = noun.slice(0, -1) + 'ie'
}
- return `${count} ${noun}${suffix}`
+ return `${count} ${noun}${suffix}`
}
}
@@ -3905,7 +3898,6 @@ function log_msg_gap(msg) {
log_br()
}
-
function log_side() {
log_br()
if (game.active === DEM)
@@ -3954,7 +3946,7 @@ function pop_summary() {
log(msg.replace("£ SP", `${n} SP`));
}
}
- }
+ }
game.summary = []
}
@@ -3967,7 +3959,7 @@ function pop_summary_i() {
logi(msg.replace("£ SP", `${n} SP`));
}
}
- }
+ }
game.summary = []
}
@@ -4035,7 +4027,6 @@ function object_copy(original) {
}
}
-
/* =================== VM FUNCTIONS ========================== */
function goto_vm(proc) {
@@ -4115,7 +4106,7 @@ function vm_endif() {
function vm_goto_step(step) {
for (let i = game.vm.ip; i < CODE[game.vm.fp].length; i++) {
if (CODE[game.vm.fp][i][0] === step) {
- game.vm.ip = i;
+ game.vm.ip = i;
vm_exec();
return;
}
@@ -4124,7 +4115,6 @@ function vm_goto_step(step) {
console.log("ERROR: Target operation not found in the current procedure.");
}
-
function vm_goto(op, nop, dir, step) {
let balance = 1
while (balance > 0) {
@@ -4159,7 +4149,7 @@ function vm_prompt() {
}
function vm_return() {
- //Remove temporary vm variables
+ //Remove temporary vm variables
delete game.support_check_modifier
delete game.vm_max_infl
delete game.vm_influence_added
@@ -4168,16 +4158,16 @@ function vm_return() {
if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
reset_austria_hungary_border_reopened()
}
-
+
//Check if end event state is needed
if (game.is_pwr_struggle || game.state === 'vm_tst_6' || game.return_state === 'tiananmen_square_attempt_done') {
vm_end_event()
- }
+ }
//Check if auto-resolve opponent event
else if (is_auto_resolve(game.played_card) && ((cards[game.played_card].side === 'C' && game.active === DEM) || (cards[game.played_card].side === 'D' && game.active === COM) )) {
vm_end_event()
}
- else {
+ else {
game.state = 'vm_end_event'
}
}
@@ -4192,8 +4182,8 @@ function vm_end_event() {
game.state = game.return_state
}
else if (game.vm_infl_to_do) {
- game.state = 'resolve_opponent_event'}
- else {
+ game.state = 'resolve_opponent_event'}
+ else {
end_round()
}
}
@@ -4232,7 +4222,7 @@ function vm_valid_spaces_opponent () {
if (infl > 0) {
valid_spaces.push(space.space_id)
}
- } else {
+ } else {
let infl = game.demInfl[i]
if (infl > 0) {
valid_spaces.push(space.space_id)
@@ -4261,11 +4251,11 @@ function vm_valid_spaces_opponent_socio () {
for (let i = 0; i < spaces.length; i++) {
let space = spaces[i]
if (game.active === DEM) {
- let infl = game.comInfl[i]
+ let infl = game.comInfl[i]
if (infl > 0 && space.socio === vm_operand(1)) {
valid_spaces.push(space.space_id)
}
- } else {
+ } else {
let infl = game.demInfl[i]
if (infl > 0 && space.socio === vm_operand(1)) {
valid_spaces.push(space.space_id)
@@ -4278,7 +4268,7 @@ function vm_valid_spaces_opponent_socio () {
}
function vm_valid_spaces_country () {
- let country
+ let country
if (vm_operand(1)) {country = vm_operand(1)}
else {country = game.vm_active_country}
for (let space of spaces) {
@@ -4404,7 +4394,7 @@ function vm_take_control(space) {
}
game.valid_spaces = game.valid_spaces.filter(id => id !== space)
log(`Took control of %${space}`)
-}
+}
function vm_do_add_infl_free(space) {
push_undo()
@@ -4505,7 +4495,7 @@ function vm_remove_x_opp_infl() {
function vm_do_remove_x_infl(space) {
push_undo()
-
+
if (game.remove_opponent_infl) {
if (game.active === COM) {
if (game.demInfl[space] >= game.vm_available_ops) {
@@ -4595,7 +4585,7 @@ function vm_remove_all_infl() {
function vm_do_remove_all_infl(space) {
push_undo()
-
+
if (game.remove_opponent_infl === true) {
if (game.active === COM) {
log(`Removed all Democratic SP from %${space}`)
@@ -4615,7 +4605,7 @@ function vm_do_remove_all_infl(space) {
game.demInfl[space] = 0
}
check_tyrant()
- }
+ }
game.vm_available_ops --
game.valid_spaces = game.valid_spaces.filter(id => id !== space)
}
@@ -4650,7 +4640,7 @@ function vm_support_check_modified() {
}
function vm_switch_infl(id){
- push_undo()
+ push_undo()
game.demInfl[id] -= game.vm_available_ops
game.comInfl[id] += game.vm_available_ops
log(`Replaced ${pluralize(game.vm_available_ops,'SP')} in %${id}`)
@@ -4812,7 +4802,7 @@ function vm_dash_for_the_west() {
}
function vm_deutsche_marks() {
- let max_value = 1;
+ let max_value = 1;
for (let c of game.democrat_hand) {
if (cards[c].ops > max_value) {
max_value = cards[c].ops
@@ -4994,7 +4984,7 @@ function vm_honecker() {
for (let c of game.strategy_discard) {
if (scoring_cards.includes(c)) {
continue}
- else {
+ else {
game.valid_cards.push(c)
}
}
@@ -5014,7 +5004,7 @@ function vm_inflationary_currency_discard() {
for (let card of game.communist_hand){
if (get_card_ops(card) >= 3) {
game.valid_cards.push(card)
- }
+ }
}
} else {
for (let card of game.democrat_hand){
@@ -5061,7 +5051,7 @@ function vm_kremlin_coup() {
if (!game.revolutions[find_country_index(country)]) {
game.temp.push(country)
}
- })
+ })
game.playable_cards = game.playable_cards.filter(c => c !== C_MALTA_SUMMIT)
game.state = 'vm_kremlin_coup_choose_country'
}
@@ -5227,7 +5217,7 @@ function vm_reformer_rehabilitated () {
if (card === game.played_card) continue
if (card === C_COMMON_EUROPEAN_HOME) continue
if (scoring_cards.includes(card)) continue
-
+
game.valid_cards.push(card)
}
game.state = 'vm_play_event_from_discard'
@@ -5428,7 +5418,7 @@ function vm_the_tyrant_is_gone() {
function vm_the_tyrant_is_gone_prep() {
add_to_persistent_events(C_THE_TYRANT_IS_GONE)
logi(`After C${C_THE_CROWD_TURNS_AGAINST_CEAUSESCU} occurs, remove 4 Commuist SPs from the Romanian Elite space. The Democrats choose where the Ceausescus flee to`)
- vm_next()
+ vm_next()
}
function vm_tyrant_block() {
@@ -5499,7 +5489,7 @@ function vm_permanently_remove () {
}
if (cards[game.played_card].remove && !game.strategy_removed.includes(game.played_card)) {
permanently_remove(game.played_card)
- } /*This means the card that called the event being played is also removed if relevant. Think this makes sense */
+ } /*This means the card that called the event being played is also removed if relevant. Think this makes sense */
vm_next()
}
@@ -5645,7 +5635,7 @@ states.vm_add_infl = {
add_infl(space, 'vm_available_ops')
if (game.vm_available_ops === 0) {
game.valid_spaces = []
- do_log_summary()
+ do_log_summary()
game.vm_event_done = true
vm_next()
}
@@ -5680,13 +5670,13 @@ states.vm_add_infl_free = {
}
} else {
get_end_infl_prompt()
- }
+ }
},
space(space) {
vm_do_add_infl_free(space)
if (game.vm_available_ops === 0) {
game.valid_spaces = []
- do_log_summary()
+ do_log_summary()
game.vm_event_done = true
vm_next()
}
@@ -5722,7 +5712,7 @@ states.vm_add_x_infl = {
for (let space_id of game.valid_spaces) {
gen_action_space(space_id)
}
- }
+ }
},
space(space) {
push_undo()
@@ -5746,7 +5736,7 @@ states.vm_add_limited_infl = {
prompt () {
if (game.vm_available_ops > 0 && game.valid_spaces.length > 0) {
if (game.vm_max_infl === 1) {
- view.prompt = `${clean_name(cards[this_card()].name)}: add ${pluralize(game.vm_max_infl,'SP')} ${event_prompt()}.`
+ view.prompt = `${clean_name(cards[this_card()].name)}: add ${pluralize(game.vm_max_infl,'SP')} ${event_prompt()}.`
}
else {
view.prompt = `${clean_name(cards[this_card()].name)}: add ${pluralize(game.vm_available_ops,'SP')} to ${event_prompt()}.`
@@ -5754,7 +5744,7 @@ states.vm_add_limited_infl = {
for (let space_id of game.valid_spaces) {
gen_action_space(space_id);
}
- }
+ }
},
space(space) {
vm_do_add_limited_infl(space, game.vm_max_infl)
@@ -5770,12 +5760,12 @@ states.vm_add_limited_infl = {
states.vm_remove_infl = {
inactive: 'remove Support Points.',
prompt () {
- // Keep this so that there is an undo option in, e.g., Scare Tactics
+ // Keep this so that there is an undo option in, e.g., Scare Tactics
if (game.valid_spaces.length === 0 && game.vm_available_ops > 0) {
view.prompt = `${clean_name(cards[this_card()].name)}: no further SPs to remove.`
gen_action('done')
return
- }
+ }
if (game.vm_available_ops === 0 ) {
view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.`
gen_action('done')
@@ -5783,7 +5773,7 @@ states.vm_remove_infl = {
}
if (game.remove_opponent_infl) {
view.prompt = `${clean_name(cards[this_card()].name)}: remove ${pluralize(game.vm_available_ops, 'opponent SP')}${event_prompt()}.`
- }
+ }
else {
view.prompt = `${clean_name(cards[this_card()].name)}: remove ${pluralize(game.vm_available_ops,'SP')}${event_prompt()}.`
}
@@ -5813,7 +5803,6 @@ states.vm_remove_infl = {
}
}
-
states.vm_remove_x_infl = {
get inactive() {
return `resolve ${clean_name(cards[this_card()].name)}: remove SP from ${event_prompt()}.`
@@ -5823,12 +5812,12 @@ states.vm_remove_x_infl = {
view.prompt = `${clean_name(cards[this_card()].name)}: no SPs to remove.`
gen_action('done')
} else if (game.vm_available_ops > 0) {
-
+
view.prompt = `${clean_name(cards[this_card()].name)}: remove ${pluralize(game.vm_available_ops,'SP')} from ${event_prompt()}.`
for (let space_id of game.valid_spaces) {
gen_action_space(space_id);
}
- }
+ }
},
space(space) {
vm_do_remove_x_infl(space)
@@ -5855,7 +5844,7 @@ states.vm_remove_limited_infl = {
} else if (game.valid_spaces.length === 0 && game.vm_available_ops > 0) {
view.prompt = `${clean_name(cards[this_card()].name)}: no further SP to remove.`
gen_action('done')
- }
+ }
},
space(space) {
vm_do_remove_limited_infl(space, game.vm_max_infl)
@@ -5863,7 +5852,7 @@ states.vm_remove_limited_infl = {
game.vm_event_done = true
do_log_summary()
vm_next()
- }
+ }
},
done () {
game.vm_event_done = true
@@ -5882,8 +5871,8 @@ states.vm_remove_all_infl = {
view.prompt = `${clean_name(cards[this_card()].name)}: remove all SPs from ${event_prompt()}.`
for (let space_id of game.valid_spaces) {
gen_action_space(space_id);
- }
- }
+ }
+ }
},
space(space) {
vm_do_remove_all_infl(space)
@@ -5950,7 +5939,7 @@ states.vm_ceh_support_check_prep = {
prompt () {
if (game.vm_available_ops > 0) {
view.prompt = `Select a space. ${pluralize(game.vm_available_ops, 'support check')} remaining.`
-
+
for (let space_id of game.valid_spaces) {
gen_action_space(space_id)
}
@@ -5967,13 +5956,12 @@ states.vm_ceh_support_check_prep = {
game.state = 'vm_austria_hungary_border_reopened_check'
return
}
- }
+ }
}
game.state = 'vm_ceh_do_support_check'
},
}
-
states.vm_ceh_do_support_check = {
inactive: 'do support checks.',
prompt () {
@@ -6097,7 +6085,7 @@ states.vm_adamec = {
}
log('Adamec fails: 3 or more required')
permanently_remove(C_ADAMEC)
- vm_return()
+ vm_return()
}
}
@@ -6309,7 +6297,7 @@ states.vm_play_event_from_discard = {
gen_action('pass')
gen_action_card(card)
}
- }
+ }
},
card(card) {
push_undo()
@@ -6573,7 +6561,7 @@ states.vm_goodbye_lenin_ops = {
push_undo()
game.vm_available_ops = get_card_ops(this_card())
valid_spaces_infl()
-
+
// If ABHR - Set AHBR tracker to true
if (game.persistent_events.includes(58)) {
game.austria_hungary_border_reopened_tracker = true
@@ -6606,7 +6594,7 @@ states.vm_honecker = {
gen_action_card(card)
gen_action('pass')
}
- }
+ }
},
card(card) {
push_undo()
@@ -6658,31 +6646,31 @@ states.vm_inflationary_currency = {
log(`Chose ${country_name(game.vm_active_country)}`)
vm_next()
},
- poland() {
+ poland() {
push_undo()
game.vm_active_country = 'Poland'
log(`Chose ${country_name(game.vm_active_country)}`)
vm_next()
},
- czechoslovakia() {
+ czechoslovakia() {
push_undo()
game.vm_active_country = 'Czechoslovakia'
log(`Chose ${country_name(game.vm_active_country)}`)
vm_next()
},
- hungary() {
+ hungary() {
push_undo()
game.vm_active_country = 'Hungary'
log(`Chose ${country_name(game.vm_active_country)}`)
vm_next()
},
- romania() {
+ romania() {
push_undo()
game.vm_active_country = 'Romania'
log(`Chose ${country_name(game.vm_active_country)}`)
vm_next()
},
- bulgaria () {
+ bulgaria () {
push_undo()
game.vm_active_country = 'Bulgaria'
log(`Chose ${country_name(game.vm_active_country)}`)
@@ -6708,7 +6696,7 @@ states.vm_inflationary_currency_discard = {
for (let card of game.valid_cards) {
gen_action_card(card)
}
- }
+ }
},
card(card) {
push_undo()
@@ -6732,7 +6720,6 @@ states.vm_inflationary_currency_discard = {
},
}
-
states.vm_kiss_of_death = {
get inactive() {
return `resolve ${clean_name(cards[game.played_card].name)}.`
@@ -6815,35 +6802,35 @@ states.vm_kremlin_coup_choose_country = {
log(`${country_name(game.vm_active_country)}:`)
vm_kremlin_coup_elite()
},
- poland() {
+ poland() {
push_undo()
game.vm_active_country = 'Poland'
log(`${country_name(game.vm_active_country)}:`)
game.temp = game.temp.filter(country => country !== game.vm_active_country)
vm_kremlin_coup_elite()
},
- czechoslovakia() {
+ czechoslovakia() {
push_undo()
game.vm_active_country = 'Czechoslovakia'
log(`${country_name(game.vm_active_country)}:`)
game.temp = game.temp.filter(country => country !== game.vm_active_country)
vm_kremlin_coup_elite()
},
- hungary() {
+ hungary() {
push_undo()
game.vm_active_country = 'Hungary'
log(`${country_name(game.vm_active_country)}:`)
game.temp = game.temp.filter(country => country !== game.vm_active_country)
vm_kremlin_coup_elite()
},
- romania() {
+ romania() {
push_undo()
game.vm_active_country = 'Romania'
log(`${country_name(game.vm_active_country)}:`)
game.temp = game.temp.filter(country => country !== game.vm_active_country)
vm_kremlin_coup_elite()
},
- bulgaria () {
+ bulgaria () {
push_undo()
game.vm_active_country = 'Bulgaria'
log(`${country_name(game.vm_active_country)}:`)
@@ -6854,7 +6841,7 @@ states.vm_kremlin_coup_choose_country = {
game.temp = 0
vm_next()
}
-}
+}
states.vm_kremlin_coup_take_control = {
get inactive() {
@@ -6895,7 +6882,7 @@ states.vm_kremlin_coup_take_control = {
if (game.vm_active_country === 'Romania') {game.selected_space = S_BUCURESTI}
if (game.vm_active_country === 'Bulgaria') {game.selected_space = S_SOFIA}
game.state = 'vm_kremlin_coup_sc_prep'
- }
+ }
}
states.vm_kremlin_coup_sc_prep = {
@@ -7046,7 +7033,7 @@ states.vm_modrow = {
log(`Fail. More than ${dem_spaces} required`)
permanently_remove(C_MODROW)
vm_return()
- }
+ }
}
}
@@ -7122,7 +7109,7 @@ states.vm_nomenklatura = {
game.valid_spaces = []
for (let i = 0; i < spaces.length; i++) {
let space = spaces[i]
-
+
if (space.socio === 1 && game.demInfl[i] > 0) {
game.valid_spaces.push(space.space_id)
}
@@ -7153,9 +7140,9 @@ states.vm_nomenklatura_remove = {
if (game.valid_spaces.length === 0 ) {
view.prompt = 'Nomenklatura. No SPs to remove: pass.'
gen_action('pass')
- } else {
+ } else {
view.prompt = 'Nomenklatura: remove all Democratic SPs from Elite spaces.'
-
+
for (let space_id of game.valid_spaces) {
gen_action_space(space_id);
}
@@ -7201,7 +7188,7 @@ states.vm_samizdat = {
prompt() {
view.prompt = 'Samizdat: you may set aside a card from your hand and draw a replacement.'
for (let card of game.democrat_hand) {
- gen_action_card(card)
+ gen_action_card(card)
}
gen_action('pass')
},
@@ -7263,34 +7250,34 @@ states.vm_shock_therapy = {
game.vm_active_country = 'East_Germany'
log(`Chose ${country_name(game.vm_active_country)}`)
},
- poland() {
+ poland() {
push_undo()
game.vm_active_country = 'Poland'
log(`Chose ${country_name(game.vm_active_country)}`)
},
- czechoslovakia() {
+ czechoslovakia() {
push_undo()
game.vm_active_country = 'Czechoslovakia'
log(`Chose ${country_name(game.vm_active_country)}`)
},
- hungary() {
+ hungary() {
push_undo()
game.vm_active_country = 'Hungary'
log(`Chose ${country_name(game.vm_active_country)}`)
},
- romania() {
+ romania() {
push_undo()
game.vm_active_country = 'Romania'
log(`Chose ${country_name(game.vm_active_country)}`)
},
- bulgaria () {
+ bulgaria () {
push_undo()
game.vm_active_country = 'Bulgaria'
log(`Chose ${country_name(game.vm_active_country)}`)
},
roll() {
clear_undo()
- let roll = roll_d6()
+ let roll = roll_d6()
let worker_farmer = 0
for (let space of spaces) {
if (space && space.country === game.vm_active_country && check_com_control(space.space_id) && (space.socio === 3 || space.socio === 4)) {
@@ -7310,7 +7297,7 @@ states.vm_shock_therapy = {
} else {
log('C93 is unsuccessful. Required 3 or more')
permanently_remove(C_SHOCK_THERAPY)
- vm_return()
+ vm_return()
}
},
pass() {
@@ -7349,7 +7336,7 @@ states.vm_social_democratic_platform_adopted = {
log(`Selected ${country_name(game.vm_active_country)}`)
vm_next()
},
- czechoslovakia() {
+ czechoslovakia() {
push_undo()
game.vm_active_country = 'Czechoslovakia'
log(`Selected ${country_name(game.vm_active_country)}`)
@@ -7361,7 +7348,7 @@ states.vm_social_democratic_platform_adopted = {
log(`Selected ${country_name(game.vm_active_country)}`)
vm_next()
},
- romania() {
+ romania() {
push_undo()
game.vm_active_country = 'Romania'
log(`Selected ${country_name(game.vm_active_country)}`)
@@ -7375,7 +7362,7 @@ states.vm_social_democratic_platform_adopted = {
},
pass() {
log('Passed')
- vm_return()
+ vm_return()
}
}
@@ -7424,7 +7411,7 @@ states.vm_the_chinese_solution = {
}
vm_next()
},
- poland() {
+ poland() {
push_undo()
game.vm_active_country = 'Poland'
log(`Chose ${country_name(game.vm_active_country)}`)
@@ -7435,7 +7422,7 @@ states.vm_the_chinese_solution = {
}
vm_next()
},
- czechoslovakia() {
+ czechoslovakia() {
push_undo()
game.vm_active_country = 'Czechoslovakia'
log(`Chose ${country_name(game.vm_active_country)}`)
@@ -7446,7 +7433,7 @@ states.vm_the_chinese_solution = {
}
vm_next()
},
- hungary() {
+ hungary() {
push_undo()
game.vm_active_country = 'Hungary'
log(`Chose ${country_name(game.vm_active_country)}`)
@@ -7457,7 +7444,7 @@ states.vm_the_chinese_solution = {
}
vm_next()
},
- romania() {
+ romania() {
push_undo()
game.vm_active_country = 'Romania'
log(`Chose ${country_name(game.vm_active_country)}`)
@@ -7468,7 +7455,7 @@ states.vm_the_chinese_solution = {
}
vm_next()
},
- bulgaria () {
+ bulgaria () {
push_undo()
game.vm_active_country = 'Bulgaria'
log(`Chose ${country_name(game.vm_active_country)}`)
@@ -7529,7 +7516,7 @@ states.vm_the_wall_must_go = {
log_h3(`Round ${attempt+1}`)
}
- let roll = roll_d6()
+ let roll = roll_d6()
log(`Roll: D${roll}`)
if (game.active === DEM) {
let controlled_spaces = spaces.filter(space => space && space.country === 'East_Germany' && check_dem_control(space.space_id)).length
@@ -7547,7 +7534,7 @@ states.vm_the_wall_must_go = {
roll += controlled_spaces
}
game.the_wall_must_go['com_roll'] = roll
-
+
}
if (game.the_wall_must_go['dem_roll'] > 0 && game.the_wall_must_go['com_roll'] > 0) {
if (game.the_wall_must_go['dem_roll'] > game.the_wall_must_go['com_roll'] ) {
@@ -7575,7 +7562,7 @@ states.vm_the_wall_must_go = {
if (game.the_wall_must_go['dem_roll'] === 0 || game.the_wall_must_go['com_roll'] === 0) {
next_player()
} else {
- game.the_wall_must_go['dem_roll'] = 0
+ game.the_wall_must_go['dem_roll'] = 0
game.the_wall_must_go['com_roll'] = 0
}
},
@@ -7638,7 +7625,7 @@ states.vm_we_are_the_people_remove = {
remove_infl(space, 'vm_available_ops')
if (game.vm_influence_added[S_LUTHERAN_CHURCH] === 4) {
finish_we_are_the_people()
- }
+ }
},
done() {
push_undo()
@@ -7708,7 +7695,7 @@ states.vm_workers_revolt_finish = {
},
roll() {
clear_undo()
- let roll = roll_d6()
+ let roll = roll_d6()
log(`Roll: D${roll}`)
let adj = count_adj(game.selected_space)
if (game.active === DEM) {
@@ -7734,7 +7721,7 @@ states.vm_tst_3_prep = {
prompt() {
view.prompt = 'Tiananmen Square Track award: draw 3 cards.'
gen_action('draw')
- },
+ },
draw() {
if (game.active === DEM) {
game.temp = game.democrat_hand.length
@@ -7780,7 +7767,7 @@ states.vm_tst_4 = {
return
}
view.prompt = `Tiananmen Square Track award: remove ${pluralize(game.vm_available_ops,'SP')}.`
-
+
for (let space_id of game.valid_spaces) {
gen_action_space(space_id);
}
@@ -7789,7 +7776,7 @@ states.vm_tst_4 = {
remove_infl(space, 'vm_available_ops')
if (game.vm_available_ops === 0) {
do_log_summary()
- vm_next()
+ vm_next()
}
},
done() {
@@ -7838,7 +7825,7 @@ states.vm_tst_6_sc = {
states.vm_tst_8 = {
inactive: 'use Tiananmen Square Track award.',
prompt() {
- if (game.vm_event_to_do && game.vm_infl_to_do) {
+ if (game.vm_event_to_do && game.vm_infl_to_do) {
view.prompt = 'Choose whether to play for event or operations first.'
gen_action('event')
gen_action('ops')
@@ -7916,17 +7903,17 @@ states.vm_tst_8_ops = {
states.vm_scare_tactics = {
inactive: 'remove a Support Point.',
- prompt () {
+ prompt () {
if (game.valid_spaces.length === 0 && game.vm_available_ops > 0) {
view.prompt = `${clean_name(cards[this_card()].name)}: no SPs to remove.`
gen_action('done')
return
- }
+ }
if (game.vm_available_ops === 0 ) {
view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.`
gen_action('done')
return
- }
+ }
view.prompt = `${clean_name(cards[this_card()].name)}: remove ${pluralize(game.vm_available_ops, 'opponent SP')}${event_prompt()}.`
for (let space_id of game.valid_spaces) {
gen_action_space(space_id);
@@ -7946,7 +7933,7 @@ states.vm_support_surges_1 = {
inactive: 'draw cards.',
prompt() {
view.prompt = 'Support Surges: draw a card.'
- gen_action('draw')
+ gen_action('draw')
},
draw() {
if (game.active === DEM) {
@@ -7962,7 +7949,7 @@ states.vm_support_surges_1 = {
states.vm_support_surges_2 = {
inactive: 'draw cards.',
- prompt() {
+ prompt() {
if (wildcards.includes(game.temp)) {
view.prompt = `Support Surges: you drew ${power_cards[game.temp].name}. Draw a second card.`
}
@@ -7974,7 +7961,7 @@ states.vm_support_surges_2 = {
} else {
view.prompt = `Support Surges: you drew a ${power_cards[game.temp].name} ${power_cards[game.temp].value}. Draw a second card.`
}
- gen_action('draw')
+ gen_action('draw')
},
draw() {
if (game.active === DEM) {
@@ -8002,7 +7989,7 @@ states.vm_support_surges_3 = {
} else {
view.prompt = `Support Surges: you drew a ${power_cards[game.temp].name} ${power_cards[game.temp].value}. Done.`
}
- gen_action('done')
+ gen_action('done')
},
done() {
game.phase = 0