summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js116
1 files changed, 60 insertions, 56 deletions
diff --git a/rules.js b/rules.js
index 82ac752..de2744f 100644
--- a/rules.js
+++ b/rules.js
@@ -205,6 +205,8 @@ const C_MALTA_SUMMIT = 110
// END CONSTANTS }}}
+const MAGIC_NEW_YEARS_EVE_PARTY = 111
+
const dem_tst_req = [5, 5, 6, 6, 7, 8, 9, 10]
const com_tst_req = [6, 6, 7, 7, 8, 7, 6, 5]
const scoring_cards = [22, 23, 42, 43, 55, 95]
@@ -223,9 +225,13 @@ const numberless_cards = [1, 2, 3, 4, 5, 6, 37, 38, 39, 40, 41, 42, 43, 44, 45,
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 one_turn_events = [ 8, 13, 25, 50, 63, 74, 49, 58, 59, 100, 101 ]
+const ceausecu_events = [10, 41, 69, 101, 107]
-const PC_TACTIC_FAILS = 52
const PC_SUPPORT_FALTERS = 49
+const PC_SUPPORT_SURGES = 50
+const PC_SCARE_TACTICS = 51
+const PC_TACTIC_FAILS = 52
+
const THE_CROWD_TURNS_AGAINST_CEAUSESCU_OCCURRED = 540
const THE_TYRANT_IS_GONE_OCCURRED = 970
@@ -440,10 +446,7 @@ exports.view = function (state, player) {
} else if (player === "Observer" || (game.active !== player && game.active !== "Both")) {
if (states[game.state]) {
let inactive = states[game.state].inactive
- if (typeof inactive === "function")
- view.prompt = `Waiting for ${game.active} ${inactive()}`
- else
- view.prompt = `Waiting for ${game.active} to ${inactive}`
+ view.prompt = `Waiting for ${game.active} to ${inactive}.`
} else {
view.prompt = "A Unknown state: " + game.state
}
@@ -697,7 +700,7 @@ states.play_card = {
finish_play_card()
// If ABHR - Set AHBR tracker to true
- if (game.persistent_events.includes(58)) {
+ if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
game.austria_hungary_border_reopened_tracker = true
}
game.state = 'add_influence'
@@ -771,7 +774,7 @@ states.resolve_opponent_event = {
check_ligachev_non_event()
log_gap(`Played C${game.played_card} to place SPs`)
// If ABHR - Set AHBR tracker to true
- if (game.persistent_events.includes(58)) {
+ if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
game.austria_hungary_border_reopened_tracker = true
}
game.state = 'add_influence'
@@ -864,7 +867,7 @@ states.tiananmen_square_attempt = {
states.tiananmen_square_attempt_success = {
inactive: 'do Tiananmen Square Attempt.',
prompt() {
- if (game.vm_event > 200) {
+ if (game.vm_event > 200) { // TODO magic number
view.prompt = 'Tiananmen Square Track attempt successful. Go to TST Award.'
gen_action('done')
} else {
@@ -980,11 +983,11 @@ states.support_check_prep = {
game.selected_space = space
// Check for Austria-Hungary Border Reopened - check on first Support Check only
- if (game.persistent_events.includes(58)) {
+ if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
if (game.active === DEM && game.available_ops > 1) {
if (
spaces[game.selected_space].country === 'East_Germany' &&
- game.persistent_events.includes(58) &&
+ game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED) &&
game.active === DEM
) {
game.state = 'austria_hungary_border_reopened_check'
@@ -1398,6 +1401,7 @@ states.power_struggle = {
}
game.valid_cards = []
game.return_state = 'power_struggle'
+
if (game.phase === 0) {
delete game.proxy_power_card
}
@@ -1416,15 +1420,16 @@ states.power_struggle = {
log_gap(`Played: P${card} V${power_cards[card].value}`)
}
}
+
if (game.phase === 0) {
if (leader_cards.includes(card)) {
game.played_power_card = card
game.phase = 3
- } else if (card === 51) {
+ } else if (card === PC_SCARE_TACTICS) {
/* Scare Tactics */
game.return = ''
goto_vm(351) /* Can I combine these 3 into a single stage where you goto_vm(300 + card) ? */
- } else if (card === 50) {
+ } else if (card === PC_SUPPORT_SURGES) {
/* Support Surges */
if (game.active === DEM) {
game.return = COM
@@ -1432,7 +1437,7 @@ states.power_struggle = {
game.return = DEM
}
goto_vm(350)
- } else if (game.phase === 0 && card === 49) {
+ } else if (game.phase === 0 && card === PC_SUPPORT_FALTERS) {
/* Support Falters */
next_player()
goto_vm(349)
@@ -1524,7 +1529,7 @@ states.power_struggle = {
states.support_loss = {
inactive: 'do Support Loss.',
prompt() {
- let ps_state = game.persistent_events.includes(111) ? "New Year's Eve Party" : "Power Struggle"
+ let ps_state = game.persistent_events.includes(MAGIC_NEW_YEARS_EVE_PARTY) ? "New Year's Eve Party" : "Power Struggle"
if (game.phase === 0) {
view.prompt = 'You lost the Power Struggle. Roll a die for Support Loss.'
gen_action('roll')
@@ -1568,7 +1573,7 @@ states.support_loss = {
states.vp_roll = {
inactive: 'do VP Roll.',
prompt() {
- let ps_state = game.persistent_events.includes(111) ? "New Year's Eve Party" : "Power Struggle"
+ let ps_state = game.persistent_events.includes(MAGIC_NEW_YEARS_EVE_PARTY) ? "New Year's Eve Party" : "Power Struggle"
if (game.phase === 0) {
view.prompt = `${ps_state} - ${country_name(game.pwr_struggle_in)}: roll a die for Victory.`
gen_action('roll')
@@ -1673,7 +1678,7 @@ states.finish_scoring = {
},
done() {
log_msg_gap('Power Struggle resolved') /* At this point log card dicarded or permanently removed? */
- if (game.persistent_events.includes(111)) {
+ if (game.persistent_events.includes(MAGIC_NEW_YEARS_EVE_PARTY)) {
game.state = 'new_years_eve_party'
return
}
@@ -1718,7 +1723,7 @@ states.end_turn_4_5_4 = {
game.vp -= 2
log(`Communist receives 2 VP from C97`)
}
- game.persistent_events.push(111)
+ game.persistent_events.push(MAGIC_NEW_YEARS_EVE_PARTY)
if (game.active !== DEM) {
next_player()
}
@@ -1944,38 +1949,38 @@ states.new_years_eve_party = {
east_germany() {
push_undo()
log('Chose to score East Germany')
- game.vm_event = 42
- goto_vm(42)
+ game.vm_event = C_POWER_STRUGGLE_EAST_GERMANY
+ goto_vm(C_POWER_STRUGGLE_EAST_GERMANY)
},
poland() {
push_undo()
log('Chose to score Poland')
- game.vm_event = 22
- goto_vm(22)
+ game.vm_event = C_POWER_STRUGGLE_POLAND
+ goto_vm(C_POWER_STRUGGLE_POLAND)
},
czechoslovakia() {
push_undo()
log('Chose to score Czechoslovakia')
- game.vm_event = 55
- goto_vm(55)
+ game.vm_event = C_POWER_STRUGGLE_CZECHOSLOVAKIA
+ goto_vm(C_POWER_STRUGGLE_CZECHOSLOVAKIA)
},
hungary() {
push_undo()
log('Chose to score Hungary')
- game.vm_event = 23
- goto_vm(23)
+ game.vm_event = C_POWER_STRUGGLE_HUNGARY
+ goto_vm(C_POWER_STRUGGLE_HUNGARY)
},
romania() {
push_undo()
log('Chose to score Romania')
- game.vm_event = 95
- goto_vm(95)
+ game.vm_event = C_POWER_STRUGGLE_ROMANIA
+ goto_vm(C_POWER_STRUGGLE_ROMANIA)
},
bulgaria() {
push_undo()
log('Chose to score Bulgaria')
- game.vm_event = 43
- goto_vm(43)
+ game.vm_event = C_POWER_STRUGGLE_BULGARIA
+ goto_vm(C_POWER_STRUGGLE_BULGARIA)
},
pass() {
push_undo()
@@ -2062,7 +2067,7 @@ states.stasi_confirm = {
gen_action('done')
},
done() {
- game.playable_cards = game.playable_cards.filter( n => n !== C_COMMON_EUROPEAN_HOME)
+ game.playable_cards = game.playable_cards.filter(n => n !== C_COMMON_EUROPEAN_HOME)
end_stasi_choose_card()
}
}
@@ -2132,7 +2137,7 @@ function add_infl(space, ops) {
log_summary(`Added £ SP in %${space}`)
// If AHBR - check AHBR conditions
- if (game.persistent_events.includes(58)) {
+ if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
if (spaces[space].country !== 'East_Germany') {
game.austria_hungary_border_reopened_tracker = false
}
@@ -2173,7 +2178,7 @@ function add_infl(space, ops) {
game.austria_hungary_border_reopened_tracker
) {
game[ops] ++
- log('+1 op from C58')
+ log('+1 op from C' + C_AUSTRIA_HUNGARY_BORDER_REOPENED)
game.austria_hungary_border_reopened_tracker = false
game.valid_spaces = game.valid_spaces.filter(n => spaces[n].country === 'East_Germany')
}
@@ -2184,7 +2189,7 @@ function add_infl(space, ops) {
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)) {
+ if (game.persistent_events.includes(C_GENSCHER) || (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED) && game.austria_hungary_border_reopened_tracker)) {
game.valid_spaces = game.valid_spaces.filter(n => !(check_opp_control(n) && spaces[n].country !== 'East_Germany'))
} else {
game.valid_spaces = game.valid_spaces.filter(n => !check_opp_control(n))
@@ -2402,11 +2407,11 @@ function do_sc(space) {
game.persistent_events.includes(C_HELSINKI_FINAL_ACT) &&
(spaces[space].socio === 5 || spaces[space].socio === 6)
) {
- log('+1 VP from C26')
+ log('+1 VP from C' + C_HELSINKI_FINAL_ACT)
game.vp ++
}
if (game.active === COM && game.persistent_events.includes(C_ECO_GLASNOST) && spaces[space].space_id === S_RUSE) {
- log('+1 VP from C39')
+ log('+1 VP from C' + C_ECO_GLASNOST)
game.vp++
}
@@ -2620,7 +2625,7 @@ function count_adj(space_id) {
}
function check_control(space_id) {
- if ( (game.comInfl[space_id] - game.demInfl[space_id]) >= spaces[space_id].stability) {
+ if ((game.comInfl[space_id] - game.demInfl[space_id]) >= spaces[space_id].stability) {
return true
} else if ((game.demInfl[space_id] - game.comInfl[space_id]) >= spaces[space_id].stability) {
return true
@@ -2683,9 +2688,9 @@ function do_tst_attempt() {
roll++
logi('+1 for playing own card')
}
- if (game.active === COM && game.persistent_events.includes(53)) {
+ if (game.active === COM && game.persistent_events.includes(C_LI_PENG)) {
roll ++
- logi('+1 from C53')
+ logi('+1 from C' + C_LI_PENG)
}
log(`Modified roll: ${roll}`)
@@ -3038,7 +3043,7 @@ function add_to_persistent_events(card) {
}
function permanently_remove(card) {
- game.persistent_events = game.persistent_events.filter( c => c !== card)
+ game.persistent_events = game.persistent_events.filter(c => c !== card)
remove_from_discard(card)
if (!game.strategy_removed.includes(card)) {
game.strategy_removed.push(card)
@@ -3088,8 +3093,8 @@ function end_stasi_choose_card() {
log_h2(`Action Round ${game.round}`)
next_player()
game.valid_spaces = []
- if (game.persistent_events.includes(5)) {
- log_h3('C5')
+ if (game.persistent_events.includes(C_GENERAL_STRIKE)) {
+ log_h3('C' + C_GENERAL_STRIKE)
game.state = 'general_strike'
} else {
game.state = 'choose_card'
@@ -3105,7 +3110,7 @@ function end_goddess() {
} else {
log_side()
}
- if (game.persistent_events.includes(5)) {
+ if (game.persistent_events.includes(C_GENERAL_STRIKE)) {
game.state = 'general_strike'
} else {
game.state = 'choose_card'
@@ -3115,11 +3120,11 @@ function end_goddess() {
function check_reformer() {
/* Is this function still used? */
if (game.dem_tst_position !== game.com_tst_position) {
- if (!game.playable_cards.includes(67)) {
- game.playable_cards.push(67)
+ if (!game.playable_cards.includes(C_REFORMER_REHABILITATED)) {
+ game.playable_cards.push(C_REFORMER_REHABILITATED)
}
} else {
- game.playable_cards = game.playable_cards.filter(n => n !== 67)
+ game.playable_cards = game.playable_cards.filter(n => n !== C_REFORMER_REHABILITATED)
}
}
@@ -3175,7 +3180,6 @@ function check_ligachev_event(card) {
}
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) {
@@ -3255,7 +3259,7 @@ function is_auto_resolve(card) {
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
+ 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) {
if (!game.state.startsWith('vm')) {
logi('No uncontrolled Elite spaces')
@@ -3707,7 +3711,7 @@ function end_round() {
log_h3('Democratic Action Round')
}
if (game.democrat_hand.includes(game.stasi_card)) {
- log_h3('C13')
+ log_h3('C' + C_STASI)
game.state = 'stasi_play_card'
} else {
game.stasi_card = 0
@@ -3738,7 +3742,7 @@ function end_round() {
if (game.active !== DEM) {
next_player()
}
- log_h3('C13')
+ log_h3('C' + C_STASI)
game.state = 'stasi_end_round'
return
} else if (game.round_player === DEM && game.persistent_events.includes(C_GENERAL_STRIKE)) {
@@ -3816,9 +3820,9 @@ function new_turn() {
if (game.turn > 1) {
if (game.persistent_events.includes(C_PRESIDENTIAL_VISIT)) {
game.com_hand_limit = 7
- log('Communist draws 7 cards due to C65')
+ log('Communist draws 7 cards due to C' + C_PRESIDENTIAL_VISIT)
permanently_remove(C_PRESIDENTIAL_VISIT)
- game.persistent_events = game.persistent_events.filter( card => card !== C_PRESIDENTIAL_VISIT)
+ game.persistent_events = game.persistent_events.filter(card => card !== C_PRESIDENTIAL_VISIT)
}
draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.dem_hand_limit, game.com_hand_limit)
game.com_hand_limit = 8
@@ -3847,7 +3851,7 @@ function new_turn() {
} else {
log_h2("Action Round " + game.round)
log_side()
- if (game.persistent_events.includes(5)) {
+ if (game.persistent_events.includes(C_GENERAL_STRIKE)) {
log_h3('C5')
game.state = 'general_strike'
} else {
@@ -4048,7 +4052,7 @@ function reset_power() {
function check_tyrant() {
if (game.the_tyrant_is_gone > 0 && check_dem_control(game.the_tyrant_is_gone)) {
- log('+2 VP from C97')
+ log('+2 VP from C' + C_THE_TYRANT_IS_GONE)
game.vp += 2
if (check_vp()) {
return
@@ -4546,7 +4550,7 @@ function vm_valid_spaces_country_sc() {
active_country = game.vm_active_country
}
valid_spaces_sc()
- game.valid_spaces = game.valid_spaces.filter( s => spaces[s].country === active_country)
+ game.valid_spaces = game.valid_spaces.filter(s => spaces[s].country === active_country)
vm_next()
}
@@ -6262,7 +6266,7 @@ states.vm_ceh_support_check_prep = {
if (game.active === DEM && game.vm_available_ops > 1) {
if (
spaces[game.selected_space].country === 'East_Germany' &&
- game.persistent_events.includes(58) &&
+ game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED) &&
game.active === DEM
) {
game.state = 'vm_austria_hungary_border_reopened_check'
@@ -6886,7 +6890,7 @@ states.vm_goodbye_lenin_ops = {
valid_spaces_infl()
// If ABHR - Set AHBR tracker to true
- if (game.persistent_events.includes(58)) {
+ if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
game.austria_hungary_border_reopened_tracker = true
}
game.state = 'vm_add_infl'