From 35521c5cf5b70a5ddfa9d420ab0d3235e6fd566d Mon Sep 17 00:00:00 2001 From: iainp5 Date: Tue, 24 Sep 2024 13:38:44 +0100 Subject: Updates to Prudence to allow it to be applied twice --- events.txt | 1 + rules.js | 76 +++++++++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/events.txt b/events.txt index f8ca126..ed50411 100644 --- a/events.txt +++ b/events.txt @@ -810,6 +810,7 @@ permanently_remove CARD 107 - Massacre in Timisoara* # Communist Player makes Support Checks in Romania using the Ops value of this card with +2 drm. Requires play of Lazslo Tokes. +massacre_in_timisoara valid_spaces_country_sc 'Romania' prompt 'Make Support Checks in Romania' support_check_modified 2 2 diff --git a/rules.js b/rules.js index 9e364b1..051167e 100644 --- a/rules.js +++ b/rules.js @@ -83,7 +83,7 @@ exports.setup = function (seed, scenario, options) { discard: false, view_opp_hand: false, strategy_removed: [], - persistent_events: {austria_hungary_border_reopened: false, civic_forum: false, eco_glasnost: false, elena: false, foreign_currency_debt_burden: '', frg_embassies: false, general_strike: false, genscher: false, grenztruppen: false, helsinki_final_act: false, honecker: false, laszlo_tokes: false, li_peng: false, ligachev: false, national_salvation_front: false, perestroika: false, presidential_visit: false, prudence: '', roundtable_talks: false, securitate: false, sinatra_doctrine: false, solidarity_legalised: false, stand_fast: '', stasi: false, st_nicholas_church: false, systematization: 0, tear_gas: false, the_crowd_turns_against_ceausescu: false, the_tyrant_is_gone: 0, the_wall: false, the_wall_must_go: false, we_are_the_people: false, yakovlev: false}, + persistent_events: {austria_hungary_border_reopened: false, civic_forum: false, eco_glasnost: false, elena: false, foreign_currency_debt_burden: '', frg_embassies: false, general_strike: false, genscher: false, grenztruppen: false, helsinki_final_act: false, honecker: false, laszlo_tokes: false, li_peng: false, ligachev: false, national_salvation_front: false, perestroika: false, presidential_visit: false, prudence: {DEM: 0, COM: 0}, roundtable_talks: false, securitate: false, sinatra_doctrine: false, solidarity_legalised: false, stand_fast: '', stasi: false, st_nicholas_church: false, systematization: 0, tear_gas: false, the_crowd_turns_against_ceausescu: false, the_tyrant_is_gone: 0, the_wall: false, the_wall_must_go: false, we_are_the_people: false, yakovlev: false}, power_struggle_deck: [], power_struggle_discard: [], dem_hand_limit: 8, @@ -456,10 +456,23 @@ states.choose_card = { game.available_ops ++ } - if ((game.active === DEM && game.persistent_events['prudence'] === DEM) || (game.active === COM && game.persistent_events['prudence'] === COM)) { + if ((game.active === DEM && game.persistent_events['prudence'].DEM !== 0)) { if (game.available_ops > 1) { - log('-1 op from C8') - game.available_ops -- + log(`${pluralize(game.persistent_events['prudence'].DEM,' op')} from C8`) + game.available_ops += game.persistent_events['prudence'].DEM + if (game.available_ops < 1) { + game.available_ops = 1 + } + } + } + + if (game.active === COM && game.persistent_events['prudence'].COM !== 0) { + if (game.available_ops > 1) { + log(`${pluralize(game.persistent_events['prudence'].DEM,' op')} from C8`) + game.available_ops += game.persistent_events['prudence'].COM + if (game.available_ops < 1) { + game.available_ops = 1 + } } } @@ -2030,8 +2043,12 @@ states.stasi_play_card = { find_card = game.democrat_hand.indexOf(card); const [playedCard] = game.democrat_hand.splice(find_card, 1); game.available_ops = cards[card].ops - if (game.available_ops > 1 && game.persistent_events['prudence'] === DEM) { - game.available_ops-- + if (game.available_ops > 1 && game.persistent_events['prudence'].DEM !== 0) { + log(`${pluralize(game.persistent_events['prudence'].DEM, ' op')} from C8}`) + game.available_ops += game.persistent_events['prudence'].DEM + if (game.available_ops < 1) { + game.available_ops = 1 + } } }, pass () { @@ -2053,7 +2070,7 @@ function add_infl(space) { console.log('adding infl to', space) const clicked_space = find_space_index(space) //console.log('at start, event', game.persistent_events['austria_hungary_border_reopened'], 'ahbr', game.austria_hungary_border_reopened, 'tracker', game.austria_hungary_border_reopened_tracker) - log(`Added 1 influence in %${clicked_space}.`) + log(`Added 1 influence in %${clicked_space}`) if (spaces[clicked_space].country !== 'East_Germany'){ game.austria_hungary_border_reopened_tracker = false @@ -2062,6 +2079,7 @@ function add_infl(space) { // Check Genscher if (game.persistent_events['genscher'] && game.active === DEM && spaces[clicked_space].country === 'East_Germany') { game.available_ops-- + log(`(-1 op due to C63)`) } else if (check_control(clicked_space)) { game.available_ops -= 2 //Check if Austria Hungary Border Reopened was used to place last SP in a controlled space in East Germany. If so, game.available_op will be negative @@ -2193,15 +2211,27 @@ function do_sc(space) { let card_ops = cards[game.played_card].ops // Check for Perestoika if (game.active === COM && game.persistent_events['perestroika']) { + log(`+1 from C25`) card_ops++ } // Check for Sinatra Doctrine if (game.active === DEM && game.persistent_events['sinatra_doctrine']) { + log(`+1 from C50`) card_ops++ } // Check for Prudence - if ((game.active === DEM && game.persistent_events['prudence'] === DEM) || game.active === COM && game.persistent_events['prudence'] === COM) { - card_ops-- + if (game.active === DEM && game.persistent_events['prudence'].DEM !== 0) { + log(`${pluralize(game.persistent_events['prudence'].DEM, ' op')} from C8`) + card_ops += game.persistent_events['prudence'].DEM + } + if (game.active === COM && game.persistent_events['prudence'].COM !== 0) { + log(`${pluralize(game.persistent_events['prudence'].COM, ' op')} from C8`) + card_ops += game.persistent_events['prudence'].COM + } + + //Check card ops is not less than 1 + if (card_ops < 1) { + card_ops = 1 } roll += card_ops log(`+${card_ops} from card ops`) @@ -3153,7 +3183,7 @@ function new_turn() { game.tst_7 = false game.tst_8 = false game.persistent_events['perestroika'] = false - game.persistent_events['prudence'] = '' + game.persistent_events['prudence'] = {DEM: 0, COM: 0} game.persistent_events['sinatra_doctrine'] = false game.persistent_events['stasi'] = false game.persistent_events['honecker'] = false @@ -3480,7 +3510,7 @@ function this_card() { } const pluralize = (count, noun, suffix = 's') => - `${count} ${noun}${count !== 1 ? suffix : ''}` + `${count} ${noun}${Math.abs(count) !== 1 ? suffix : ''}` function clean_name(str) { if (str && str.slice(-1) === '*') { @@ -4782,8 +4812,8 @@ function vm_inflationary_currency_discard() { if (cards[card].ops >= 2) { game.valid_cards.push(card) } - } else if (game.persistent_events['prudence'] === COM ) { - if (cards[card].ops >= 4) { + } else if (game.persistent_events['prudence'].COM !== 0 ) { + if ((cards[card].ops + game.persistent_events['prudence'].COM) >=3 ) { game.valid_cards.push(card) } } else { @@ -4970,8 +5000,8 @@ function vm_presidential_visit() { function vm_prudence() { if (game.active === DEM) { - game.persistent_events['prudence'] = COM - } else {game.persistent_events['prudence'] = DEM} + game.persistent_events['prudence'].COM -- + } else {game.persistent_events['prudence'].DEM --} log_msg_gap('C8 in effect') vm_next() } @@ -6738,17 +6768,20 @@ states.vm_samizdat = { for (let card of game.democrat_hand) { gen_action_card(card) } - gen_action('done') + gen_action('pass') }, card(card) { push_undo() game.samizdat_card = card game.democrat_hand = game.democrat_hand.filter(c => c !== card) log('Set aside a card') + game.state = 'vm_samizdat_finish' }, - done() { - if (game.samizdat_card > 0) {game.state = 'vm_samizdat_finish'} - else {vm_next()} + pass() { + //if (game.samizdat_card > 0) {game.state = 'vm_samizdat_finish'} + /*else { */ + vm_next() + //} } } @@ -7795,7 +7828,7 @@ CODE[35] = [ // Heal our Bleeding Wounds* CODE[36] = [ // Dash for the West* [ vm_permanently_remove ], - [ vm_prompt, 'select any Democratic event with an asterix(*) from the discard pile. Event occurs immediately.'], + [ vm_prompt, 'select any Democratic event with an asterix(*) from the discard pile. Event occurs immediately.' ], [ vm_dash_for_the_west ], [ vm_return ], ] @@ -8345,7 +8378,6 @@ CODE[105] = [ // Public Against Violence* CODE[106] = [ // Social Democratic Platform Adopted* [ vm_social_democratic_platform_adopted ], [ vm_valid_spaces_country ], - [ vm_prompt, ()=>`${country_name(game.vm_active_country)}`], [ vm_add_infl_free, 2 ], [ vm_valid_spaces_country_sc ], [ vm_prompt, ()=>`make a Support Check in ${country_name(game.vm_active_country)}` ], @@ -8355,6 +8387,7 @@ CODE[106] = [ // Social Democratic Platform Adopted* ] CODE[107] = [ // Massacre in Timisoara* + [ vm_massacre_in_timisoara ], [ vm_valid_spaces_country_sc, 'Romania' ], [ vm_prompt, 'Make Support Checks in Romania' ], [ vm_support_check_modified, 2, 2 ], @@ -8391,6 +8424,7 @@ CODE[110] = [ // Malta Summit* + // ============= TIANANMEN SQUARE TRACK AWARDS ==================== CODE[203] = [//Tiananmen Square space 3 award [vm_tst_3], -- cgit v1.2.3