summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js165
1 files changed, 101 insertions, 64 deletions
diff --git a/rules.js b/rules.js
index 871b4ed..00cbaab 100644
--- a/rules.js
+++ b/rules.js
@@ -714,69 +714,93 @@ states.play_card = {
check_ligachev_event(game.played_card)
log_event(game.played_card)
}
- game.vm_infl_to_do = false
- game.return = game.active
- if (switch_events.includes(game.played_card)) {
- change_player()
+ if (game.state === 'game_over') {
+ return
+ } else {
+ game.vm_infl_to_do = false
+ game.return = game.active
+ if (switch_events.includes(game.played_card)) {
+ change_player()
+ }
+ game.vm_event = game.played_card
+ goto_vm(game.vm_event)
}
- game.vm_event = game.played_card
- goto_vm(game.vm_event)
},
opp_event() {
push_undo()
log_ops_banner()
check_ligachev_event(game.played_card)
- log_event(game.played_card)
- game.vm_infl_to_do = true
- game.return = game.active
- game.vm_event = game.played_card
- if (is_auto_resolve(game.played_card) || switch_events.includes(game.played_card)) {
- goto_vm(game.vm_event)
+ if (game.state === 'game_over') {
+ return
} else {
- change_player()
- goto_vm(game.vm_event)
+ log_event(game.played_card)
+ game.vm_infl_to_do = true
+ game.return = game.active
+ game.vm_event = game.played_card
+ if (is_auto_resolve(game.played_card) || switch_events.includes(game.played_card)) {
+ goto_vm(game.vm_event)
+ } else {
+ change_player()
+ goto_vm(game.vm_event)
+ }
}
},
influence() {
push_undo()
log_ops_banner()
check_ligachev_non_event()
- log('Placed SP:')
- finish_play_card()
+ if (game.state === 'game_over') {
+ return
+ } else {
+ log('Placed SP:')
+ finish_play_card()
- // If ABHR - Set AHBR tracker to true
- if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
- game.austria_hungary_border_reopened_tracker = true
+ // If ABHR - Set AHBR tracker to true
+ if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
+ game.austria_hungary_border_reopened_tracker = true
+ }
+ game.state = 'add_influence'
+ valid_spaces_infl()
}
- game.state = 'add_influence'
- valid_spaces_infl()
},
tst() {
push_undo()
log_ops_banner()
check_ligachev_non_event()
- log('Tiananmen Square Attempt:')
- finish_play_card()
- game.state = 'tiananmen_square_attempt'
+ if (game.state === 'game_over') {
+ return
+ } else {
+ log('Tiananmen Square Attempt:')
+ finish_play_card()
+ game.state = 'tiananmen_square_attempt'
+ }
},
support_check() {
push_undo()
log_ops_banner()
check_ligachev_non_event()
- log('Support Checks:')
- finish_play_card()
- game.available_ops = 2
- game.state = 'support_check_prep'
- valid_spaces_sc()
+ if (game.state === 'game_over') {
+ return
+ } else {
+ log('Support Checks:')
+ finish_play_card()
+ game.available_ops = 2
+ game.state = 'support_check_prep'
+ valid_spaces_sc()
+ }
},
tst_7() { /* Cancel opponent event */
push_undo()
log_ops_banner()
check_ligachev_non_event()
- log(`Event cancelled using TST Award.`)
- game.tst_7 = true
- game.vm_infl_to_do = true
- game.state = 'resolve_opponent_event'
+ if (game.state === 'game_over') {
+ return
+ } else {
+ log(`Event cancelled using TST Award.`)
+ game.tst_7 = true
+ game.vm_infl_to_do = true
+ game.state = 'resolve_opponent_event'
+ }
},
tst_8() { /* Play card for ops and event */
push_undo()
@@ -1141,7 +1165,7 @@ states.draw_power_cards = {
}
// Events which affect cards drawn
if (game.persistent_events.includes(C_ROUNDTABLE_TALKS)) {
- if (game. game.com_pwr_hand_limit >= 2) {
+ if (game.com_pwr_hand_limit >= 2) {
log(`Democrat receives 2 cards from Communist due to C${C_ROUNDTABLE_TALKS}.`)
game.dem_pwr_hand_limit += 2
game.com_pwr_hand_limit -= 2
@@ -1282,6 +1306,7 @@ states.the_crowd_turns_against_ceausescu_infl = {
if (game.return !== game.active) {
change_player()
}
+ summary_flush()
log_h5('Raise the Stakes')
log(`${game.active}:`)
game.state = 'raise_stakes_1'
@@ -1775,7 +1800,7 @@ states.end_turn_4_5_4 = {
}
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!`)
+ goto_game_over('Draw', `The game is tied due to held scoring cards!`)
} else if (dem_has_scoring_card) {
log('Democrat player has a held scoring card')
goto_game_over(COM, `${COM} won by held scoring card!`)
@@ -1898,7 +1923,7 @@ states.final_scoring = {
} else if (game.vp < 0) {
goto_game_over(COM, `${COM} wins on Victory Point Track!`)
} else if (game.vp === 0) {
- goto_game_over('', `The game is tied!`)
+ goto_game_over('Draw', `The game is tied!`)
}
},
}
@@ -2067,7 +2092,7 @@ states.new_years_eve_party = {
} else if (game.vp < 0) {
goto_game_over(COM, `New Year's Eve Party: ${COM} wins on Victory Point Track!`)
} else if (game.vp === 0) {
- goto_game_over('', `New Year's Eve Party: The game is tied!`)
+ goto_game_over('Draw', `New Year's Eve Party: The game is tied!`)
}
},
end() {
@@ -2076,7 +2101,7 @@ states.new_years_eve_party = {
} else if (game.vp < 0) {
goto_game_over(COM, `New Year's Eve Party: ${COM} wins on Victory Point Track!`)
} else if (game.vp === 0) {
- goto_game_over('', `New Year's Eve Party: The game is tied!`)
+ goto_game_over('Draw', `New Year's Eve Party: The game is tied!`)
}
},
}
@@ -2218,22 +2243,30 @@ states.stasi_play_ceh = {
log_ops_banner()
log(`Played C${game.played_card} with C${C_COMMON_EUROPEAN_HOME}.`)
check_ligachev_non_event()
- log('Placed SP:')
- if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
- game.austria_hungary_border_reopened_tracker = true
+ if (game.state === 'game_over') {
+ return
+ } else {
+ log('Placed SP:')
+ if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
+ game.austria_hungary_border_reopened_tracker = true
+ }
+ game.state = 'add_influence'
+ valid_spaces_infl()
}
- game.state = 'add_influence'
- valid_spaces_infl()
},
support_check() {
push_undo()
log_ops_banner()
log(`Played C${game.played_card} with C${C_COMMON_EUROPEAN_HOME}.`)
check_ligachev_non_event()
- log('Support Checks:')
- game.available_ops = 2
- game.state = 'support_check_prep'
- valid_spaces_sc()
+ if (game.state === 'game_over') {
+ return
+ } else {
+ log('Support Checks:')
+ game.available_ops = 2
+ game.state = 'support_check_prep'
+ valid_spaces_sc()
+ }
},
}
@@ -3201,7 +3234,7 @@ function remove_from_hand(card) {
function check_ligachev_non_event() {
if (game.active === DEM && game.persistent_events.includes(C_LIGACHEV)) {
- log(`-3 VP from C${C_LIGACHEV}`)
+ log(`-3 VP from C${C_LIGACHEV}.`)
game.vp -= 3
if (check_vp()) {
return
@@ -3214,7 +3247,7 @@ function check_ligachev_non_event() {
function check_ligachev_event(card) {
if (game.active === DEM && game.persistent_events.includes(C_LIGACHEV)) {
if (card !== C_GORBACHEV_CHARMS_THE_WEST) {
- log(`-3 VP from C${C_LIGACHEV}`)
+ log(`-3 VP from C${C_LIGACHEV}.`)
game.vp -= 3
if (check_vp()) {
return
@@ -5076,15 +5109,15 @@ 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)
- adj_cluj = true
- if (game.demInfl[S_BABES_BOLYAI_UNIVERSITY] > 0)
- adj_cluj = true
- if (game.demInfl[S_ORTHODOX_CHURCH_ROMANIA] > 0)
- adj_cluj = true
- if (game.demInfl[S_BUCURESTI] > 0)
- adj_cluj = true
-
+ let adj_spaces = null
+ if (game.systematization !== S_CLUJ_NAPOCA)
+ adj_spaces = get_adjusted_adjacency(S_CLUJ_NAPOCA)
+ if (adj_spaces) {
+ for (let s of adj_spaces) {
+ if (game.demInfl[s] > 0)
+ adj_cluj = true
+ }
+ }
if (adj_cluj && game.comInfl[S_BUCURESTI] > 0) {
if (game.active !== COM) {
change_player()
@@ -8101,12 +8134,16 @@ states.vm_tst_8 = {
event() {
push_undo()
check_ligachev_event(game.played_card)
- log_event(game.played_card)
- game.vm_event_to_do = false
- game.return_state = 'vm_tst_8'
- game.return = game.active
- game.vm_event = game.played_card
- goto_vm(game.vm_event)
+ if (game.state === 'game_over') {
+ return
+ } else {
+ log_event(game.played_card)
+ game.vm_event_to_do = false
+ game.return_state = 'vm_tst_8'
+ game.return = game.active
+ game.vm_event = game.played_card
+ goto_vm(game.vm_event)
+ }
},
ops() {
push_undo()