diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 241 |
1 files changed, 82 insertions, 159 deletions
@@ -2209,9 +2209,7 @@ function add_infl(space) { } else { game.demInfl[space]++ } - - // Check whether spaces are controlled - check_control_change(space) + check_tyrant() // Check Austria Hungary Border Reopened is true and condition has been met if (game.available_ops === 0 && game.active === DEM && game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED) && game.austria_hungary_border_reopened_tracker) { @@ -2259,7 +2257,7 @@ function remove_infl(space) { game.valid_spaces = game.valid_spaces.filter(id => id !== space); } } - check_control_change(space) + check_tyrant() } else { if (game.active === COM) { @@ -2273,7 +2271,7 @@ function remove_infl(space) { game.valid_spaces = game.valid_spaces.filter(id => id !== space); } } - check_control_change(space) + check_tyrant() } game.available_ops-- } @@ -2420,7 +2418,7 @@ function do_sc(space) { game.valid_spaces = game.valid_spaces.filter(id => id !== space) } } - check_control_change(space) + check_tyrant() } else { log_msg_gap('Change influence: 0 SP') @@ -3769,31 +3767,24 @@ function reset_power() { game.raised_stakes_round = 0 game.raised_stakes = 0 game.played_power_card = 0 - game.tactics_fails = '' + delete game.tactics_fails game.view_opp_hand = false - if (game.persistent_events.includes(72)){ - permanently_remove(72) - game.table_cards = game.table_cards.filter(card => card !== 72) - game.persistent_events = game.persistent_events.filter(n => n !== 72) - } - if (game.persistent_events.includes(62)) { - permanently_remove(62) - game.table_cards = game.table_cards.filter(card => card !== 62) - game.persistent_events = game.persistent_events.filter(n => n !== 62) - } - if (game.persistent_events.includes(54) && game.pwr_struggle_in === 'Romania'){ - permanently_remove(54) - } - if (game.pwr_struggle_in === 'Romania' && game.persistent_events.includes(C_SECURITATE)){ - game.persistent_events = game.persistent_events.filter(n => n !== C_SECURITATE) + let scoring_events = [C_PEASANT_PARTIES_REVOLT, C_YAKOVLEV_COUNSELS_GORBACHEV, C_THE_CROWD_TURNS_AGAINST_CEAUSESCU, C_SECURITATE] + for (let e of scoring_events ) { + if ( e === C_THE_CROWD_TURNS_AGAINST_CEAUSESCU && game.persistent_events.includes(e) && game.pwr_struggle_in === 'Romania') { + permanently_remove(e) + } else if (e === C_SECURITATE && game.pwr_struggle_in === 'Romania' && game.persistent_events.includes(e)){ + game.persistent_events = game.persistent_events.filter(n => n !== C_SECURITATE) + } else if (game.persistent_events.includes(e)) { + permanently_remove(e) + game.table_cards = game.table_cards.filter(card => card !== e) + game.persistent_events = game.persistent_events.filter(n => n !== e) + } } } -function check_control_change(space_id) { - - // Check if the Tyrant is Gone has been fulfilled - +function check_tyrant() { if (game.the_tyrant_is_gone > 0 && check_dem_control(game.the_tyrant_is_gone)) { log('+2 VP from C97') game.vp += 2 @@ -3805,8 +3796,7 @@ function check_control_change(space_id) { } } -function check_systematization() { - // Check for Systematization - may not use this space +function check_systematization() { /* Check for Systematization - may not use this space */ if (game.systematization > 0) { game.valid_spaces = game.valid_spaces.filter(n => n !== game.systematization) } @@ -4049,17 +4039,6 @@ function vm_operand(a) { return x } -function vm_assert_argcount(n) { - const argcount = CODE[game.vm.fp][game.vm.ip].length - 1 - if (argcount !== n) - throw Error(`ASSERT Invalid number of arguments on event ${game.vm.fp}: ${argcount} instead of ${n}`) -} - -function vm_log() { - log(vm_operand(1)); - vm_next(); -} - function vm_if() { if (!vm_operand(1)) { let balance = 1 @@ -4138,15 +4117,6 @@ function vm_prompt() { vm_next() } -function pop_vm_prompt() { - if (game.vm._prompt) { - game.vm.prompt = game.vm._prompt - delete game.vm._prompt - } else { - game.vm.prompt = 0 - } -} - function vm_return() { //Remove temporary vm variables delete game.support_check_modifier @@ -4190,33 +4160,16 @@ function vm_end_event() { /* ================== VM ACTIONS =========================== */ -function vm_opp_hand_false() { - game.view_opp_hand = false - vm_next() -} - function vm_valid_spaces() { - let space_1 - let space_2 - let space_3 - let space_4 - let space_5 - let space_6 - - if (vm_operand(1)) { space_1 = spaces.find(space => space.ascii_name === vm_operand(1)).space_id} - if (vm_operand(2)) { space_2 = spaces.find(space => space.ascii_name === vm_operand(2)).space_id} - if (vm_operand(3)) { space_3 = spaces.find(space => space.ascii_name === vm_operand(3)).space_id} - if (vm_operand(4)) { space_4 = spaces.find(space => space.ascii_name === vm_operand(4)).space_id} - if (vm_operand(5)) { space_5 = spaces.find(space => space.ascii_name === vm_operand(5)).space_id} - if (vm_operand(6)) { space_6 = spaces.find(space => space.ascii_name === vm_operand(6)).space_id} - - game.valid_spaces = [space_1, space_2, space_3, space_4, space_5, space_6] - game.valid_spaces = game.valid_spaces.filter( n => n ) - - // Check for Systematization - may not use this space - check_systematization() - - vm_next() + for (let i = 1; i <= 6; i++) { + let operand = vm_operand(i) + if (operand) { + let space = spaces.find(space => space.ascii_name === operand) + game.valid_spaces.push(space.space_id) + } + } + check_systematization(); + vm_next(); } function vm_valid_spaces_opponent () { @@ -4244,17 +4197,12 @@ function vm_valid_spaces_socio () { let valid_spaces = [] for (let i = 0; i < spaces.length; i++) { let space = spaces[i] - if (space.socio === vm_operand(1)) { valid_spaces.push(space.space_id) } } game.valid_spaces = valid_spaces - - // Check for Systematization - may not use this space - if (game.systematization && game.systematization > 0) { - game.valid_spaces = game.valid_spaces.filter(n => n !== game.systematization) - } + check_systematization() vm_next() } @@ -4262,7 +4210,6 @@ function vm_valid_spaces_opponent_socio () { 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 && space.socio === vm_operand(1)) { @@ -4276,10 +4223,7 @@ function vm_valid_spaces_opponent_socio () { } } game.valid_spaces = valid_spaces - // Check for Systematization - may not use this space - if (game.systematization && game.systematization > 0) { - game.valid_spaces = game.valid_spaces.filter(n => n !== game.systematization) - } + check_systematization() vm_next() } @@ -4293,10 +4237,7 @@ function vm_valid_spaces_country () { game.valid_spaces.push(space.space_id); } } - // Check for Systematization - may not use this space - if (game.systematization && game.systematization > 0) { - game.valid_spaces = game.valid_spaces.filter(n => n !== game.systematization) - } + check_systematization() vm_next() } @@ -4307,7 +4248,6 @@ function vm_valid_spaces_sc () { function vm_valid_spaces_country_opp () { let country = '' - if (vm_operand(1)) { country = vm_operand(1) } else { @@ -4438,7 +4378,7 @@ function vm_do_add_infl(space) { } // Check Genscher - if (game.persistent_events.includes(63) && game.active === DEM && spaces[space].country === 'East_Germany') { + if (game.persistent_events.includes(C_GENSCHER) && game.active === DEM && spaces[space].country === 'East_Germany') { game.vm_available_ops-- log_summary(`(-1 op due to C63)`) } else if (check_opp_control(space)) { @@ -4457,9 +4397,7 @@ function vm_do_add_infl(space) { } else { game.demInfl[space]++ } - - // Check whether spaces are controlled - check_control_change(space) + check_tyrant() // Check Austria Hungary Border Reopened is true and condition has been met if (game.vm_available_ops === 0 && game.active === DEM && game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED) && game.austria_hungary_border_reopened_tracker) { @@ -4496,16 +4434,13 @@ function vm_do_add_infl(space) { function vm_do_add_infl_free(space) { push_undo() log_summary(`Added £ SP in %${space}.`) - - // Update influence values if (game.active === COM) { game.comInfl[space]++ } else { game.demInfl[space]++ } game.vm_available_ops-- - // Check whether spaces are controlled - check_control_change(space) + check_tyrant() } function vm_add_infl() { @@ -4526,14 +4461,12 @@ function vm_add_x_infl() { function vm_do_add_x_infl(space) { push_undo() log(`Added ${game.vm_available_ops} SPs in %${space}.`) - - if (game.active === COM) { game.comInfl[space] += game.vm_available_ops } else { game.demInfl[space] += game.vm_available_ops } - check_control_change(space) + check_tyrant() game.vm_available_ops = 0 game.valid_spaces = [] } @@ -4568,7 +4501,7 @@ function vm_do_add_limited_infl(space, max_infl) { if (game.vm_influence_added[space] === max_infl) { game.valid_spaces = game.valid_spaces.filter(id => id !== space); } - check_control_change(space) + check_tyrant() if (game.vm_available_ops === 0) {game.valid_spaces = [] } } @@ -4631,7 +4564,7 @@ function vm_do_remove_infl(space) { } } } - check_control_change(space) + check_tyrant() game.vm_influence_added[space]++ game.vm_available_ops-- if (game.vm_available_ops===0) {game.valid_spaces = []} @@ -4675,8 +4608,7 @@ function vm_do_remove_x_infl(space) { } log(`Removed ${game.vm_available_ops} SPs from %${space}`) - check_control_change(space) - + check_tyrant() game.vm_available_ops = 0 game.valid_spaces = [] } @@ -4693,7 +4625,6 @@ function vm_do_remove_limited_infl(space, max_infl) { log(`Removed SP from %${space}.`) game.vm_available_ops -- - if (!game.vm_influence_added) { game.vm_influence_added = {}; } @@ -4720,7 +4651,7 @@ function vm_do_remove_limited_infl(space, max_infl) { game.valid_spaces = game.valid_spaces.filter(id => id !== space); } - check_control_change(space) + check_tyrant() if (game.vm_available_ops === 0) {game.valid_spaces = []} } @@ -4739,7 +4670,7 @@ function vm_do_remove_all_infl(space) { } else { game.comInfl[space] = 0 } - check_control_change(space) + check_tyrant() } else { if (game.active === COM) { @@ -4747,7 +4678,7 @@ function vm_do_remove_all_infl(space) { } else { game.demInfl[space] = 0 } - check_control_change(space) + check_tyrant() } game.vm_available_ops -- game.valid_spaces = game.valid_spaces.filter(id => id !== space) @@ -4761,7 +4692,7 @@ function vm_replace_all_infl(space_id) { game.comInfl[space_id] += game.demInfl[space_id] game.demInfl[space_id] = 0 } - check_control_change(space_id) + check_tyrant() } function vm_1_support_check() { @@ -4781,13 +4712,12 @@ 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}`) game.vm_available_ops = 0 - check_control_change(id) + check_tyrant() } /* ===================== EVENT SPECIFIC FUNCTIONS ========== */ @@ -4819,8 +4749,8 @@ function vm_army_backs_revolution() { } function vm_austria_hungary_border_reopened() { - game.persistent_events.push(58) - permanently_remove(58) + game.persistent_events.push(C_AUSTRIA_HUNGARY_BORDER_REOPENED) + permanently_remove(C_AUSTRIA_HUNGARY_BORDER_REOPENED) game.austria_hungary_border_reopened_tracker = false vm_next() } @@ -4839,7 +4769,7 @@ function vm_breakaway_baltic_republics() { if (check_vp()) { return } - game.playable_cards.push(109) + game.playable_cards.push(C_KREMLIN_COUP) game.playable_cards = game.playable_cards.filter(n => n !== C_GORBACHEV_CHARMS_THE_WEST) 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)) {game.valid_spaces.push(S_RAZGRAD)} @@ -4960,14 +4890,12 @@ function vm_eco_glasnost() { } function vm_elena(){ - game.persistent_events.push(101) + game.persistent_events.push(C_ELENA) vm_next() } -function vm_eliminate(space_id) { +function vm_eliminate(space_id) { // Eliminate the democrat influence and move the communist influence to Bucuresti log(`Eliminated %${space_id}`) - -// Eliminate the democrat influence and move the communist influence to Bucuresti if (space_id === S_BUCURESTI) { game.demInfl[space_id] = 0 game.comInfl[space_id] = 0 @@ -4979,10 +4907,6 @@ function vm_eliminate(space_id) { } game.comInfl[space_id] = 0 } - //Update control in the eliminated space and in Bucuresti - check_control_change(space_id) - check_control_change(S_BUCURESTI) - } function get_adjusted_adjacency(space_id) { @@ -5012,7 +4936,7 @@ function vm_foreign_currency_debt_burden() { if (check_vp()) { return } - game.persistent_events.push(49) + game.persistent_events.push(C_FOREIGN_CURRENCY_DEBT_BURDEN) game.state = 'vm_foreign_currency_debt_burden' } @@ -5026,26 +4950,26 @@ function vm_foreign_television() { vm_next() } function vm_frg_embassies() { - game.persistent_events.push(74) - game.table_cards.push(74) - remove_from_discard(74) - log('C74 in effect') + 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`) vm_next() } function vm_general_strike() { - game.persistent_events.push(5) - game.table_cards.push(5) - remove_from_discard(5) - log('C5 in effect') + 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`) vm_next() } function vm_genscher() { - game.persistent_events.push(63) - game.table_cards.push(63) - remove_from_discard(63) - log(`C63 in effect`) + game.persistent_events.push(C_GENSCHER) + game.table_cards.push(C_GENSCHER) + remove_from_discard(C_GENSCHER) + log(`C${C_GENSCHER} in effect`) vm_next() } @@ -5079,8 +5003,8 @@ function vm_government_resigns() { } function vm_grenztruppen() { - game.persistent_events.push(59) - permanently_remove(59) + game.persistent_events.push(C_GRENZTRUPPEN) + permanently_remove(C_GRENZTRUPPEN) vm_next() } @@ -5102,7 +5026,7 @@ function vm_heal_our_bleeding_wounds() { } function vm_helsinki_final_act() { - game.persistent_events.push(26) + game.persistent_events.push(C_HELSINKI_FINAL_ACT) vm_next() } @@ -5159,11 +5083,11 @@ function vm_kohl_proposes_reunification() { if (check_vp()) { return } - if (game.persistent_events.includes(86)) { - game.vm_event = 87 + if (game.persistent_events.includes(C_THE_WALL_MUST_GO)) { + game.vm_event = C_KOHL_PROPOSES_REUNIFICATION game.state = 'vm_common_european_home_play' } else { - permanently_remove(87) + permanently_remove(C_KOHL_PROPOSES_REUNIFICATION) vm_return() } @@ -5208,13 +5132,13 @@ function vm_legacy_of_1968() { } function vm_li_peng() { - game.persistent_events.push(53) - remove_from_discard(53) + game.persistent_events.push(C_LI_PENG) + remove_from_discard(C_LI_PENG) vm_next() } function vm_ligachev() { - game.persistent_events.push(99) + game.persistent_events.push(C_LIGACHEV) vm_next() } @@ -5240,9 +5164,9 @@ function vm_nagy_reburied(){ } function vm_national_salvation_front() { - game.persistent_events.push(102) - game.table_cards.push(102) - remove_from_discard(102) + game.persistent_events.push(C_NATIONAL_SALVATION_FRONT) + game.table_cards.push(C_NATIONAL_SALVATION_FRONT) + remove_from_discard(C_NATIONAL_SALVATION_FRONT) vm_next() } @@ -5266,10 +5190,10 @@ function vm_normalisation() { } function vm_peasant_parties_revolt() { - game.persistent_events.push(72) - log_msg_gap('C72 in effect') - game.table_cards.push(72) - remove_from_discard(72) + 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) vm_next() } @@ -5307,8 +5231,8 @@ function vm_power_struggle() { } function vm_presidential_visit() { - game.persistent_events.push(65) - log_msg_gap('C65 in effect') + game.persistent_events.push(C_PRESIDENTIAL_VISIT) + log_msg_gap(`C${C_PRESIDENTIAL_VISIT} in effect`) vm_next() } @@ -5332,7 +5256,7 @@ function vm_public_against_violence() { } function vm_reformer_rehabilitated () { - permanently_remove(67) + permanently_remove(C_REFORMER_REHABILITATED) game.discard = true for (let card of game.strategy_discard) { if (!event_is_playable(card)) continue @@ -5439,7 +5363,7 @@ 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('C30 in effect') + log_msg_gap(`C${C_TEAR_GAS} in effect`) vm_next() } @@ -5497,7 +5421,6 @@ function vm_the_tyrant_is_gone() { game.state = 'vm_the_tyrant_is_gone' } - function vm_the_tyrant_is_gone_prep() { game.table_cards.push(C_THE_TYRANT_IS_GONE) remove_from_discard(C_THE_TYRANT_IS_GONE) @@ -5562,7 +5485,7 @@ function vm_workers_revolt() { function vm_yakovlev_counsels_gorbachev() { game.persistent_events.push(C_YAKOVLEV_COUNSELS_GORBACHEV) - log_msg_gap('C62 in effect') + 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) vm_next() |