summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2024-11-01 13:27:15 +0000
committeriainp5 <iain.pearce.ip@gmail.com>2024-11-01 13:27:15 +0000
commit051b5d19a9420a7c60db6c6e97cd165c32cecc49 (patch)
tree54333ae2ec8751fe8b00595ae1b710d91c8f5334 /rules.js
parent74f6d1f269ef0eb5fb1cd616f6cb791d9041d756 (diff)
download1989-dawn-of-freedom-051b5d19a9420a7c60db6c6e97cd165c32cecc49.tar.gz
Tidy up persistent events
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js114
1 files changed, 44 insertions, 70 deletions
diff --git a/rules.js b/rules.js
index d022769..c8ab1dc 100644
--- a/rules.js
+++ b/rules.js
@@ -252,8 +252,6 @@ exports.setup = function (seed, scenario, options) {
return: '',
vm: null,
vm_event: 0,
- vm_event_to_do: false,
- vm_infl_to_do: false,
played_card: 0,
table_cards: [],
@@ -1655,11 +1653,11 @@ states.end_turn_4_5_4 = {
log('Communist player has a held scoring card')
goto_game_over(DEM, `${DEM} won by held scoring card!`)
}
- else if (game.persistent_events.includes(104)) {
+ else if (game.persistent_events.includes(C_NEW_YEARS_EVE_PARTY)) {
log_h1(`New Year's Eve Party`)
game.vm_event = 104
//Check if the Communist receives VP from The Tyrant is Gone
- if (game.persistent_events.includes(97)) {
+ if (game.persistent_events.includes(C_THE_TYRANT_IS_GONE)) {
game.vp -= 2
log(`Communist receives 2 VP from C97`)
}
@@ -1674,7 +1672,7 @@ states.end_turn_4_5_4 = {
log_h2('Final Scoring')
//Check if the Communist receives VP from The Tyrant is Gone
- if (game.persistent_events.includes(97)) {
+ if (game.persistent_events.includes(C_THE_TYRANT_IS_GONE)) {
game.vp -= 2
log(`Communist receives 2 VP from C97`)
}
@@ -2861,6 +2859,13 @@ function get_aftermath_roll() {
return modified_roll
}
+function add_to_persistent_events(card) {
+ game.persistent_events.push(card)
+ game.table_cards.push(card)
+ remove_from_discard(card)
+ log(`C${card} in effect`)
+}
+
function permanently_remove(card) {
if (game.strategy_removed.includes(card)) {return}
remove_from_discard(card)
@@ -3141,7 +3146,7 @@ function get_tst_6_ops() {
function finish_the_wall() {
if (game.the_wall_must_go['dem_wins'] === 2) {
- game.persistent_events.push(86)
+ game.persistent_events.push(C_THE_WALL_MUST_GO)
log('+3 VP')
game.vp += 3
if (check_vp()) {
@@ -3619,6 +3624,7 @@ function reset_power() {
delete game.phase
delete game.raised_stakes_round
delete game.raised_stakes
+ delete game.raised_stakes_discard
delete game.played_power_card
delete game.tactics_fails
game.view_opp_hand = false
@@ -4493,8 +4499,7 @@ function vm_army_backs_revolution() {
}
function vm_austria_hungary_border_reopened() {
- game.persistent_events.push(C_AUSTRIA_HUNGARY_BORDER_REOPENED)
- permanently_remove(C_AUSTRIA_HUNGARY_BORDER_REOPENED)
+ add_to_persistent_events(C_AUSTRIA_HUNGARY_BORDER_REOPENED)
game.austria_hungary_border_reopened_tracker = false
vm_next()
}
@@ -4566,7 +4571,7 @@ function vm_civic_forum() {
if (check_vp()) {
return
}
- game.persistent_events.push(C_CIVIC_FORUM)
+ add_to_persistent_events(C_CIVIC_FORUM)
if (check_dem_control(S_CZECH_WRITERS)) {
vm_next()
} else {
@@ -4628,12 +4633,12 @@ function vm_domino_theory() {
}
function vm_eco_glasnost() {
- game.persistent_events.push(39)
+ add_to_persistent_events(C_ECO_GLASNOST)
vm_next()
}
function vm_elena(){
- game.persistent_events.push(C_ELENA)
+ add_to_persistent_events(C_ELENA)
vm_next()
}
@@ -4679,7 +4684,7 @@ function vm_foreign_currency_debt_burden() {
if (check_vp()) {
return
}
- game.persistent_events.push(C_FOREIGN_CURRENCY_DEBT_BURDEN)
+ add_to_persistent_events(C_FOREIGN_CURRENCY_DEBT_BURDEN)
game.state = 'vm_foreign_currency_debt_burden'
}
@@ -4693,26 +4698,17 @@ function vm_foreign_television() {
vm_next()
}
function vm_frg_embassies() {
- game.persistent_events.push(C_FRG_EMBASSIES)
- game.table_cards.push(C_FRG_EMBASSIES)
- remove_from_discard(C_FRG_EMBASSIES)
- log(`C${C_FRG_EMBASSIES} in effect`)
+ add_to_persistent_events(C_FRG_EMBASSIES)
vm_next()
}
function vm_general_strike() {
- game.persistent_events.push(C_GENERAL_STRIKE)
- game.table_cards.push(C_GENERAL_STRIKE)
- remove_from_discard(C_GENERAL_STRIKE)
- log(`C${C_GENERAL_STRIKE} in effect`)
+ add_to_persistent_events(C_GENERAL_STRIKE)
vm_next()
}
function vm_genscher() {
- game.persistent_events.push(C_GENSCHER)
- game.table_cards.push(C_GENSCHER)
- remove_from_discard(C_GENSCHER)
- log(`C${C_GENSCHER} in effect`)
+ add_to_persistent_events(C_GENSCHER)
vm_next()
}
@@ -4746,8 +4742,7 @@ function vm_government_resigns() {
}
function vm_grenztruppen() {
- game.persistent_events.push(C_GRENZTRUPPEN)
- permanently_remove(C_GRENZTRUPPEN)
+ add_to_persistent_events(C_GRENZTRUPPEN)
vm_next()
}
@@ -4769,12 +4764,12 @@ function vm_heal_our_bleeding_wounds() {
}
function vm_helsinki_final_act() {
- game.persistent_events.push(C_HELSINKI_FINAL_ACT)
+ add_to_persistent_events(C_HELSINKI_FINAL_ACT)
vm_next()
}
function vm_honecker() {
- game.persistent_events.push(C_HONECKER)
+ add_to_persistent_events(C_HONECKER)
game.valid_cards = []
for (let c of game.strategy_discard) {
if (scoring_cards.includes(c)) {
@@ -4854,7 +4849,7 @@ function vm_kremlin_coup() {
}
function vm_laszlo_tokes() {
- game.persistent_events.push(C_LASZLO_TOKES)
+ add_to_persistent_events(C_LASZLO_TOKES)
game.playable_cards.push(C_MASSACRE_IN_TIMISOARA)
game.state = 'vm_laszlo_tokes'
}
@@ -4875,13 +4870,12 @@ function vm_legacy_of_1968() {
}
function vm_li_peng() {
- game.persistent_events.push(C_LI_PENG)
- remove_from_discard(C_LI_PENG)
+ add_to_persistent_events(C_LI_PENG)
vm_next()
}
function vm_ligachev() {
- game.persistent_events.push(C_LIGACHEV)
+ add_to_persistent_events(C_LIGACHEV)
vm_next()
}
@@ -4907,9 +4901,7 @@ function vm_nagy_reburied(){
}
function vm_national_salvation_front() {
- game.persistent_events.push(C_NATIONAL_SALVATION_FRONT)
- game.table_cards.push(C_NATIONAL_SALVATION_FRONT)
- remove_from_discard(C_NATIONAL_SALVATION_FRONT)
+ add_to_persistent_events(C_NATIONAL_SALVATION_FRONT)
vm_next()
}
@@ -4933,17 +4925,12 @@ function vm_normalisation() {
}
function vm_peasant_parties_revolt() {
- game.persistent_events.push(C_PEASANT_PARTIES_REVOLT)
- log_msg_gap(`C${C_PEASANT_PARTIES_REVOLT} in effect`)
- game.table_cards.push(C_PEASANT_PARTIES_REVOLT)
- remove_from_discard(C_PEASANT_PARTIES_REVOLT)
+ add_to_persistent_events(C_PEASANT_PARTIES_REVOLT)
vm_next()
}
function vm_perestroika() {
- game.persistent_events.push(C_PERESTROIKA)
- game.table_cards.push(C_PERESTROIKA)
- log_msg_gap(`C${C_PERESTROIKA} in effect`)
+ add_to_persistent_events(C_PERESTROIKA)
vm_next()
}
@@ -4961,7 +4948,9 @@ function vm_poszgay() {
function vm_power_struggle() {
game.is_pwr_struggle = true
game.phase = 0
+ game.raised_stakes = 0
game.raised_stakes_round = 0
+ game.raised_stakes_discard = 0
game.pwr_struggle_in = countries[scoring_cards.indexOf(game.vm_event)]
log_h2(`C${game.vm_event}`)
@@ -4975,7 +4964,7 @@ function vm_power_struggle() {
}
function vm_presidential_visit() {
- game.persistent_events.push(C_PRESIDENTIAL_VISIT)
+ add_to_persistent_events(C_PRESIDENTIAL_VISIT)
log_msg_gap(`C${C_PRESIDENTIAL_VISIT} in effect`)
vm_next()
}
@@ -5014,10 +5003,8 @@ function vm_reformer_rehabilitated () {
}
function vm_roundtable_talks() {
- game.persistent_events.push(17)
- game.table_cards.push(17)
- remove_from_discard(17)
- log_msg_gap('C17 in effect')
+ add_to_persistent_events(C_ROUNDTABLE_TALKS)
+
vm_next()
}
@@ -5047,8 +5034,7 @@ function vm_samizdat() {
}
function vm_securitate() {
- game.persistent_events.push(C_SECURITATE)
- permanently_remove(C_SECURITATE)
+ add_to_persistent_events(C_SECURITATE)
vm_next()
}
@@ -5061,27 +5047,24 @@ function vm_social_democratic_platform_adopted() {
}
function vm_solidarity_legalised() {
- log_msg_gap(`C2 in effect`)
game.playable_cards.push(C_WALESA)
- game.persistent_events.push(C_SOLIDARITY_LEGALIZED)
+ add_to_persistent_events(C_SOLIDARITY_LEGALIZED)
vm_next()
}
function vm_st_nicholas_church () {
- game.persistent_events.push(C_ST_NICHOLAS_CHURCH)
+ add_to_persistent_events(C_ST_NICHOLAS_CHURCH)
game.playable_cards.push(C_THE_MONDAY_DEMONSTRATIONS)
vm_next()
}
function vm_stasi() {
- log_msg_gap('C13 in effect')
- game.table_cards.push(C_STASI)
- game.persistent_events.push(C_STASI)
+ add_to_persistent_events(C_STASI)
vm_next()
}
function vm_stand_fast() {
- game.persistent_events.push(C_STAND_FASTd)
+ add_to_persistent_events(C_STAND_FAST)
if (game.active === DEM) {
game.stand_fast = DEM
} else {game.stand_fast = COM}
@@ -5128,10 +5111,7 @@ function vm_tank_column() {
}
function vm_tear_gas () {
- game.persistent_events.push(C_TEAR_GAS)
- game.table_cards.push(C_TEAR_GAS)
- remove_from_discard(C_TEAR_GAS)
- log_msg_gap(`C${C_TEAR_GAS} in effect`)
+ add_to_persistent_events(C_TEAR_GAS)
vm_next()
}
@@ -5166,9 +5146,7 @@ function vm_the_monday_demonstrations() {
}
function vm_the_sinatra_doctrine() {
- game.persistent_events.push(C_THE_SINATRA_DOCTRINE)
- game.table_cards.push(C_THE_SINATRA_DOCTRINE)
- log_msg_gap(`C${C_THE_SINATRA_DOCTRINE} in effect`)
+ add_to_persistent_events(C_THE_SINATRA_DOCTRINE)
vm_next()
}
@@ -5201,8 +5179,7 @@ function vm_tyrant_block() {
}
function vm_the_wall () {
- game.persistent_events.push(C_THE_WALL)
- log_msg_gap('C9 in effect')
+ add_to_persistent_events(C_THE_WALL)
vm_next()
}
@@ -5221,7 +5198,7 @@ function vm_warsaw_pact_summit() {
function vm_we_are_the_people() {
if (game.demInfl[S_LUTHERAN_CHURCH] > 0) {game.valid_spaces = [S_LUTHERAN_CHURCH]}
- game.persistent_events.push(C_WE_ARE_THE_PEOPLE)
+ add_to_persistent_events(C_WE_ARE_THE_PEOPLE)
if (!game.vm_influence_added) {
game.vm_influence_added = {};
}
@@ -5252,10 +5229,7 @@ function vm_workers_revolt() {
}
function vm_yakovlev_counsels_gorbachev() {
- game.persistent_events.push(C_YAKOVLEV_COUNSELS_GORBACHEV)
- log_msg_gap(`C${C_YAKOVLEV_COUNSELS_GORBACHEV} in effect`)
- game.table_cards.push(C_YAKOVLEV_COUNSELS_GORBACHEV)
- remove_from_discard(C_YAKOVLEV_COUNSELS_GORBACHEV)
+ add_to_persistent_events(C_YAKOVLEV_COUNSELS_GORBACHEV)
vm_next()
}