From 8379a9f203f7947f70cfaaa2452bd487569b1955 Mon Sep 17 00:00:00 2001 From: iainp5 Date: Tue, 1 Oct 2024 13:46:28 +0100 Subject: Added game.summary, reduced game object --- rules.js | 391 ++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 272 insertions(+), 119 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index ff590ed..1a3f053 100644 --- a/rules.js +++ b/rules.js @@ -23,7 +23,6 @@ const all_power_cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, const numberless_cards = [25, 26, 27, 28, 29, 30, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52] const auto_resolve_events = [5, 8, 9, 13, 17, 25, 26, 30, 35, 50, 53, 54, 58, 59, 62, 63, 65, 70, 72, 74, 99, 102, 108] const switch_events = [6, 20, 71] -const variable_events = [3, 14, 15, 21, 61, 67, 70, 81, 84, 96, 97, 107, 109] exports.scenarios = [ "Standard" ] @@ -36,6 +35,7 @@ exports.setup = function (seed, scenario, options) { seed: seed, log: [], undo: [], + summary: [], active: null, state: "com_init", return: '', @@ -72,7 +72,6 @@ exports.setup = function (seed, scenario, options) { com_tst_attempted: 0, dem_tst_attempted_this_turn: 0, com_tst_attempted_this_turn:0, - tst_success: false, tst_7: false, tst_8: false, vp: 0, @@ -105,11 +104,10 @@ exports.setup = function (seed, scenario, options) { raised_stakes: 0, raised_stakes_round: 0, phase: 0, - times_held: {'East_Germany': 0, 'Poland': 0, 'Czechoslovakia': 0, 'Hungary': 0, 'Romania': 0, 'Bulgaria': 0}, - revolutions: {'East_Germany': false, 'Poland': false, 'Czechoslovakia': false, 'Hungary': false, 'Romania': false, 'Bulgaria': false}, + times_held: [0, 0, 0, 0, 0, 0], + revolutions: [false, false, false, false, false, false], remove_opponent_infl: false, tactics_fails: '', - warsaw_pact_summit: false, } log_h1("1989 Dawn of Freedom") @@ -137,9 +135,9 @@ function start_game() { } }) - // Set cards were event playable status changes during the game + // Set variable event cards where event is playable at start of game - game.playable_cards = [false, true, true, true, false, '', true, false, false, false, false, false, false ] + game.playable_cards = [14, 15, 21, 70] //console.log('game.strategy_deck: ', game.strategy_deck[1]) draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.dem_hand_limit, game.com_hand_limit) @@ -326,12 +324,17 @@ states.com_init = { } }, infl(space) { - add_infl(space) }, done() { view.prompt='Influence added.' + + if (game.summary.length > 0) { + pop_summary() + log_br() + } + game.starting_infl.com_starting_infl++ if (game.starting_infl.com_starting_infl == 1){ game.available_ops = 3 @@ -344,6 +347,7 @@ states.com_init = { valid_spaces_setup() next_player() } else if (game.starting_infl.com_starting_infl == 3) { + delete game.starting_infl game.state = 'start_game' } } @@ -370,7 +374,13 @@ states.dem_init = { }, done() { - view.prompt='Influence added' + view.prompt='Influence added.' + + if (game.summary.length > 0) { + pop_summary() + log_br() + } + game.starting_infl.dem_starting_infl++ if (game.starting_infl.dem_starting_infl == 1){ game.available_ops = 3 @@ -486,11 +496,11 @@ states.play_card ={ //console.log('game.active', game.active, 'game.playable_cards[67].playable', game.playable_cards[67].playable) - if (game.played_card === 67){ - if (game.active === DEM && game.playable_cards[find_event(67)] === DEM) { + if (game.played_card === 67 && game.playable_cards.includes(67)){ + if (game.active === DEM && (game.dem_tst_position > game.com_tst_position)) { gen_action('event') } - if (game.active === COM && game.playable_cards[find_event(67)] === COM) { + if (game.active === COM && (game.dem_tst_position < game.com_tst_position)) { gen_action('event') } } @@ -499,13 +509,13 @@ states.play_card ={ //Check if it is a card with an event which is always playable - if (!variable_events.includes(game.played_card)) { + if (cards[game.played_card].playable) { get_events(game.played_card) } // Resolve cards with variable events - if (variable_events.includes(game.played_card) && game.playable_cards[find_event(game.played_card)]) { + if (game.playable_cards.includes(game.played_card)) { get_events(game.played_card) } /* if ((game.active === DEM && cards[game.played_card].side === 'D' && game.playable_cards[game.played_card].playable === 1) || (game.active === COM && cards[game.played_card].side === 'C' && game.playable_cards[game.played_card].playable ===1) || (cards[game.played_card].side === 'N'&& game.playable_cards[game.played_card].playable ===1)) { @@ -566,7 +576,7 @@ states.play_card ={ } // Check if card is opponent card with event that needs to be resolved - if (!variable_events.includes(game.played_card)|| game.playable_cards[find_event(game.played_card)]) { + if (cards[game.played_card].playable || game.playable_cards.includes(game.played_card)) { if ((game.active === DEM && cards[game.played_card].side === "C" ) || (game.active === COM && cards[game.played_card].side === "D")) { //game.phase = 1 /*Do I need this? */ game.vm_event_to_do = true @@ -592,7 +602,7 @@ states.play_card ={ game.vm_event_to_do = true }*/ - if (!variable_events.includes(game.played_card)|| game.playable_cards[find_event(game.played_card)]) { + if (cards[game.played_card].playable || game.playable_cards.includes(game.played_card)) { if ((game.active === DEM && cards[game.played_card].side === "C" ) || (game.active === COM && cards[game.played_card].side === "D")) { game.vm_event_to_do = true } @@ -703,6 +713,11 @@ states.finish_add_infl = { add_infl(space) }, done() { + if (game.summary.length > 0) { + pop_summary() + log_br() + } + end_round() } } @@ -794,6 +809,11 @@ states.add_influence = { add_infl(space) }, done() { + if (game.summary.length > 0) { + pop_summary() + log_br() + } + if(game.vm_event_to_do) { reset_austria_hungary_border_reopened() game.state = 'resolve_opponent_event'} @@ -805,24 +825,33 @@ states.add_influence = { states.tiananmen_square_attempt = { inactive: 'do Tiananmen Square Attempt.', prompt () { - if ((game.active === DEM && game.dem_tst_attempted_this_turn > 0 )|| (game.active === COM && game.com_tst_attempted_this_turn > 0)) { - if (game.tst_success) { - view.prompt = 'Tiananmen Square Track attempt successful.' - } else { - view.prompt = 'Tiananmen Square Track attempt failed.' - } - gen_action('done') - return - } view.prompt = 'Tiananmen Square Track attempt: Roll a die.' gen_action('roll') }, roll() { clear_undo() do_tst_attempt () + } +} + +states.tiananmen_square_attempt_success = { + inactive: 'do Tiananmen Square Attempt.', + prompt () { + view.prompt = 'Tiananmen Square Track attempt successful.' + gen_action('done') + }, + done () { + end_round() + } +} + +states.tiananmen_square_attempt_fail = { + inactive: 'do Tiananmen Square Attempt.', + prompt () { + view.prompt = 'Tiananmen Square Track attempt failed.' + gen_action('done') }, done () { - game.tst_success = false end_round() } } @@ -1118,6 +1147,11 @@ states.the_crowd_turns_against_ceausescu_infl = { vm_do_add_infl(space) }, done() { + if (game.summary.length > 0) { + pop_summary() + log_br() + } + if (game.return !== game.active) { next_player() } @@ -1484,6 +1518,10 @@ states.support_loss ={ } }, done () { + if (game.summary.length > 0) { + pop_summary() + log_br() + } next_player() log_h3('Victory Point') game.phase = 0 @@ -1715,9 +1753,9 @@ states.final_scoring_held = { }, bonus() { console.log('game.revolutions: ', game.revolutions) - const held_countries = Object.values(game.revolutions).filter(value => value === false).length + const held_countries = game.revolutions.filter(value => value === false).length let vp_gain = 4*held_countries - log(`Communist holds ${held_countries} countries: gains ${vp_gain} VP`) + log(`Communist holds ${held_countries} countries: -${vp_gain} VP`) game.vp -= 4*held_countries game.temp = {'East_Germany': false, 'Poland': false, 'Czechoslovakia': false, 'Hungary': false, 'Romania': false, 'Bulgaria': false} game.state = 'final_scoring' @@ -1875,17 +1913,17 @@ states.honecker ={ states.new_years_eve_party = { get inactive() { - return `resolve ${cards[104].name}.` + return `resolve ${clean_name(cards[104].name)}.` }, prompt() { if (!game.is_pwr_struggle) { view.prompt = `New Year's Eve Party: you may choose a country to have a final power struggle.` - if (!game.revolutions['East_Germany']) {gen_action('east_germany')} - if (!game.revolutions['Poland']) {gen_action('poland')} - if (!game.revolutions['Czechoslovakia']) {gen_action('czechoslovakia')} - if (!game.revolutions['Hungary']) {gen_action('hungary')} - if (!game.revolutions['Romania']) {gen_action('romania')} - if (!game.revolutions['Bulgaria']) {gen_action('bulgaria')} + if (!game.revolutions[0]) {gen_action('poland')} + if (!game.revolutions[1]) {gen_action('hungary')} + if (!game.revolutions[2]) {gen_action('east_germany')} + if (!game.revolutions[3]) {gen_action('bulgaria')} + if (!game.revolutions[4]) {gen_action('czechoslovakia')} + if (!game.revolutions[5]) {gen_action('romania')} gen_action('pass') } else { view.prompt = `New Year's Eve Party: done.` @@ -1998,7 +2036,7 @@ states.stasi_confirm = { } }, done() { - game.playable_cards[find_event(21)] = false + game.playable_cards = game.playable_cards.filter( n => n !== 21) end_stasi_choose_card() } } @@ -2100,7 +2138,8 @@ function add_infl(space) { const clicked_space = find_space_index(space) console.log('clicked_space', clicked_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}`) + log_summary(`Added £ influence in %${clicked_space}`) if (spaces[clicked_space].country !== 'East_Germany'){ game.austria_hungary_border_reopened_tracker = false @@ -2167,7 +2206,8 @@ function add_infl(space) { function remove_infl(space) { push_undo() const clicked_space = find_space_index(space) - log(`Removed 1 influence from %${clicked_space}.`) + //log(`Removed 1 influence from %${clicked_space}.`) + log_summary(`Removed £ influence from %${clicked_space}.`) if (game.remove_opponent_infl === true) { if (game.active === COM) { @@ -2769,23 +2809,26 @@ function do_tst_attempt() { game.dem_tst_position++ game.dem_tst_attempted = 0 if (game.dem_tst_position === 3 && game.com_tst_position < 3) {goto_vm(203)} - if (game.dem_tst_position === 4 && game.com_tst_position < 4) {goto_vm(204)} + if (game.dem_tst_position === 4 && game.com_tst_position < 4) {goto_vm(204)} + game.state = 'tiananmen_square_attempt_success' } else { log(`${dem_tst_req[game.dem_tst_position]} required: fail`) game.dem_tst_attempted = 1 + game.state = 'tiananmen_square_attempt_fail' } } else { game.com_tst_attempted_this_turn = 1 if (roll >= com_tst_req[game.com_tst_position]) { log(`${com_tst_req[game.com_tst_position]} required: success`) - game.tst_success = true game.com_tst_position++ game.com_tst_attempted = 0 if (game.com_tst_position === 3 && game.dem_tst_position < 3) {goto_vm(203)} if (game.com_tst_position === 4 && game.dem_tst_position < 4) {goto_vm(204)} + game.state = 'tiananmen_square_attempt_success' } else { log(`${com_tst_req[game.com_tst_position]} required: fail`) game.com_tst_attempted = 1 + game.state = 'tiananmen_square_attempt_fail' } } } @@ -2863,14 +2906,14 @@ function battlegrounds(country) { function take_power(country) { log(`Democrat takes power in ${game.pwr_struggle_in}`) - game.revolutions[country] = true - game.times_held[country] = 1 + game.revolutions[find_country_index(country)] = true + game.times_held[find_country_index(country)] = 1 } function retain_power(country){ - game.times_held[country]++ - let vp_gain = get_value(country)*game.times_held[country] + game.times_held[find_country_index(country)]++ + let vp_gain = get_value(country)*game.times_held[find_country_index(country)] log(`Chooses to retain power`) log(`-${vp_gain} VP`) game.vp -= vp_gain @@ -3088,10 +3131,10 @@ function end_stasi_choose_card() { } function check_reformer() { - console.log('reformer check, dem pos:', game.dem_tst_position, 'com:', game.com_tst_position) + /*console.log('reformer check, dem pos:', game.dem_tst_position, 'com:', game.com_tst_position) if (game.dem_tst_position > game.com_tst_position) { console.log('reformer set to DEM') - game.playable_cards[find_event(67)] = DEM + //game.playable_cards[find_event(67)] = DEM } if (game.dem_tst_position < game.com_tst_position) { //console.log('reformer set to COM') @@ -3104,7 +3147,7 @@ function check_reformer() { //console.log(`reformer set to ''`) game.playable_cards[find_event(67)] = '' } - //console.log('game.playable_cards[67].playable', game.playable_cards[67].playable) + //console.log('game.playable_cards[67].playable', game.playable_cards[67].playable) */ } function count_scoring_cards() { @@ -3233,7 +3276,8 @@ function end_round() { game.return = '' game.valid_cards = [] game.valid_spaces = [] - game.playable_cards[find_event(21)] = true + check_common_european_home() + //game.playable_cards[find_event(21)] = true reset_austria_hungary_border_reopened() /*This should be redundant! */ @@ -3548,6 +3592,10 @@ function find_space_index(name_unique) { return spaces.findIndex(space => space && space.name_unique === name_unique) } +function find_country_index(country) { + return countries.indexOf(country) +} + function draw_deck(deck) { return deck.filter(card => card && card.period === 1).map(card => card.number) } @@ -3753,6 +3801,12 @@ function check_systematization() { } } +function check_common_european_home() { + if (!game.playable_cards.includes(21)) { + game.playable_cards.push(21) + } +} + function this_card() { return game.vm_event > 0 ? game.vm_event : game.played_card } @@ -3801,7 +3855,7 @@ function country_name(country) { return country.replace(/_/g, ' ') } -// ======== LOG COMMANDS ============= +// ======== LOG FUNCTIONS ============= function log(msg) { game.log.push(msg) @@ -3857,6 +3911,58 @@ function log_sep() { log(".hr") } +function log_action(msg) { + log_br() + log(msg) +} + +// ============= SUMMARY FUNCTIONS ============= + +function push_summary() { + if (game.summary) + throw "TOO MANY SUMMARIES" + game.summary = [] +} + +function log_summary(msg) { + for (let item of game.summary) { + if (item[1] === msg) { + item[0]++ + return + } + } + game.summary.push([1, msg]) +} + +function pop_summary() { + if (game.summary.length > 0) { + for (let [n, msg] of game.summary) { + log(msg.replace("£", String(n))) + } + } + game.summary = [] +} + +function log_summary_place(p) { + let from = piece_space(p) + if (from !== AVAILABLE) + log_summary("% " + piece_name(p) + " from S" + from) + else + log_summary("% " + piece_name(p)) +} + +function log_summary_move_to_from(p, to) { + log_summary("% " + piece_name(p) + " to S" + to + " from S" + piece_space(p)) +} + +function log_summary_remove(p) { + log_summary("Removed % " + piece_name(p)) +} + +function log_summary_activated(p) { + log_summary("Activated % " + piece_faction_name(p)) +} + // ============ UNDO FUNCTIONS ================== function clear_undo() { @@ -4370,8 +4476,10 @@ function vm_do_add_infl(space) { console.log('in vm_do_add_infl, space', 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}.`) + log_summary(`Added £ influence in %${clicked_space}.`) + if (spaces[clicked_space].country !== 'East_Germany'){ game.austria_hungary_border_reopened_tracker = false } @@ -4435,7 +4543,9 @@ function vm_do_add_infl(space) { function vm_do_add_infl_free(space) { push_undo() const clicked_space = find_space_index(space) - log(`Added 1 influence in %${clicked_space}.`) + //log(`Added 1 influence in %${clicked_space}.`) + + log_summary(`Added £ influence in %${clicked_space}.`) // Update influence values if (game.active === COM) { @@ -4491,7 +4601,9 @@ function vm_add_limited_infl() { function vm_do_add_limited_infl(space, max_infl) { push_undo() const clicked_space = find_space_index(space) - log(`Added 1 influence in %${clicked_space}.`) + //log(`Added 1 influence in %${clicked_space}.`) + + log_summary(`Added £ influence in %${clicked_space}.`) game.vm_available_ops -- if (!game.vm_influence_added) { @@ -4539,8 +4651,8 @@ function vm_remove_x_opp_infl() { function vm_do_remove_infl(space) { push_undo() const clicked_space = find_space_index(space) - log(`Removed 1 influence from %${clicked_space}.`) - + //log(`Removed 1 influence from %${clicked_space}.`) + log_summary(`Removed £ influence from %${clicked_space}.`) if (!game.vm_influence_added) { game.vm_influence_added = {}; @@ -4764,7 +4876,7 @@ function vm_army_backs_revolution() { permanently_remove(70) }*/ delete game.persistent_events['securitate'] - game.playable_cards[find_event(70)] = false + game.playable_cards = game.playable_cards.filter(n => n !== 70) /*if (game.table_cards.includes(70)) { permanently_remove(70) }*/ @@ -4793,8 +4905,8 @@ function vm_breakaway_baltic_republics() { if (check_vp()) { return } - game.playable_cards[find_event(109)] = true - game.playable_cards[find_event(14)] = false + game.playable_cards.push(109) + game.playable_cards = game.playable_cards.filter(n => n !== 14) if (!check_dem_control(56) && game.persistent_events['systematization'] !== 56) {game.valid_spaces.push(56)} if (!check_dem_control(70)) {game.valid_spaces.push(70)} vm_next() @@ -4878,7 +4990,7 @@ function vm_common_european_home() { function vm_dash_for_the_west() { game.valid_cards = [] for (let c of game.strategy_discard) { - if (cards[c].side === 'D' && cards[c].remove === 1 && (!variable_events.includes(c) || game.playable_cards[find_event(c)])) { + if (cards[c].side === 'D' && cards[c].remove === 1 && (cards[c].playable || game.playable_cards.includes(c))) { game.valid_cards.push(c) } } @@ -5055,7 +5167,7 @@ function vm_goodbye_lenin() { } //Check if these cards are playabl for (let card of game.communist_hand_red) { - if (!variable_events.includes(card) || game.playable_cards[find_event(card)]) { + if (cards[card].playable || game.playable_cards.includes(card)) { game.valid_cards.push(card) } } @@ -5175,7 +5287,7 @@ function vm_kremlin_coup() { //revolutions: {'East_Germany': false, 'Poland': false, 'Czechoslovakia': false, 'Hungary': false, 'Romania': false, 'Bulgaria': false} game.temp = [] countries.forEach(country => { - if (!game.revolutions[country]) { + if (!game.revolutions[find_country_index(country)]) { game.temp.push(country) } }) @@ -5185,7 +5297,7 @@ function vm_kremlin_coup() { function vm_laszlo_tokes() { game.persistent_events['laszlo_tokes'] = true - game.playable_cards[find_event(107)] = true + game.playable_cards.push(107) game.state = 'vm_laszlo_tokes' } @@ -5226,7 +5338,7 @@ function vm_massacre_in_timisoara() { } function vm_modrow() { - game.playable_cards[find_event(15)] = false + game.playable_cards.push(15) game.state = 'vm_modrow' } @@ -5375,7 +5487,7 @@ function vm_sajudis_check() { } function vm_sajudis() { - game.playable_cards[find_event(81)] = true + game.playable_cards.push(81) game.stability++ log('+1 VP') game.vp++ @@ -5406,14 +5518,14 @@ function vm_social_democratic_platform_adopted() { function vm_solidarity_legalised() { log_msg_gap(`C2 in effect`) - game.playable_cards[find_event(3)] = true + game.playable_cards.push(3) game.persistent_events['solidarity_legalised'] = true vm_next() } function vm_st_nicholas_church () { game.persistent_events['st_nicholas_church'] = true - game.playable_cards[find_event(61)] = true + game.playable_cards.push(61) permanently_remove(24) vm_next() } @@ -5456,7 +5568,7 @@ function vm_tear_gas () { } function vm_the_baltic_way() { - game.playable_cards[find_event(84)] =true + game.playable_cards.push(84) game.stability++ if (!check_dem_control(56) && game.persistent_events['systematization'] !== 56) {game.valid_spaces.push(56)} if (!check_dem_control(70) && game.persistent_events['systematization'] !== 70) {game.valid_spaces.push(70)} @@ -5477,7 +5589,7 @@ function vm_the_crowd_turns_against_ceausescu() { //game.persistent_events['the_crowd_turns_against_ceausescu'] = true game.table_cards.push(54) remove_from_discard(54) - game.playable_cards[find_event(97)] = true + game.playable_cards.push(97) vm_next() } @@ -5557,7 +5669,7 @@ function vm_workers_revolt() { for (let space of spaces) { if (!space) continue let country = space.country - if (!game.revolutions[`${country}`] && game.comInfl[space.space_id] > 0 && space.socio === 4) { + if (!game.revolutions[find_country_index(country)] && game.comInfl[space.space_id] > 0 && space.socio === 4) { game.valid_spaces.push(space.space_id); } } @@ -5565,7 +5677,7 @@ function vm_workers_revolt() { for (let space of spaces) { if (!space) continue let country = space.country - if (game.revolutions[`${country}`] && game.demInfl[space.space_id] > 0 && space.socio === 4) { + if (game.revolutions[find_country_index(country)] && game.demInfl[space.space_id] > 0 && space.socio === 4) { game.valid_spaces.push(space.space_id); } } @@ -5700,6 +5812,11 @@ states.vm_add_infl = { vm_do_add_infl(space) }, done () { + if (game.summary.length > 0) { + pop_summary() + log_br() + } + game.vm_event_done = true vm_next() } @@ -5730,13 +5847,17 @@ states.vm_add_infl_free = { if (game.vm_available_ops === 0 ) { game.valid_spaces = [] game.vm_event_done = true + if (game.summary.length > 0) { + pop_summary() + log_br() + } vm_next() } }, - done () { + /*done () { game.vm_event_done = true vm_next() - } + }*/ } states.vm_add_x_infl = { @@ -5782,22 +5903,30 @@ states.vm_add_limited_infl = { for (let space_id of game.valid_spaces) { gen_action_infl(spaces[space_id].name_unique); } - } /*else { + } else { view.prompt = `${clean_name(cards[this_card()].name)}: done.` gen_action('done') - }*/ + } }, infl(space) { vm_do_add_limited_infl(space, game.vm_max_infl) - if (game.vm_available_ops === 0 || game.valid_spaces.length === 0) { + /*if (game.vm_available_ops === 0 || game.valid_spaces.length === 0) { game.vm_event_done = true + if (game.summary.length > 0) { + pop_summary() + log_br() + } vm_next() - } + }*/ }, - /*done () { + done () { + if (game.summary.length > 0) { + pop_summary() + log_br() + } game.vm_event_done = true vm_next() - }*/ + } } states.vm_remove_infl = { @@ -5834,6 +5963,10 @@ states.vm_remove_infl = { }*/ }, done() { + if (game.summary.length > 0) { + pop_summary() + log_br() + } vm_next() } } @@ -5888,6 +6021,10 @@ states.vm_remove_limited_infl = { vm_do_remove_limited_infl(space, game.vm_max_infl) if (game.vm_available_ops === 0) { game.vm_event_done = true + if (game.summary.length > 0) { + pop_summary() + log_br() + } vm_next() } }, @@ -6061,7 +6198,7 @@ states.vm_tiananmen_square_attempt = { states.vm_adamec = { get inactive() { - return `resolve ${cards[88].name}.` + return `resolve ${clean_name(cards[88].name)}.` }, prompt() { view.prompt = 'Adamec: roll a die.' @@ -6105,7 +6242,7 @@ states.vm_brought_in_for_questioning = { discard() { game.vm_event = discard_card(game.democrat_hand) game.phase = 1 - if (cards[game.vm_event].side === 'C' && (!variable_events.includes(game.event) || game.playable_cards[find_event(game.vm_event)])) { + if (cards[game.vm_event].side === 'C' && (cards[game.vm_event].playable || game.playable_cards.includes(game.vm_event))) { //game.return = game.active if (!auto_resolve_events.includes(game.vm_event) && !switch_events.includes(game.vm_event)) { next_player() @@ -6126,16 +6263,16 @@ states.vm_brought_in_for_questioning = { states.vm_central_committee_reshuffle = { get inactive() { - return `resolve ${cards[57].name}.` + return `resolve ${clean_name(cards[57].name)}.` }, prompt() { view.prompt = 'Choose a country to add SP.' - if (!game.revolutions['East_Germany']) {gen_action('east_germany')} - if (!game.revolutions['Poland']) {gen_action('poland')} - if (!game.revolutions['Czechoslovakia']) {gen_action('czechoslovakia')} - if (!game.revolutions['Hungary']) {gen_action('hungary')} - if (!game.revolutions['Romania']) {gen_action('romania')} - if (!game.revolutions['Bulgaria']) {gen_action('bulgaria')} + if (!game.revolutions[0]) {gen_action('poland')} + if (!game.revolutions[1]) {gen_action('hungary')} + if (!game.revolutions[2]) {gen_action('east_germany')} + if (!game.revolutions[3]) {gen_action('bulgaria')} + if (!game.revolutions[4]) {gen_action('czechoslovakia')} + if (!game.revolutions[5]) {gen_action('romania')} }, east_germany() { game.vm_active_country = "East_Germany" @@ -6225,11 +6362,11 @@ states.vm_common_european_home = { states.vm_dash_for_the_west = { get inactive() { - return `resolve ${cards[36].name}.` + return `resolve ${clean_name(cards[36].name)}.` }, prompt() { if (game.phase === 1) { - view.prompt = 'Dash for The West: roll a die' + view.prompt = 'Dash for the West: roll a die' gen_action('roll') } else { view.prompt = 'Dash for the West: roll a die. Done.' @@ -6338,7 +6475,7 @@ states.vm_deutsche_marks = { return `resolve ${cards[20].name}.` }, prompt() { - if(cards[game.vm_event].side === 'C' && (!variable_events.includes(game.vm_event) || game.playable_cards[find_event(game.vm_event)])) { + if(cards[game.vm_event].side === 'C' && (cards[game.vm_event].playable || game.playable_cards.includes(game.vm_event))) { view.prompt = `Deutsche Marks: you must play ${clean_name(cards[this_card()].name)} for the event.` gen_action('event') } else { @@ -6585,19 +6722,19 @@ states.vm_inflationary_currency = { prompt() { view.prompt = 'Inflationary Currency: choose a country where your opponent has power.' if (game.active === DEM) { - if (!game.revolutions['East_Germany']) {gen_action('east_germany')} - if (!game.revolutions['Poland']) {gen_action('poland')} - if (!game.revolutions['Czechoslovakia']) {gen_action('czechoslovakia')} - if (!game.revolutions['Hungary']) {gen_action('hungary')} - if (!game.revolutions['Romania']) {gen_action('romania')} - if (!game.revolutions['Bulgaria']) {gen_action('bulgaria')} + if (!game.revolutions[0]) {gen_action('poland')} + if (!game.revolutions[1]) {gen_action('hungary')} + if (!game.revolutions[2]) {gen_action('east_germany')} + if (!game.revolutions[3]) {gen_action('bulgaria')} + if (!game.revolutions[4]) {gen_action('czechoslovakia')} + if (!game.revolutions[5]) {gen_action('romania')} } else { - if (game.revolutions['East_Germany']) {gen_action('east_germany')} - if (game.revolutions['Poland']) {gen_action('poland')} - if (game.revolutions['Czechoslovakia']) {gen_action('czechoslovakia')} - if (game.revolutions['Hungary']) {gen_action('hungary')} - if (game.revolutions['Romania']) {gen_action('romania')} - if (game.revolutions['Bulgaria']) {gen_action('bulgaria')} + if (game.revolutions[0]) {gen_action('poland')} + if (game.revolutions[1]) {gen_action('hungary')} + if (game.revolutions[2]) {gen_action('east_germany')} + if (game.revolutions[3]) {gen_action('bulgaria')} + if (game.revolutions[4]) {gen_action('czechoslovakia')} + if (game.revolutions[5]) {gen_action('romania')} } }, east_germany() { @@ -7150,6 +7287,10 @@ states.vm_nomenklatura_add = { if (game.vm_available_ops === 0 ) {game.valid_spaces = []} }, done() { + if (game.summary.length > 0) { + pop_summary() + log_br() + } vm_next() } } @@ -7211,12 +7352,12 @@ states.vm_shock_therapy = { prompt() { if (game.vm_active_country === '' ) { view.prompt = 'Shock Therapy: choose a country where you hold Power:' - if (game.revolutions['East_Germany']) {gen_action('east_germany')} - if (game.revolutions['Poland']) {gen_action('poland')} - if (game.revolutions['Czechoslovakia']) {gen_action('czechoslovakia')} - if (game.revolutions['Hungary']) {gen_action('hungary')} - if (game.revolutions['Romania']) {gen_action('romania')} - if (game.revolutions['Bulgaria']) {gen_action('bulgaria')} + if (game.revolutions[0]) {gen_action('poland')} + if (game.revolutions[1]) {gen_action('hungary')} + if (game.revolutions[2]) {gen_action('east_germany')} + if (game.revolutions[3]) {gen_action('bulgaria')} + if (game.revolutions[4]) {gen_action('czechoslovakia')} + if (game.revolutions[5]) {gen_action('romania')} } else if (game.phase === 2) { view.prompt = 'Shock Therapy: done.' gen_action('done') @@ -7287,12 +7428,12 @@ states.vm_social_democratic_platform_adopted = { }, prompt() { view.prompt = 'Select a country where the Democrat holds Power.' - if (game.revolutions['East_Germany']) {gen_action('east_germany')} - if (game.revolutions['Poland']) {gen_action('poland')} - if (game.revolutions['Czechoslovakia']) {gen_action('czechoslovakia')} - if (game.revolutions['Hungary']) {gen_action('hungary')} - if (game.revolutions['Romania']) {gen_action('romania')} - if (game.revolutions['Bulgaria']) {gen_action('bulgaria')} + if (game.revolutions[0]) {gen_action('poland')} + if (game.revolutions[1]) {gen_action('hungary')} + if (game.revolutions[2]) {gen_action('east_germany')} + if (game.revolutions[3]) {gen_action('bulgaria')} + if (game.revolutions[4]) {gen_action('czechoslovakia')} + if (game.revolutions[5]) {gen_action('romania')} }, east_germany() { push_undo() @@ -7362,12 +7503,12 @@ states.vm_the_chinese_solution = { }, prompt() { view.prompt = 'You may give up 3 VP to conduct support checks in a country where you hold power.' - if (!game.revolutions['East_Germany']) {gen_action('east_germany')} - if (!game.revolutions['Poland']) {gen_action('poland')} - if (!game.revolutions['Czechoslovakia']) {gen_action('czechoslovakia')} - if (!game.revolutions['Hungary']) {gen_action('hungary')} - if (!game.revolutions['Romania']) {gen_action('romania')} - if (!game.revolutions['Bulgaria']) {gen_action('bulgaria')} + if (!game.revolutions[0]) {gen_action('poland')} + if (!game.revolutions[1]) {gen_action('hungary')} + if (!game.revolutions[2]) {gen_action('east_germany')} + if (!game.revolutions[3]) {gen_action('bulgaria')} + if (!game.revolutions[4]) {gen_action('czechoslovakia')} + if (!game.revolutions[5]) {gen_action('romania')} gen_action('pass') }, east_germany() { @@ -7619,6 +7760,10 @@ states.vm_we_are_the_people_remove = { vm_do_remove_infl(space) }, done() { + if (game.summary.length > 0) { + pop_summary() + log_br() + } if (!game.vm_influence_added[6]) { log('No influence removed') vm_next() @@ -7652,6 +7797,10 @@ states.vm_we_are_the_people_add = { if (game.vm_influence_added[6] === 0 ) {game.valid_spaces = []} }, done() { + if (game.summary.length > 0) { + pop_summary() + log_br() + } vm_next() } } @@ -7779,6 +7928,10 @@ states.vm_tst_4 = { vm_do_remove_infl(space) }, done() { + if (game.summary.length > 0) { + pop_summary() + log_br() + } vm_next() } } -- cgit v1.2.3