summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2025-01-11 17:33:04 +0000
committeriainp5 <iain.pearce.ip@gmail.com>2025-01-11 17:33:04 +0000
commit0f72001ae4f2c9bfc3d72a1e6d17a9830c55facb (patch)
treefa90492c521d4dbf143e87525eeace9df8711264 /rules.js
parent91a3955e10f741fee5b10a69539a4d57f9e0af9d (diff)
download1989-dawn-of-freedom-0f72001ae4f2c9bfc3d72a1e6d17a9830c55facb.tar.gz
Tidy up code
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js560
1 files changed, 94 insertions, 466 deletions
diff --git a/rules.js b/rules.js
index 572c0ca..bf3fa04 100644
--- a/rules.js
+++ b/rules.js
@@ -769,8 +769,7 @@ states.play_card = {
game.state = 'support_check_prep'
valid_spaces_sc()
},
- tst_7() {
- /* Cancel opponent event */
+ tst_7() { /* Cancel opponent event */
push_undo()
log_ops_banner()
check_ligachev_non_event()
@@ -779,8 +778,7 @@ states.play_card = {
game.vm_infl_to_do = true
game.state = 'resolve_opponent_event'
},
- tst_8() {
- /* Play card for ops and event */
+ tst_8() { /* Play card for ops and event */
push_undo()
log_tst_8_banner()
game.vm_event_to_do = true
@@ -820,8 +818,6 @@ states.resolve_opponent_event = {
},
influence() {
push_undo()
- //check_ligachev_non_event()
- //log_gap(`Played C${game.played_card} to place SPs`)
log_gap('Placed SP:')
// If ABHR - Set AHBR tracker to true
if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
@@ -832,8 +828,6 @@ states.resolve_opponent_event = {
},
support_check() {
push_undo()
- //check_ligachev_non_event()
- //log_gap(`Played C${game.played_card} for Support Checks`)
log_gap('Support Checks:')
game.available_ops = 2
game.state = 'support_check_prep'
@@ -1056,8 +1050,8 @@ states.support_check_prep = {
},
done() {
push_undo()
- if (game.is_pwr_struggle) {
- /* Crowd Turns Against Ceausescu should be the only time you end up here during a power struggle */
+ // Check if in a Power Struggle after Crowd Turns Against Ceausescu
+ if (game.is_pwr_struggle) {
if (game.return !== game.active) {
change_player()
}
@@ -1254,7 +1248,6 @@ states.vm_the_crowd_turns_against_ceausescu = {
game.valid_spaces = game.valid_spaces.filter(n => spaces[n].country === 'Romania')
log('Placed SP:')
game.state = 'the_crowd_turns_against_ceausescu_infl'
- /* Send this to add_infl? Add check at end of add_infl similar to valid_spaces? */
},
support_check() {
push_undo()
@@ -1621,11 +1614,10 @@ states.support_loss = {
log(`${game.active} removed SP:`)
},
space(space) {
- game.remove_opponent_infl = false /* Don't know why this is needed... */
+ game.remove_opponent_infl = false
remove_infl(space, 'available_ops')
},
done() {
- // TODO: log "None" here?
summary_flush()
change_player()
game.phase = 0
@@ -1671,21 +1663,17 @@ states.vp_roll = {
if (game.active === DEM) {
change_player()
}
- //log_h5('Power')
game.state = 'choose_power'
}
},
take() {
- //push_undo()
let scoring_card = scoring_cards[countries.indexOf(game.pwr_struggle_in)]
permanently_remove(scoring_card)
- log_gap('Power:')
- logi("The Democrat takes Power!")
+ log_gap("The Democrat takes Power!")
take_power(game.pwr_struggle_in)
game.phase = 2
},
scoring() {
- //push_undo()
score_country(game.pwr_struggle_in)
resolve_tyrant()
},
@@ -1710,8 +1698,7 @@ states.choose_power = {
},
surrender() {
push_undo()
- log_gap('Power:')
- logi(`Communist voluntarily surrenders Power.`)
+ log_gap(`Communist voluntarily surrenders Power.`)
take_power(game.pwr_struggle_in)
permanently_remove(game.played_card)
game.phase = 1
@@ -1797,7 +1784,6 @@ states.end_turn_4_5_4 = {
} else if (game.persistent_events.includes(C_NEW_YEARS_EVE_PARTY)) {
log_h1(`New Year's Eve Party`)
game.vm_event = C_NEW_YEARS_EVE_PARTY
- // Check if the Communist receives VP from The Tyrant is Gone
if (game.the_tyrant_is_gone && game.the_tyrant_is_gone > 0) {
game.vp -= 2
log(`Communist receives 2 VP from C` + C_THE_TYRANT_IS_GONE + `.`)
@@ -1810,8 +1796,6 @@ states.end_turn_4_5_4 = {
} else if (game.turn === 10) {
clear_undo()
log_h2('Final Scoring')
-
- // Check if the Communist receives VP from The Tyrant is Gone
if (game.the_tyrant_is_gone && game.the_tyrant_is_gone > 0) {
game.vp -= 2
log(`Communist receives 2 VP from C`+ C_THE_TYRANT_IS_GONE + '.')
@@ -1830,7 +1814,6 @@ states.final_scoring_held = {
gen_action('bonus')
},
bonus() {
- //push_undo()
const held_countries = game.revolutions.filter(value => value === false).length
let vp_gain = 4 * held_countries
log(`Communist holds power in ${pluralize(held_countries, 'country', 's')}: -${vp_gain} VP.`)
@@ -2233,7 +2216,6 @@ states.stasi_play_ceh = {
log(`Played C${game.played_card} with C${C_COMMON_EUROPEAN_HOME}.`)
check_ligachev_non_event()
log('Placed SP:')
- // If ABHR - Set AHBR tracker to true
if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
game.austria_hungary_border_reopened_tracker = true
}
@@ -2257,7 +2239,6 @@ states.stasi_play_ceh = {
function add_infl(space, ops) {
push_undo()
- // If AHBR - check AHBR conditions
if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
if (spaces[space].country !== 'East_Germany') {
game.austria_hungary_border_reopened_tracker = false
@@ -2290,13 +2271,11 @@ function add_infl(space, ops) {
game[ops]--
}
- // Update influence values
if (game.active === COM) {
game.comInfl[space]++
} else {
game.demInfl[space]++
}
-
summary_influence(space)
check_tyrant()
@@ -2316,10 +2295,7 @@ function add_infl(space, ops) {
game.valid_spaces = game.valid_spaces.filter(n => spaces[n].country === 'East_Germany')
}
- // If only 1 IP remaining, may not place in opponent controlled spaces
-
- // Check for Genscher & Austria Hungary Border Reopened
-
+ // If only 1 IP remaining, may not place in opponent controlled spaces unless Genscher/AHBR
if (game[ops] === 1) {
if (game.active === DEM) {
if (game.persistent_events.includes(C_GENSCHER) || (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED) && game.austria_hungary_border_reopened_tracker)) {
@@ -2331,8 +2307,6 @@ function add_infl(space, ops) {
game.valid_spaces = game.valid_spaces.filter(n => !check_opp_control(n))
}
}
-
- // Clear valid spaces if no IP remaining.
if (game[ops] <= 0) {
game.valid_spaces = []
}
@@ -2340,7 +2314,6 @@ function add_infl(space, ops) {
function remove_infl(space, ops) {
push_undo()
-
if (game.remove_opponent_infl === true) {
if (game.active === COM) {
game.demInfl[space]--
@@ -2353,7 +2326,6 @@ function remove_infl(space, ops) {
game.valid_spaces = game.valid_spaces.filter(id => id !== space)
}
}
-
} else {
if (game.active === COM) {
game.comInfl[space]--
@@ -2383,22 +2355,16 @@ function do_sc(space) {
let tear_gas_start = game.persistent_events.includes(C_TEAR_GAS)
let the_wall_start = game.persistent_events.includes(C_THE_WALL)
let roll = roll_d6()
-
- // Continue with Support Check Logic
log(`%${space}: D${roll}`)
- // Check for The Wall
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}`)
- // Check for the Crowd Turns Against Ceausescu
+ // Get SC ops
if (game.is_pwr_struggle) {
roll += game.vm_available_ops
logi(`+${game.vm_available_ops} Ceausescu`)
- }
-
- // Check if in Tiananmen Square Track Award
- else if (game.state === 'vm_tst_6_sc') {
+ } else if (game.state === 'vm_tst_6_sc') {
roll += get_tst_6_ops()
roll += 2
logi('+2 TST award')
@@ -2407,13 +2373,11 @@ function do_sc(space) {
roll += card_ops
logi(`+${card_ops} card ops`)
}
-
+ // Get support check modifiers
if (game.support_check_modifier > 0) {
roll += game.support_check_modifier
logi(`+${game.support_check_modifier} event`)
}
-
- // Events which modify SC rolls
if (game.active === COM && game.persistent_events.includes(C_TEAR_GAS) && spaces[space].socio === SOCIO_STUDENT) {
roll ++
logi(`+1 C${C_TEAR_GAS}`)
@@ -2456,50 +2420,36 @@ function do_sc(space) {
logi(`+1 C${C_AUSTRIA_HUNGARY_BORDER_REOPENED}`)
}
- // Continue with logic - check for adjacency
-
- // Events which affect adjacency - The Wall
-
+ // Check for adjacency
const adj = count_adj(space)
if (game.active === COM && game.persistent_events.includes(C_THE_WALL) && spaces[space].country === 'East_Germany') {
roll += adj.com_adj
- if (adj.com_adj > 0) {
+ if (adj.com_adj > 0)
logi(`+${adj.com_adj} adjacency`)
- }
permanently_remove(C_THE_WALL)
-
} else {
- // Standard adjacency
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) {
+ if (adj.dem_adj > 0)
logi(`+${adj.dem_adj} adjacency`)
- }
- if (adj.com_adj > 0) {
+ if (adj.com_adj > 0)
logi(`-${adj.com_adj} opponent adjacency`)
- }
} else {
roll += adj.com_adj
roll -= adj.dem_adj
- if (adj.com_adj > 0) {
+ if (adj.com_adj > 0)
logi(`+${adj.com_adj} adjacency`)
- }
- if (adj.dem_adj > 0) {
+ if (adj.dem_adj > 0)
logi(`-${adj.dem_adj} opponent adjacency`)
- }
}
}
}
-
- // Support Check calcs
- //logi('Result:')
- //logi(`Modified roll: ${roll}`)
+ //Stability and final support check calcs
const stability = spaces[space].stability
logi(`-${stability*2} stability (x2)`)
const change_infl = Math.max(0, roll - stability*2)
- //logi('Change SP %' + space + ':')
if (change_infl > 0) {
if (game.active === DEM) {
if (change_infl > game.comInfl[space]) {
@@ -2526,7 +2476,6 @@ function do_sc(space) {
}
log(change_infl + ' SP for ' + game.active + '.')
check_tyrant_sc()
-
} else {
log('No change SP.')
}
@@ -2543,8 +2492,6 @@ function do_sc(space) {
log('+1 VP from C' + C_ECO_GLASNOST)
game.vp++
}
-
- // Check if Tear Gas or The Wall used
let tear_gas_end = game.persistent_events.includes(C_TEAR_GAS)
let the_wall_end = game.persistent_events.includes(C_THE_WALL)
if (tear_gas_start && !tear_gas_end) {
@@ -2553,7 +2500,6 @@ function do_sc(space) {
if (the_wall_start && !the_wall_end) {
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) {
@@ -2566,57 +2512,43 @@ function do_sc(space) {
function valid_spaces_setup() {
for (let i = 0; i < spaces.length; i++) {
let space = spaces[i]
-
if (game.active === COM) {
let infl = game.demInfl[i]
-
- if (infl === 0) {
+ if (infl === 0)
game.valid_spaces.push(space.space_id)
- }
} else {
let infl = game.comInfl[i]
- if (infl === 0) {
+ if (infl === 0)
game.valid_spaces.push(space.space_id)
- }
}
}
}
function valid_spaces_sc() {
let valid_spaces_set = new Set()
-
for (let i = 0; i < spaces.length; i++) {
let space = spaces[i]
-
if (game.active === DEM) {
let infl = game.comInfl[i]
- if (infl !== 0) {
+ 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) {
+ 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) {
+ 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
- }
-
valid_spaces_set.add(space.space_id)
}
}
}
game.valid_spaces = Array.from(valid_spaces_set)
-
- // Check for the Crown Turns Against Ceausescu
if (
game.is_pwr_struggle &&
game.pwr_struggle_in === 'Romania' &&
@@ -2633,14 +2565,12 @@ function valid_spaces_support_loss() {
let space = spaces[i]
if (game.active === DEM) {
let infl = game.demInfl[i]
- if (infl > 0 && space.country === game.pwr_struggle_in) {
+ if (infl > 0 && space.country === game.pwr_struggle_in)
valid_spaces_set.add(space.space_id)
- }
} else {
let infl = game.comInfl[i]
- if (infl > 0 && space.country === game.pwr_struggle_in) {
+ if (infl > 0 && space.country === game.pwr_struggle_in)
valid_spaces_set.add(space.space_id)
- }
}
}
game.valid_spaces = Array.from(valid_spaces_set)
@@ -2648,15 +2578,12 @@ 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]
let player_influence = game.active === COM ? game.comInfl[i] : game.demInfl[i]
-
- // If the piece has the player's influence, add it and its adjacent spaces to the set
if (player_influence > 0) {
if (
ops > 1 ||
@@ -2669,20 +2596,14 @@ function valid_spaces_infl() {
for (let adj_space_id of adjacent_spaces) {
if (adj_space_id >= 0) {
const adj_piece = spaces[adj_space_id]
-
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) {
+ } else if (ops >= 2 || !opponent_control) {
valid_spaces_set.add(adj_piece.space_id)
}
}
@@ -2699,19 +2620,14 @@ function valid_cards(player_hand, presence) {
for (let c of player_hand) {
let card = power_cards[c]
- // Never add tactics fails or cards of its suit
- if (c === PC_TACTIC_FAILS) {
+ if (c === PC_TACTIC_FAILS)
continue
- }
- if (card.name === game.tactics_fails) {
+ if (card.name === game.tactics_fails)
continue
- }
-
- if (card.socio === 0) {
+ if (card.socio === 0)
valid_cards_set.add(c)
- } else if (leaders.includes(card.socio) && presence[card.socio]) {
+ else if (leaders.includes(card.socio) && presence[card.socio])
valid_cards_set.add(c)
- }
}
} else if (game.phase === 1) {
for (let c of player_hand) {
@@ -2746,12 +2662,10 @@ function count_adj(space_id) {
let adjacent_spaces = get_adjusted_adjacency(space_id)
for (let adj_space_id of adjacent_spaces) {
- if (check_dem_control(adj_space_id)) {
+ if (check_dem_control(adj_space_id))
dem_adj++
- }
- if (check_com_control(adj_space_id)) {
+ if (check_com_control(adj_space_id))
com_adj++
- }
}
return {dem_adj, com_adj}
}
@@ -2795,12 +2709,9 @@ function check_com_control(space_id) {
function do_tst_attempt() {
let roll = roll_d6()
logi(`D${roll}`)
-
roll += game.available_ops
logi(`+${game.available_ops} card Ops`)
- // TIANANMEN SQUARE MODIFIERS
-
if ((game.active === DEM && game.dem_tst_attempted === 1) || (game.active === COM && game.com_tst_attempted === 1)) {
roll++
logi('+1 previous TST attempts')
@@ -2824,8 +2735,6 @@ function do_tst_attempt() {
roll ++
logi('+1 C' + C_LI_PENG)
}
-
- // TIANANMEN SQUARE ATTEMPT
game.return = game.round_player
if (game.active === DEM) {
@@ -2842,7 +2751,6 @@ function do_tst_attempt() {
if (game.dem_tst_position === 8 && game.com_tst_position < 8) {
game.tst_8 = false
}
-
// Check if they have caught up to box 7 or 8
if (game.dem_tst_position >= 7 && game.com_tst_position >= 7) {
delete game.tst_7
@@ -2850,7 +2758,6 @@ function do_tst_attempt() {
if (game.dem_tst_position >= 8 && game.com_tst_position >= 8) {
delete game.tst_8
}
-
// Check if TST events occur
if (game.dem_tst_position === 3 && game.com_tst_position < 3) {
game.vm_event = 203
@@ -2881,7 +2788,6 @@ function do_tst_attempt() {
if (game.com_tst_position === 8 && game.dem_tst_position < 8) {
game.tst_8 = false
}
-
// Check if they have caught up to box 7 or 8
if (game.com_tst_position >= 7 && game.dem_tst_position >= 7) {
delete game.tst_7
@@ -2889,7 +2795,6 @@ function do_tst_attempt() {
if (game.com_tst_position >= 8 && game.dem_tst_position >= 8) {
delete game.tst_8
}
-
// Check if TST events occur
if (game.com_tst_position === 3 && game.dem_tst_position < 3) {
game.vm_event = 203
@@ -2906,7 +2811,6 @@ function do_tst_attempt() {
}
function check_presence(country) {
-
let dem_spaces = 0
let com_spaces = 0
let dem_battlegrounds = 0
@@ -2917,37 +2821,27 @@ function check_presence(country) {
for (let i = 0; i < spaces.length; i++) {
let space = spaces[i]
if (space.country === country) {
-
if (check_dem_control(i)) {
dem_spaces++
- if (space.battleground === 1) {
+ if (space.battleground === 1)
dem_battlegrounds++
- }
- if (leaders.includes(space.socio)) {
+ if (leaders.includes(space.socio))
dem_leaders[space.socio] = true
- }
}
if (check_com_control(i)) {
com_spaces++
- if (space.battleground === 1) {
+ if (space.battleground === 1)
com_battlegrounds++
- }
- if (leaders.includes(space.socio)) {
+ if (leaders.includes(space.socio))
com_leaders[space.socio] = true
- }
}
}
}
-
- // 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,
@@ -2982,8 +2876,8 @@ function take_power(country) {
function retain_power(country) {
game.times_held[find_country_index(country)]++
let vp_gain = get_value(country) * game.times_held[find_country_index(country)]
- //log(`Communist retains power.`)
- log_gap(`Power: -${vp_gain} VP (retains power)`)
+ log_gap(`Communist retains power:`)
+ logi(`-${vp_gain} VP`)
game.vp_retain = -vp_gain
game.vp -= vp_gain
}
@@ -2993,8 +2887,6 @@ function score_country(country) {
log_h5(`${country}`)
else
log_h5(`Scoring`)
-
- // Get scoring values
let value_presence = get_value(country)
let value_domination = value_presence * 2
let value_control
@@ -3003,12 +2895,10 @@ function score_country(country) {
} else {
value_control = 4
}
-
let dem_vp = 0
let com_vp = 0
let presence = check_presence(country)
- //Democrat scoring
log('Democrat:')
if (presence.dem_control) {
logi(`Control, ${pluralize(presence.dem_battlegrounds,' battleground')}`)
@@ -3032,7 +2922,6 @@ function score_country(country) {
}
logi(`+${dem_vp} VP`)
- //Communist scoring
log_gap('Communist:')
if (presence.com_control) {
logi(`Control, ${pluralize(presence.com_battlegrounds,' battleground')}`)
@@ -3054,128 +2943,12 @@ function score_country(country) {
logi('No presence')
}
logi(`${com_vp} VP`)
-
-/*
- // If one side has domination or control
- if (presence.dem_control || presence.dem_domination) {
- log(`Democrat:`)
- if (presence.dem_control) {
- logi(`${value_control} VP for Control`)
- dem_vp += value_control
- } else {
- logi(`${value_domination} VP for Domination`)
- dem_vp += value_domination
- }
- logi(`${presence.dem_battlegrounds} VP for Battlegrounds`)
- dem_vp += presence.dem_battlegrounds
-
- log('Communist:')
- if (presence.com_spaces > 0) {
- logi(`${value_presence} VP for Presence`)
- com_vp -= value_presence
- if (presence.com_battlegrounds > 0) {
- logi(`${presence.com_battlegrounds} VP for Battlegrounds`)
- com_vp -= presence.com_battlegrounds
- }
- } else {
- logi('0 VP')
- }
- } else if (presence.com_control || presence.com_domination) {
- log('Communist:')
- if (presence.com_control) {
- logi(`${value_control} VP for Control`)
- com_vp -= value_control
- } else {
- logi(`${value_domination} VP for Domination`)
- com_vp -= value_domination
- }
- logi(`${presence.com_battlegrounds} VP for Battlegrounds`)
- com_vp -= presence.com_battlegrounds
-
- log('Democrat:')
- if (presence.dem_spaces > 0) {
- logi(`${value_presence} VP for Presence`)
- dem_vp += value_presence
- if (presence.dem_battlegrounds > 0) {
- logi(`${presence.dem_battlegrounds} VP for Battlegrounds`)
- dem_vp += presence.dem_battlegrounds
- }
- } else {
- logi('0 VP')
- }
- }
-
- // Otherwise, presence and battlegrounds
- else {
- log(`Communist:`)
- if (presence.com_spaces > 0) {
- logi(`${value_presence} VP for Presence`)
- com_vp -= value_presence
- if (presence.com_battlegrounds > 0) {
- logi(`${presence.com_battlegrounds} VP for Battlegrounds`)
- com_vp -= presence.com_battlegrounds
- }
- } else {
- logi('0 VP')
- }
- log('Democrat:')
- if (presence.dem_spaces > 0) {
- logi(`${value_presence} VP for Presence`)
- dem_vp += value_presence
- if (presence.dem_battlegrounds > 0) {
- logi(`${presence.dem_battlegrounds} VP for Battlegrounds`)
- dem_vp += presence.dem_battlegrounds
- }
- } else {
- logi('0 VP')
- }
- }
-*/
- // Calculate change VP
-
- let change_vp = dem_vp + com_vp
- game.vp += change_vp
- /*
- log_gap('Net VP:')
- if (change_vp > 0) {
- logi(`+${change_vp} VP`)
- } else {
- logi(`${change_vp} VP`)
- }
- // Scoring Summary
- log_h4(`Power Struggle ${country}: Summary`)
- if (game.vp_roll >= 0)
- log_gap('+' + game.vp_roll + ' VP from VP roll')
- else
- log_gap(game.vp_roll)
- if (game.vp_retain)
- log(game.vp_retain + ' VP from holding power')
- if (change_vp > 0)
- log('+' + change_vp + ' VP from country scoring')
- else
- log(change_vp + ' VP from country scoring')
- let total_vp
- if (game.vp_retain)
- total_vp = game.vp_roll + game.vp_retain + change_vp
- else
- total_vp = game.vp_roll + change_vp
- log_h5('Total:')
- if (total_vp > 0)
- logi('+' + total_vp + ' VP' )
- else
- logi('' + total_vp + ' VP' )
-
- if (game.vp > 0)
- log_gap('Score is +' + game.vp + ' VP.')
- else
- log_gap('Score is ' + game.vp + ' VP.')
- */
-
+ game.vp += dem_vp + com_vp
if (game.state === 'final_scoring') {
if (game.vp > 0)
log_gap(`Score is +${game.vp} VP`)
else
- log_gap(`Score is +${game.vp} VP`)
+ log_gap(`Score is ${game.vp} VP`)
}
}
@@ -3212,8 +2985,6 @@ function get_aftermath_roll(what) {
petition_win = 2
}
let modified_roll = roll + game.raised_stakes + rally_win - petition_win
-
- // Special check for Yakovlev Counsels Gobachev. Applies only if Democrat wins, so only if Com is doing support loss and if Dem is doing VP roll
if (game.state === 'support_loss') {
if (game.active === COM && game.persistent_events.includes(C_YAKOVLEV_COUNSELS_GORBACHEV)) {
logi(`+1 C${C_YAKOVLEV_COUNSELS_GORBACHEV}`)
@@ -3230,7 +3001,6 @@ function get_aftermath_roll(what) {
} else if (modified_roll > 7) {
modified_roll = 7
}
-
if (game.raised_stakes !== 0) {
logi(`+${game.raised_stakes} Raising the Stakes`)
}
@@ -3620,12 +3390,9 @@ function is_auto_resolve(card) {
}
function event_is_playable(card) {
- // Reformer never playable here
if (card === C_REFORMER_REHABILITATED) {
return false
- }
- // Check for Common European Home
- else if (card === C_COMMON_EUROPEAN_HOME) {
+ } else if (card === C_COMMON_EUROPEAN_HOME) {
if (game.active === DEM) {
if (game.stasi_card === C_COMMON_EUROPEAN_HOME) {
return false
@@ -3638,16 +3405,11 @@ function event_is_playable(card) {
return true
}
}
- }
- // Check for Gorbachev Charms the West after Breakaway Baltic Republics
- else if (card === C_GORBACHEV_CHARMS_THE_WEST && !game.playable_cards.includes(C_GORBACHEV_CHARMS_THE_WEST)) {
+ } else if (card === C_GORBACHEV_CHARMS_THE_WEST && !game.playable_cards.includes(C_GORBACHEV_CHARMS_THE_WEST)) {
return false
- } //Democrat must have cards to set aside to play Samizdat
- else if (card === C_SAMIZDAT && game.democrat_hand.length === 0) {
+ } else if (card === C_SAMIZDAT && game.democrat_hand.length === 0) {
return false
- }
- // Then check normally
- else if (game.playable_cards.includes(card)) {
+ } else if (game.playable_cards.includes(card)) {
return true
} else if (cards[card].playable) {
return true
@@ -3677,7 +3439,6 @@ function get_card_ops(card) {
}
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)
@@ -3690,7 +3451,6 @@ function get_card_ops(card) {
}
ops ++
}
-
if (game.active === DEM && game.prudence && game.prudence.DEM !== 0) {
if (
game.state === 'play_card' ||
@@ -3705,12 +3465,10 @@ function get_card_ops(card) {
}
}
ops += game.prudence.DEM
-
if (ops < 1) {
ops = 1
}
}
-
if (game.active === COM && game.prudence && game.prudence.COM < 0) {
if (
game.state === 'play_card' ||
@@ -3751,7 +3509,6 @@ function get_tst_6_ops() {
ops = -1
}
}
-
if (game.active === COM && game.prudence && game.prudence.COM < 0) {
if (ops > 0) {
logi(`${pluralize(game.prudence.COM,'Op')} C${C_PRUDENCE}.`)
@@ -3767,7 +3524,6 @@ function get_tst_6_ops() {
}
function finish_play_card() {
- // Check if Common European Home played for influence
if (game.played_card === C_COMMON_EUROPEAN_HOME) {
if (game.active === DEM) {
game.vp --
@@ -3780,8 +3536,6 @@ function finish_play_card() {
return
}
}
-
- // Check if card is opponent card with event that needs to be resolved
if (cards[game.played_card].playable || game.playable_cards.includes(game.played_card)) {
if (
(game.active === DEM && cards[game.played_card].side === 'C') ||
@@ -3837,17 +3591,13 @@ function finish_we_are_the_people() {
// =========== MOVING THROUGH TURNS ============
function end_round() {
- // Check if the game is over!
if (game.state === 'game_over') {
return
}
- // Check if Ceausescu has been played and if so check end round condition
if (game.persistent_events.includes(C_CEAUSESCU)) {
if (check_ceausescu())
return
}
-
- // Reset
delete game.played_card
delete game.temp
delete game.vm_event
@@ -3865,6 +3615,7 @@ function end_round() {
game.valid_spaces = []
delete game.genscher_logged
reset_austria_hungary_border_reopened()
+ check_reformer()
// Check for duplicate card entries
let card_check
@@ -3877,19 +3628,15 @@ function end_round() {
function check_duplicates(array) {
return new Set(array).size !== array.length
}
-
function find_duplicates(array) {
const duplicates = array.filter((item, index) => array.indexOf(item) !== index)
return [...new Set(duplicates)]
}
-
card_check = card_check.sort((a, b) => a - b)
-
if (check_duplicates(card_check)) {
const duplicates = find_duplicates(card_check)
throw new Error(`Duplicate cards detected: ${duplicates.join(', ')}`)
}
-
if (game.turn <= 3) {
if (card_check.length !== 40) {
throw new Error(`Wrong number of cards: ${card_check.length}`)
@@ -3901,10 +3648,7 @@ function end_round() {
} else if (card_check.length !== 110) {
throw new Error(`Wrong number of cards: ${card_check.length}`)
}
-
- // Check if the Reformer is playable
- check_reformer()
-
+
// Check if last round and if so resolve end turn events
if (game.round_player === DEM && game.round === 7) {
if (game.persistent_events.includes(C_HONECKER)) {
@@ -3939,15 +3683,12 @@ function end_round() {
}
// Resolve end action round
- // Stasi check
if (game.round_player === COM && game.persistent_events.includes(C_STASI)) {
- // If in Honecker, turn ends
if (game.round === 8) {
clear_undo()
game.state = 'end_turn_4_5_4'
return
}
- // Otherwise go to Stasi
game.round_player = DEM
if (game.active !== DEM) {
change_player()
@@ -3959,15 +3700,11 @@ 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) {
+ } else if (game.round_player === COM) {
game.round_player = DEM
if (game.active !== DEM) {
change_player()
@@ -3976,7 +3713,6 @@ function end_round() {
return
}
if (game.round_player === DEM) {
-
if (game.persistent_events.includes(C_STASI)) {
if (game.active !== DEM) {
change_player()
@@ -4015,17 +3751,16 @@ function new_turn() {
game.round_player = COM
game.dem_tst_attempted_this_turn = 0
game.com_tst_attempted_this_turn = 0
- if (game.tst_7) {
- game.tst_7 = false
- }
- if (game.tst_8) {
- game.tst_8 = false
- }
delete game.selected_space
delete game.return_state
+ delete game.stasi_card
+ delete game.stand_fast
+ if (game.tst_7)
+ game.tst_7 = false
+ if (game.tst_8)
+ game.tst_8 = false
// Remove events that only last one turn
-
let no_longer_in_effect = []
for (let e of one_turn_events) {
if (game.persistent_events.includes(e)) {
@@ -4033,35 +3768,27 @@ function new_turn() {
no_longer_in_effect.push(e)
}
}
-
if (game.prudence) {
delete game.prudence
no_longer_in_effect.push(C_PRUDENCE)
}
-
if (no_longer_in_effect.length > 0) {
log('No longer in effect:')
for (let c of no_longer_in_effect)
logi("C" + c)
}
-
- delete game.stasi_card
- delete game.stand_fast
-
if (game.samizdat_card > 0) {
game.democrat_hand.push(game.samizdat_card)
delete game.samizdat_card
}
-
+ // New Turn
log_h1("Turn " + game.turn)
-
if (game.turn === 4) {
add_midyear()
}
if (game.turn === 8) {
add_lateyear()
}
-
if (game.turn > 1) {
if (game.persistent_events.includes(C_PRESIDENTIAL_VISIT)) {
game.com_hand_limit = 7
@@ -4072,14 +3799,12 @@ 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')
-
if (
(game.dem_tst_position >= 5 && game.com_tst_position <= 4 && game.active !== DEM) ||
(game.com_tst_position >= 5 && game.dem_tst_position <= 4 && game.active !== COM)
@@ -4142,7 +3867,6 @@ 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"
while (democrat_hand.length < dem_hand_limit || communist_hand.length < com_hand_limit) {
if (deck.length === 0) {
@@ -4275,7 +3999,6 @@ function reset_power() {
delete game.ps_round
delete game.vp_roll
delete game.vp_retain
-
let scoring_events = [C_PEASANT_PARTIES_REVOLT, C_YAKOVLEV_COUNSELS_GORBACHEV, C_THE_CROWD_TURNS_AGAINST_CEAUSESCU]
for (let e of scoring_events) {
if (e === C_THE_CROWD_TURNS_AGAINST_CEAUSESCU) {
@@ -4424,9 +4147,8 @@ function log_event(n) {
}
function log_br() {
- if (game.log.length > 0 && game.log[game.log.length - 1] !== "") {
+ if (game.log.length > 0 && game.log[game.log.length - 1] !== "")
game.log.push("")
- }
}
function logi(msg) {
@@ -4493,8 +4215,6 @@ function summary_flush() {
// ============ MAP AND SET FUNCTIONS ===========
-// Array remove and insert (faster than splice)
-
function array_insert_pair(array, index, key, value) {
for (let i = array.length; i > index; i -= 2) {
array[i] = array[i-2]
@@ -4504,8 +4224,6 @@ function array_insert_pair(array, index, key, value) {
array[index+1] = value
}
-// Map as plain sorted array of key/value pairs
-
function map_clear(map) {
map.length = 0
}
@@ -4610,18 +4328,15 @@ function object_copy(original) {
function goto_vm(proc) {
let old_vm = game.vm
-
game.state = "vm"
game.vm = {
prompt: 0,
fp: proc,
ip: 0,
}
-
if (old_vm) {
game.vm.return_vm = old_vm
}
-
vm_exec()
}
@@ -4726,8 +4441,6 @@ function vm_prompt() {
}
function vm_return() {
- console.log('vm_return called')
- // Remove temporary vm variables
delete game.support_check_modifier
delete game.vm_max_infl
delete game.vm_influence_added
@@ -4736,13 +4449,9 @@ 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 === 'ceausescu_check') {
vm_end_event()
- }
- // Check if auto-resolve opponent event (excluding Kiss of Death)
- else if ((is_auto_resolve(game.played_card) && game.played_card !== C_KISS_OF_DEATH ) &&
+ } else if ((is_auto_resolve(game.played_card) && game.played_card !== C_KISS_OF_DEATH ) &&
((cards[game.played_card].side === 'C' && game.active === DEM) ||
(cards[game.played_card].side === 'D' && game.active === COM))
) {
@@ -4753,27 +4462,19 @@ function vm_return() {
}
function vm_end_event() {
- console.log('in vm_end_event, game.return_state', game.return_state, 'game.vm_infl_to_do', game.vm_infl_to_do)
if (game.return_state === 'ceausescu_check') {
end_round()
return
}
- if (game.return !== game.active) {
- console.log('1')
+ if (game.return !== game.active)
change_player()
- }
- if (game.return_state === 'power_struggle') {
- console.log('2')
+ if (game.return_state === 'power_struggle')
do_valid_cards()
- }
- if (game.return_state && game.return_state !== '') {
- console.log('3')
+ if (game.return_state && game.return_state !== '')
game.state = game.return_state
- } else if (game.vm_infl_to_do) {
- console.log('going to resolve opp event')
+ else if (game.vm_infl_to_do) {
game.state = 'resolve_opponent_event'
} else {
- console.log('4')
end_round()
}
}
@@ -4796,7 +4497,6 @@ function vm_valid_spaces_opponent() {
let valid_spaces = []
for (let i = 0; i < spaces.length; i++) {
let space = spaces[i]
-
if (game.active === DEM) {
let infl = game.comInfl[i]
if (infl > 0) {
@@ -5051,24 +4751,19 @@ function vm_add_limited_infl() {
function vm_do_add_limited_infl(space, max_infl) {
push_undo()
game.vm_available_ops --
-
if (!game.vm_influence_added) {
game.vm_influence_added = {}
}
-
if (!game.vm_influence_added[space]) {
game.vm_influence_added[space] = 0
}
-
if (game.active === COM) {
game.comInfl[space] ++
} else {
game.demInfl[space] ++
}
-
summary_influence(space)
game.vm_influence_added[space] ++
-
if (game.vm_influence_added[space] === max_infl) {
game.valid_spaces = game.valid_spaces.filter(id => id !== space)
}
@@ -5153,33 +4848,23 @@ function vm_remove_limited_opp_infl() {
function vm_do_remove_limited_infl(space, max_infl) {
push_undo()
game.vm_available_ops --
-
- if (!game.vm_influence_added) {
+ if (!game.vm_influence_added)
game.vm_influence_added = {}
- }
-
- if (!game.vm_influence_added[space]) {
+ if (!game.vm_influence_added[space])
game.vm_influence_added[space] = 0
- }
-
if (game.active === COM) {
game.demInfl[space] --
- if (game.demInfl[space] === 0) {
+ if (game.demInfl[space] === 0)
game.valid_spaces = game.valid_spaces.filter(id => id !== space)
- }
} else {
game.comInfl[space] --
- if (game.comInfl[space] === 0) {
+ if (game.comInfl[space] === 0)
game.valid_spaces = game.valid_spaces.filter(id => id !== space)
- }
}
-
game.vm_influence_added[space] ++
-
if (game.vm_influence_added[space] === max_infl) {
game.valid_spaces = game.valid_spaces.filter(id => id !== space)
}
-
summary_influence(space)
check_tyrant()
if (game.vm_available_ops === 0) {
@@ -5292,9 +4977,8 @@ function vm_adamec() {
}
function vm_army_backs_revolution() {
- if (game.persistent_events.includes(C_SECURITATE)) {
+ if (game.persistent_events.includes(C_SECURITATE))
permanently_remove(C_SECURITATE)
- }
add_to_persistent_events(C_ARMY_BACKS_REVOLUTION)
log(`C${C_SECURITATE} no longer has any effect.`)
vm_next()
@@ -5314,12 +4998,10 @@ function vm_austria_hungary_border_reopened() {
}
function vm_betrayal() {
- if (game.demInfl[S_ORTHODOX_CHURCH_ROMANIA] > 0) {
+ if (game.demInfl[S_ORTHODOX_CHURCH_ROMANIA] > 0)
game.valid_spaces.push(S_ORTHODOX_CHURCH_ROMANIA)
- }
- if (game.demInfl[S_ORTHODOX_CHURCH_BULGARIA] > 0) {
+ if (game.demInfl[S_ORTHODOX_CHURCH_BULGARIA] > 0)
game.valid_spaces.push(S_ORTHODOX_CHURCH_BULGARIA)
- }
game.state = 'vm_switch_infl'
}
@@ -5367,19 +5049,14 @@ function vm_ceausescu_prep() {
function vm_ceausescu() {
game.persistent_events = game.persistent_events.filter(n => n!== C_CEAUSESCU)
let adj_cluj = false
-
- if (game.demInfl[S_TIMISOARA] > 0) {
+ if (game.demInfl[S_TIMISOARA] > 0)
adj_cluj = true
- }
- if (game.demInfl[S_BABES_BOLYAI_UNIVERSITY] > 0) {
+ if (game.demInfl[S_BABES_BOLYAI_UNIVERSITY] > 0)
adj_cluj = true
- }
- if (game.demInfl[S_ORTHODOX_CHURCH_ROMANIA] > 0) {
+ if (game.demInfl[S_ORTHODOX_CHURCH_ROMANIA] > 0)
adj_cluj = true
- }
- if (game.demInfl[S_BUCURESTI] > 0) {
+ if (game.demInfl[S_BUCURESTI] > 0)
adj_cluj = true
- }
if (adj_cluj && game.comInfl[S_BUCURESTI] > 0) {
if (game.active !== COM) {
@@ -5412,17 +5089,15 @@ function vm_civic_forum_prep() {
}
function vm_civic_forum() {
- if (check_dem_control(S_CZECH_WRITERS)) {
+ if (check_dem_control(S_CZECH_WRITERS))
vm_next()
- } else {
+ else
vm_return()
- }
}
function vm_cluj_check() {
- if (game.comInfl[S_CLUJ_NAPOCA] > 0) {
+ if (game.comInfl[S_CLUJ_NAPOCA] > 0)
game.valid_spaces.push(S_CLUJ_NAPOCA)
- }
vm_next()
}
@@ -5509,7 +5184,6 @@ function vm_elena() {
}
function vm_eliminate(space_id) {
- // Eliminate the democrat influence and move the communist influence to Bucuresti
log(`Eliminated %${space_id}.`)
if (space_id === S_BUCURESTI) {
game.demInfl[space_id] = 0
@@ -5533,7 +5207,7 @@ function get_adjusted_adjacency(space_id) {
return spaces[eliminated_space_id].adjacent
}
return adj_space_id
- }).flat() // Flatten in case the eliminated space has multiple adjacencies
+ }).flat()
}
adjacent_spaces = adjacent_spaces.filter(s => s !== space_id)
return adjacent_spaces
@@ -5586,15 +5260,12 @@ function vm_goodbye_lenin() {
game.view_opp_hand = true
game.communist_hand_red = []
for (let card of game.communist_hand) {
- if (cards[card].red) {
+ if (cards[card].red)
game.communist_hand_red.push(card)
- }
}
- // Check if these cards are playable
for (let card of game.communist_hand_red) {
- if (cards[card].playable || game.playable_cards.includes(card)) {
+ if (cards[card].playable || game.playable_cards.includes(card))
game.valid_cards.push(card)
- }
}
game.state = 'vm_goodbye_lenin'
}
@@ -5602,9 +5273,8 @@ function vm_goodbye_lenin() {
function vm_government_resigns() {
for (let i = 0; i < spaces.length; i++) {
let space = spaces[i]
- if (space.socio === SOCIO_ELITE && game.comInfl[i] > 0 && !is_controlled(i)) {
+ if (space.socio === SOCIO_ELITE && game.comInfl[i] > 0 && !is_controlled(i))
game.valid_spaces.push(i)
- }
}
game.remove_opponent_infl = true
vm_next()
@@ -5662,8 +5332,6 @@ function vm_inflationary_currency() {
}
function vm_inflationary_currency_discard() {
- // This function starts with the player who is playing Inflationary Currency for the Event
- // Switch player and check the hand of their opponent to see if the have cards with ops > 3 to discard
change_player()
if (game.active === COM) {
for (let card of game.communist_hand) {
@@ -5844,8 +5512,6 @@ function vm_power_struggle() {
game.raised_stakes_round = 0
game.raised_stakes_discard = 0
game.pwr_struggle_in = countries[scoring_cards.indexOf(game.vm_event)]
-
- // Check for Securitate
if (game.pwr_struggle_in === 'Romania' && game.persistent_events.includes(C_SECURITATE)) {
log(`C${C_SECURITATE}: Democrat reveals Power Struggle cards.`)
game.opp_power_hand = true
@@ -5876,9 +5542,8 @@ function vm_prudence() {
function vm_public_against_violence() {
game.valid_spaces = []
- if (game.comInfl[S_BRATISLAVA] > 0) {
+ if (game.comInfl[S_BRATISLAVA] > 0)
game.valid_spaces.push(S_BRATISLAVA)
- }
vm_next()
}
@@ -5894,7 +5559,6 @@ function vm_reformer_rehabilitated() {
continue
if (scoring_cards.includes(card))
continue
-
game.valid_cards.push(card)
}
game.state = 'vm_play_event_from_discard'
@@ -5907,12 +5571,10 @@ function vm_roundtable_talks() {
}
function vm_sajudis_check() {
- if (!check_dem_control(S_RAZGRAD)) {
+ if (!check_dem_control(S_RAZGRAD))
game.valid_spaces.push(S_RAZGRAD)
- }
- if (!check_dem_control(S_HARGHITA_COVASNA)) {
+ if (!check_dem_control(S_HARGHITA_COVASNA))
game.valid_spaces.push(S_HARGHITA_COVASNA)
- }
vm_next()
}
@@ -5995,13 +5657,10 @@ function vm_tank_column() {
} else {
game.com_tst_position++
game.com_tst_attempted = 0
- // Check if the Chinese Solution becomes playable
if (game.com_tst_position === 7) {
game.playable_cards.push(C_THE_CHINESE_SOLUTION)
}
}
-
- // Check if TST Awards occur
if (game.active === DEM) {
if (game.dem_tst_position === 3 && game.com_tst_position < 3) {
game.vm_event = 203
@@ -6045,12 +5704,10 @@ function vm_the_baltic_way_prep() {
}
function vm_the_baltic_way() {
- if (!check_dem_control(S_HARGHITA_COVASNA) && game.systematization !== S_HARGHITA_COVASNA) {
+ if (!check_dem_control(S_HARGHITA_COVASNA) && game.systematization !== S_HARGHITA_COVASNA)
game.valid_spaces.push(S_HARGHITA_COVASNA)
- }
- if (!check_dem_control(S_RAZGRAD)) {
+ if (!check_dem_control(S_RAZGRAD))
game.valid_spaces.push(S_RAZGRAD)
- }
vm_next()
}
@@ -6066,12 +5723,10 @@ function vm_the_crowd_turns_against_ceausescu() {
}
function vm_the_monday_demonstrations() {
- if (!check_dem_control(S_LUTHERAN_CHURCH)) {
+ if (!check_dem_control(S_LUTHERAN_CHURCH))
game.valid_spaces.push(S_LUTHERAN_CHURCH)
- }
- if (!check_dem_control(S_LEIPZIG)) {
+ if (!check_dem_control(S_LEIPZIG))
game.valid_spaces.push(S_LEIPZIG)
- }
vm_next()
}
@@ -6099,9 +5754,8 @@ function vm_the_tyrant_is_gone() {
for (let i = 0; i < spaces.length; i++) {
let space = spaces[i]
if (game.demInfl[i] === 0 && space.country === 'Romania') {
- if (space.space_id === game.systematization) {
+ if (space.space_id === game.systematization)
continue
- }
game.valid_spaces.push(space.space_id)
}
}
@@ -6139,15 +5793,13 @@ function vm_warsaw_pact_summit() {
}
function vm_we_are_the_people() {
- if (game.demInfl[S_LUTHERAN_CHURCH] > 0) {
+ if (game.demInfl[S_LUTHERAN_CHURCH] > 0)
game.valid_spaces = [ S_LUTHERAN_CHURCH ]
- }
add_to_persistent_events(C_WE_ARE_THE_PEOPLE)
log(`The Communist may no longer make Support Checks in Leipzig.`)
log('Removed SP:')
- if (!game.vm_influence_added) {
+ if (!game.vm_influence_added)
game.vm_influence_added = {}
- }
game.vm_influence_added[S_LUTHERAN_CHURCH] = 0
game.vm_available_ops = 4
game.state = 'vm_we_are_the_people_remove'
@@ -6184,7 +5836,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. */
+ }
vm_next()
}
@@ -6214,7 +5866,7 @@ function vm_tst_6() {
}
function vm_tst_8() {
- game.state = 'vm_goodbye_lenin_ops' // Use this to resolve ops.
+ game.state = 'vm_goodbye_lenin_ops'
}
// ==================== POWER STRUGGLE FUNCTIONS ======================
@@ -6348,7 +6000,6 @@ states.vm_add_infl_free = {
gen_action('done')
} else if (game.vm_available_ops > 0) {
prompt_event(`Place ${game.vm_available_ops} SPs in ${event_prompt()}.`)
-
for (let space_id of game.valid_spaces) {
gen_action_space(space_id)
}
@@ -6385,7 +6036,6 @@ states.vm_add_x_infl = {
gen_action('done')
} else if (game.vm_available_ops > 0) {
prompt_event(`Place ${game.vm_available_ops} SPs in ${event_prompt()}.`)
-
for (let space_id of game.valid_spaces) {
gen_action_space(space_id)
}
@@ -6411,8 +6061,7 @@ states.vm_add_limited_infl = {
if (game.vm_available_ops > 0 && game.valid_spaces.length > 0) {
if (game.vm_max_infl === 1) {
prompt_event(`Place ${pluralize(game.vm_max_infl,'SP')} ${event_prompt()}.`)
- }
- else {
+ } else {
prompt_event(`Place ${pluralize(game.vm_available_ops,'SP')} in ${event_prompt()}.`)
}
for (let space_id of game.valid_spaces) {
@@ -6432,7 +6081,6 @@ states.vm_add_limited_infl = {
states.vm_remove_infl = {
prompt() {
- // 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) {
prompt_event("No SPs to remove.")
gen_action('done')
@@ -6502,7 +6150,6 @@ states.vm_remove_limited_infl = {
prompt() {
if (game.vm_available_ops > 0 && game.valid_spaces.length > 0) {
prompt_event(`Remove ${pluralize(game.vm_available_ops,'SP')}${event_prompt()}, no more than ${game.vm_max_infl} per space.`)
-
for (let space_id of game.valid_spaces) {
gen_action_space(space_id)
}
@@ -6568,10 +6215,6 @@ states.vm_support_check_prep = {
space(space) {
push_undo()
game.selected_space = space
-
- // Check for Austria-Hungary Border Reopened - check on first Support Check only
- // First check for Monday Demonstrations or My First Banana - Support Checks will always be in East Germany
- // TODO: Add check for My First Banana?
if (
(game.vm_event === C_THE_MONDAY_DEMONSTRATIONS || game.vm_event === C_MY_FIRST_BANANA) &&
game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)
@@ -6580,8 +6223,6 @@ states.vm_support_check_prep = {
game.state = 'vm_do_support_check'
return
}
-
- // Then check Austria-Hungary Border Reopened normally
if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
if (game.active === DEM && game.vm_available_ops > 1) {
if (
@@ -6616,8 +6257,6 @@ states.vm_ceh_support_check_prep = {
space(space) {
push_undo()
game.selected_space = space
-
- // Then check Austria-Hungary Border Reopened normally
if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
if (game.active === DEM && game.vm_available_ops > 1) {
if (
@@ -6685,7 +6324,6 @@ states.vm_1_support_check_prep = {
space(space) {
push_undo()
game.selected_space = space
- //Check for Austria Hungary Border Reopened on Democrat Support Check
if (
game.active === DEM &&
game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED) &&
@@ -6889,7 +6527,7 @@ states.vm_common_european_home_play = {
gen_action('influence')
gen_action('support_check')
if (game.active === DEM && game.vm_event === C_KOHL_PROPOSES_REUNIFICATION) {
- return /* Special condition if card is actually Kohl Proposes Reunification */
+ return
}
},
influence() {
@@ -6897,7 +6535,6 @@ states.vm_common_european_home_play = {
log('Placed SP:')
game.vm_available_ops = get_card_ops(game.vm_event)
valid_spaces_infl()
- // If ABHR - Set AHBR tracker to true
if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
game.austria_hungary_border_reopened_tracker = true
}
@@ -7208,8 +6845,6 @@ 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(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
game.austria_hungary_border_reopened_tracker = true
}
@@ -7371,9 +7006,7 @@ states.vm_kiss_of_death = {
discard() {
clear_undo()
game.vm_event = discard_card(game.communist_hand)
- // Change player before checking if event is playable. Common European Home is not playable here
change_player()
- // Special check for the Reformer Rehabilitated
if (game.vm_event === C_REFORMER_REHABILITATED && game.dem_tst_position > game.com_tst_position) {
log_event(game.vm_event)
game.state = 'vm_kiss_of_death_finish'
@@ -8093,7 +7726,6 @@ states.vm_the_wall_must_go = {
if (game.the_wall_must_go['dem_roll'] === 0 && game.the_wall_must_go['com_roll'] === 0) {
log(`Round ${attempt+1}`)
}
-
let roll = roll_d6()
logi(`${game.active}: D${roll}`)
if (game.active === DEM) {
@@ -8112,7 +7744,6 @@ 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']) {
@@ -8124,7 +7755,6 @@ states.vm_the_wall_must_go = {
logi('Communist wins')
game.the_wall_must_go['com_wins']++
}
-
logi(`Democrat: ${game.the_wall_must_go['dem_wins']}, Communist: ${game.the_wall_must_go['com_wins']}`)
}
if (game.the_wall_must_go['dem_wins'] === 2) {
@@ -8353,7 +7983,6 @@ states.vm_tst_4 = {
return
}
view.prompt = `Tiananmen Square Award: Remove ${pluralize(game.vm_available_ops,'SP')}.`
-
for (let space_id of game.valid_spaces) {
gen_action_space(space_id)
}
@@ -8477,7 +8106,6 @@ states.vm_tst_8_ops = {
push_undo()
game.vm_available_ops = cards[game.played_card].ops
valid_spaces_infl()
- // If ABHR - Set AHBR tracker to true
if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
game.austria_hungary_border_reopened_tracker = true
}