diff options
author | iainp5 <iain.pearce.ip@gmail.com> | 2024-10-27 10:32:20 +0000 |
---|---|---|
committer | iainp5 <iain.pearce.ip@gmail.com> | 2024-10-27 10:32:20 +0000 |
commit | 1830a7a920ffb4ebb3fcc04f957352b5386b0f84 (patch) | |
tree | eff74ef283d5ec7340a2e3054ac753687e984b7b | |
parent | 2f4c6fd75e33d534e76bf6c03f0352157f026c36 (diff) | |
download | 1989-dawn-of-freedom-1830a7a920ffb4ebb3fcc04f957352b5386b0f84.tar.gz |
Tidying up code
-rw-r--r-- | rules.js | 984 |
1 files changed, 105 insertions, 879 deletions
@@ -208,6 +208,7 @@ const C_MALTA_SUMMIT = 110 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] +const C_TACTICS_FAILS = 52 const leader_cards = [37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48] const wildcards = [49, 50, 51, 52] const elite_leaders = [37, 38, 39, 40] @@ -337,9 +338,7 @@ function start_game() { game.playable_cards = [C_GORBACHEV_CHARMS_THE_WEST, C_HONECKER, C_COMMON_EUROPEAN_HOME, C_SECURITATE] - //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) - //.log('game.strategy_deck: ', game.strategy_deck[1], 'democrat_hand:', game.democrat_hand) game.valid_spaces = valid_spaces_setup() game.available_ops = 2 @@ -475,18 +474,14 @@ exports.view = function(state, player) { // === ACTIONS =========== function gen_action(action, argument) { -//console.log('gen_action called with ', action, ' and ', argument) if (argument === undefined) { - //console.log('argument undefined') view.actions[action] = 1 } else { if (!(action in view.actions)) { - //console.log('push argument') view.actions[action] = [] } view.actions[action].push(argument) } - //console.log('view.actions: ', view.actions, 'view.actions[action]: ', view.actions[action]) } function gen_action_space(space){ @@ -515,7 +510,6 @@ function gen_action_scoring(){ } exports.action = function (state, player, action, arg) { - //console.log('exports.action called with state:' , state, 'player:', player, 'action: ', action, 'arg: ', arg) game = state if (states[game.state] && action in states[game.state]) { states[game.state][action](arg, player) @@ -533,7 +527,6 @@ exports.action = function (state, player, action, arg) { states.com_init = { inactive: 'place starting SPs.', prompt() { - //console.log('state:', game.state, 'game.valid_spaces', game.valid_spaces) if (game.starting_infl.dem_starting_infl === 2 && game.available_ops === 0 ) { view.prompt = 'Place starting SPs: done. Start Turn 1.'; gen_action("start"); @@ -586,7 +579,6 @@ states.com_init = { states.dem_init = { inactive: 'place starting SPs.', prompt() { - //console.log('state:', game.state) if (game.available_ops == 0) { view.prompt = 'Place starting SPs: done.'; gen_action("done"); @@ -659,7 +651,6 @@ states.choose_card = { }, pass() { log('No cards remaining. Passed') - //end_round() game.state = 'end_round' } } @@ -681,27 +672,16 @@ states.play_card ={ return `play ${clean_name(cards[game.played_card].name)}.` }, prompt () { - /*if (game.phase >= 1) { /*Finish here when playing your own event - console.log('in play card') - view.prompt = `${clean_name(cards[game.played_card].name)}: done. End the Action Round.` - gen_action('end_round') - return - }*/ - view.prompt = `Play ${clean_name(cards[game.played_card].name)} for:` if (scoring_cards.includes(game.played_card)) { - /*view.prompt = 'Play for:'*/ gen_action('event') return } // Check for Reformer Rehabilitated - - //console.log('game.active', game.active, 'game.playable_cards[67].playable', game.playable_cards[67].playable) - - - if (game.played_card === 67 && game.playable_cards.includes(67)){ + + if (game.played_card === C_REFORMER_REHABILITATED && game.playable_cards.includes(C_REFORMER_REHABILITATED)){ if (game.active === DEM && (game.dem_tst_position > game.com_tst_position)) { gen_action('event') } @@ -711,11 +691,7 @@ states.play_card ={ } //Check for events - //console.log('event_is_playable(game.played_card)', event_is_playable(game.played_card)) if (event_is_playable(game.played_card)) { - //console.log('card is playable') - //Check for Tiananmen Square Track awards special abilities - //console.log('game.tst_7', game.tst_7) if ((game.active === DEM && cards[game.played_card].side === 'C' && game.dem_tst_position >= 7 && game.com_tst_position < 7 && !game.tst_7) || (game.active === COM && cards[game.played_card].side === 'D' && game.com_tst_position >= 7 && game.dem_tst_position < 7 && !game.tst_7)){ gen_action('tst_7') } @@ -738,7 +714,6 @@ states.play_card ={ }, event() { push_undo() - //console.log('played event, game.active', game.active, 'game.view_opp_hand', game.view_opp_hand) log_gap(`Played C${cards[game.played_card].number} for the event`) game.vm_infl_to_do = false if (scoring_cards.includes(game.played_card)) {game.phase = 0} @@ -746,7 +721,6 @@ states.play_card ={ game.return = game.active if (switch_events.includes(game.played_card)) {next_player()} game.vm_event = game.played_card - //console.log('before event, game.vm_infl_to_do', game.vm_infl_to_do) goto_vm(game.vm_event) }, opp_event() { @@ -789,7 +763,6 @@ states.play_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 } } @@ -848,7 +821,6 @@ states.resolve_opponent_event = { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { - //console.log('in resolve opponent event: discard', game.strategy_discard) if (game.vm_infl_to_do) { view.prompt = 'Event resolved. Choose to play card for:' gen_action('influence') @@ -906,10 +878,6 @@ states.resolve_opponent_event = { }, end_round() { push_undo() - /*if(game.round_player === COM && game.active === DEM) { - log_h3('End of Communist Action Round') - change_player() - } */ end_round() } } @@ -942,7 +910,6 @@ states.finish_add_infl = { } end_round() - //game.state = 'end_round' } } @@ -952,7 +919,6 @@ states.finish_support_check_prep = { if (game.available_ops === 0) { view.prompt = 'Support checks: done.' gen_action('end_round') - //return } else { view.prompt = `Select a space. ${pluralize(game.available_ops, 'support check')} remaining.` console.log('valid_spaces', game.valid_spaces) @@ -965,11 +931,9 @@ states.finish_support_check_prep = { push_undo() game.selected_space = space // Check for Austria-Hungary Border Reopened - check on first support check only - //console.log('game.austria_hungary_border_reopened_checked', game.austria_hungary_border_reopened_checked) if (game.persistent_events.includes(58)){ if (game.active === DEM && game.available_ops > 1) { - //console.log('in ahb check, country, ', spaces[game.selected_space].country, 'ahb', 'austria_hungary_border_reopened']) - if (spaces[game.selected_space].country === 'East_Germany' && game.persistent_events.includes(58) && game.active === DEM) { + if (spaces[game.selected_space].country === 'East_Germany' && game.persistent_events.includes(58) && game.active === DEM) { game.state = 'finish_austria_hungary_border_reopened_check' return } @@ -979,7 +943,6 @@ states.finish_support_check_prep = { }, end_round () { end_round() - //game.state = 'end_round' } } @@ -1084,7 +1047,6 @@ states.tiananmen_square_attempt_success = { }, done () { push_undo() - //console.log('going to tst award, game.return_state', game.return_state) goto_vm(game.vm_event) }, end_round () { @@ -1102,7 +1064,6 @@ states.tiananmen_square_attempt_fail = { end_round () { push_undo() end_round() - //game.state = 'tiananmen_square_attempt_done' } } @@ -1114,35 +1075,23 @@ states.tiananmen_square_attempt_done = { }, end_round () { end_round() - //game.state = 'end_round' } } states.tst_goddess = { inactive: 'choose whether to discard a card.', prompt() { - //if (game.phase === 0) { view.prompt = 'Tiananmen Square Track award: you may discard a non-Power Struggle Card and draw a replacement.' for (let card of game.valid_cards) { gen_action_card(card) } gen_action('pass') - /*} else { - view.prompt = 'Discard a card: done.' - gen_action('done') - }*/ }, card(card) { push_undo() discard(card) game.valid_cards = [] game.state = 'tst_goddess_draw' - //game.phase++ - /*if (game.active === DEM) { - draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.democrat_hand.length +1, game.communist_hand.length) - } else { - draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.democrat_hand.length, game.communist_hand.length +1) - }*/ }, pass() { log('Did not discard') @@ -1207,7 +1156,7 @@ states.tst_goddess_draw = { states.support_check_prep = { inactive: 'do support checks', prompt () { - if (game.available_ops === 0) { /*Needs another check for Support Checks done during Crowd Turns against Ceausescu*/ + if (game.available_ops === 0) { if (game.is_pwr_struggle) { view.prompt = 'The Crowd Turns Against Ceausescu. Support checks: done.' gen_action('done') @@ -1231,18 +1180,16 @@ states.support_check_prep = { game.selected_space = space // Check for Austria-Hungary Border Reopened - check on first support check only - //console.log('game.austria_hungary_border_reopened_checked', game.austria_hungary_border_reopened_checked) if (game.persistent_events.includes(58)) { if (game.active === DEM && game.available_ops > 1) { if (spaces[game.selected_space].country === 'East_Germany' && game.persistent_events.includes(58) && game.active === DEM) { game.state = 'austria_hungary_border_reopened_check' return } - //game.state = 'do_support_check' - } /*else { */ + + } } game.state = 'do_support_check' - //} }, end_round() { push_undo() @@ -1266,7 +1213,6 @@ states.support_check_prep = { states.do_support_check = { inactive: 'do support checks.', prompt () { - // console.log('in do_support_check') view.prompt = `Support check: ${spaces[game.selected_space].name_unique}. Roll a die.` gen_action('roll') }, @@ -1321,11 +1267,7 @@ states.draw_power_cards = { draw() { push_undo() game.power_struggle_deck = [...all_power_cards] - // console.log('game.power_struggle_deck.length', game.power_struggle_deck.length) - //console.log('called draw cards, country', game.pwr_struggle_in, 'game.active', game.active, 'game.view_opp_hand', game.view_opp_hand) - //console.log('test3') let presence = check_presence(game.pwr_struggle_in) - //console.log('test2') if (presence.dem_spaces > 0) { game.dem_pwr_hand_limit = 6 + 2*(presence.dem_spaces - 1) } else { @@ -1371,21 +1313,18 @@ states.draw_power_cards = { //Draw Power Cards game.is_pwr_struggle = true - //console.log('game.dem_pwr_hand_limit', game.dem_pwr_hand_limit, 'game.com_pwr_hand_limit', game.com_pwr_hand_limit) draw_cards(game.power_struggle_deck, game.dem_pwr_hand, game.com_pwr_hand, game.dem_pwr_hand_limit, game.com_pwr_hand_limit) if (game.active === DEM) { game.valid_cards = [...game.dem_pwr_hand] } else { game.valid_cards = [...game.com_pwr_hand] } - //game.valid_cards = all_power_cards log(`Communist: ${game.com_pwr_hand.length} cards`) log(`Democrat: ${game.dem_pwr_hand.length} cards`) //Check if The Crowd Turns Against Ceausescu occurs if (game.table_cards.includes(54) && game.pwr_struggle_in === 'Romania') { - //console.log('draw cards: crowd subcheck, game.active', game.active) if (game.active === COM) { game.return = COM next_player() @@ -1396,7 +1335,6 @@ states.draw_power_cards = { } else { log_h2('Raise the Stakes') game.state = 'raise_stakes_1' - //console.log('game.state', game.state, 'game.active', game.active, 'game.view_opp_hand', game.view_opp_hand) } } } @@ -1412,7 +1350,6 @@ states.the_crowd_turns_against_ceausescu_prep = { draw() { game.ceausescu_cards = [] draw_cards(game.power_struggle_deck, game.ceausescu_cards, game.com_pwr_hand, 15, game.com_pwr_hand.length) - //console.log('game.ceausescu_cards', game.ceausescu_cards) game.temp = game.ceausescu_cards.filter(card => card && card >=25 && card <= 30).length log(`Drew ${pluralize(game.temp, 'Rally in the Square')}.`) game.vm_available_ops = game.temp * 3 @@ -1483,7 +1420,6 @@ states.raise_stakes_1 = { prompt () { console.log('raise stakes 1 - com hand', game.com_pwr_hand, 'dem hand', game.dem_pwr_hand) - // console.log('raise the stakes: game.played_power_card', game.played_power_card, 'game.active', game.active, 'game.view_opp_hand', game.view_opp_hand) if ((game.active === DEM && game.dem_pwr_hand < 3) || (game.active === COM && game.com_pwr_hand < 3)) { view.prompt = 'Raise the stakes: you must pass.' gen_action('pass') @@ -1531,13 +1467,11 @@ states.raise_stakes_1 = { log_gap('Raised the stakes') game.raised_stakes_discard = 0 next_player() - //console.log('game.active', game.active) if (game.active === DEM) { game.valid_cards = [...game.dem_pwr_hand] } else { game.valid_cards = [...game.com_pwr_hand] } - // console.log('game.valid_cards', game.valid_cards) game.state = 'raise_stakes_2' } } @@ -1675,7 +1609,7 @@ states.power_struggle = { } } if (game.phase === 0) { - if (card >= 37 && card <= 48) { /*When a leader is played */ + if (leader_cards.includes(card)) { game.played_power_card = card game.phase = 3 } else if (card === 51){ /*Scare Tactics */ @@ -1732,10 +1666,9 @@ states.power_struggle = { log('Conceded') log_h2('Aftermath') log_h3('Support Loss') - //if ((game.played_power_card >= 25 && game.played_power_card <= 30) || game.played_power_card === 53) {game.rally_win = 2} - //if ((game.played_power_card >= 31 && game.played_power_card <= 36) || game.played_power_card === 54) {game.petition_win = 2} if (game.phase === 0) { - game.played_power_card = 0 /*If conceded when held the initiative but had no playable cards, ignore the last played card */ + game.played_power_card = 0 + game.proxy_power_card = 0 /*If conceded when held the initiative but had no playable cards, ignore the last played card */ } game.phase = 0 game.state = 'support_loss' @@ -1768,24 +1701,6 @@ states.power_struggle = { next_player() do_valid_cards() }, - /*draw () { - if (game.active === DEM) { - draw_cards(game.power_struggle_deck, game.dem_pwr_hand, game.com_pwr_hand, game.dem_pwr_hand.length+2, game.com_pwr_hand.length) - } else {draw_cards(game.power_struggle_deck, game.dem_pwr_hand, game.com_pwr_hand, game.dem_pwr_hand.length, game.com_pwr_hand.length+2)} - game.phase = 0 - next_player() - do_valid_cards() - },*/ - /*infl(space) { - game.remove_opponent_infl = true - remove_infl(space) - game.phase = 6 - }, - discard () { /*Is this still needed? - if (game.active === DEM) {discard_card(game.dem_pwr_hand)} - else {discard_card(game.com_pwr_hand)} - game.available_ops -- - }, */ done () { if (game.phase === 7) { /*Is this ever called anymore? */ game.phase = 0 @@ -1959,10 +1874,8 @@ states.vp_roll = { log(`-${vp_change} VP`) } if (roll >= 4) - //console.log('VP before', game.vp) if (game.active === DEM) {game.vp += vp_change} else {game.vp -= vp_change} - //console.log('VP after', game.vp) if (game.active === DEM && modified_roll >= 4) { game.phase = 1 } else { @@ -2036,21 +1949,6 @@ states.choose_power = { } } } -/* -states.score_country = { - inactive: `score country`, - prompt () { - view.prompt = 'Scoring: done.' - gen_action('done') - }, - done () { - reset_power() - /*if (game.return !== game.active) { - next_player()} - game.state = 'finish_scoring' - } -} -*/ states.the_tyrant_is_gone ={ inactive: 'resolve The Tyrant is Gone.', @@ -2080,7 +1978,6 @@ states.finish_scoring ={ gen_action('done') } , done() { - //console.log('game.return_state', game.return_state) log_msg_gap('Power Struggle resolved') /*At this point log card dicarded or permanently removed? */ if (game.persistent_events.includes(111)) { game.state = 'new_years_eve_party' @@ -2091,7 +1988,6 @@ states.finish_scoring ={ } reset_power() end_round() - //game.state = 'end_round' } } @@ -2173,7 +2069,6 @@ states.final_scoring_held = { gen_action('bonus') }, bonus() { - // console.log('game.revolutions: ', game.revolutions) const held_countries = game.revolutions.filter(value => value === false).length let vp_gain = 4*held_countries log(`Communist holds ${held_countries} countries: -${vp_gain} VP`) @@ -2255,10 +2150,7 @@ states.general_strike = { for (let card of available_cards) { gen_action_card(card) } - } /*else if (game.phase >= 1) { - view.prompt = 'General Strike: done.' - gen_action('done') - } */ else if (game.played_card > 0 ) { + } else if (game.played_card > 0 ) { view.prompt = 'General Strike: roll a die.' gen_action('roll') } @@ -2296,13 +2188,9 @@ states.general_strike = { } else { log('The strike continues. Required 6 or more') } - //game.phase = 1 - game.state = 'end_round' - }, /* - done () { - //end_round() + game.state = 'end_round' - }*/ + }, } states.honecker ={ @@ -2407,7 +2295,6 @@ states.new_years_eve_party = { states.stasi_end_round = { inactive: 'choose next card due to Stasi.', prompt() { - //console.log('game.stasi_card', game.stasi_card) let available_cards = game.democrat_hand if (available_cards.length === 0) { view.prompt = 'Stasi: no cards remaining.' @@ -2473,13 +2360,7 @@ states.stasi_confirm = { states.stasi_play_card = { inactive: 'play a card.', - prompt () { /*Should get rid of the play card 'done' prompt for consistency with general play */ - /*if (game.played_card > 0) { - game.state = 'play_card' - view.prompt = 'Play card: done.' - gen_action("done"); - return;*/ - //} else + prompt () { if (game.democrat_hand.length === 0) { view.prompt = 'Stasi: you must pass.' gen_action('pass') @@ -2493,7 +2374,6 @@ states.stasi_play_card = { }, card(card) { push_undo() - //log_msg_gap(`Stasi: played C${card}`) game.played_card = card let find_card find_card = game.democrat_hand.indexOf(card); @@ -2513,7 +2393,6 @@ states.stasi_play_card = { game.state = 'end_round' }, done () { - //game.stasi_card = 0 if (game.democrat_hand.includes(C_COMMON_EUROPEAN_HOME)) { game.state = 'stasi_resolve_common_european_home' } else { @@ -2547,9 +2426,6 @@ states.stasi_resolve_common_european_home = { function add_infl(space) { push_undo() - //console.log('adding infl to', 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 %${space}`) log_summary(`Added £ SP in %${space}`) //If AHBR - check AHBR conditions @@ -2596,17 +2472,13 @@ function add_infl(space) { // Check for Genscher & Austria Hungary Border Reopened if (game.available_ops === 1) { - //console.log(`in Genscher / AHBR check, game.persistent_events['genscher']`, game.persistent_events['genscher']) if (game.active === DEM) { if (game.persistent_events.includes(63) || (game.persistent_events.includes(58) && game.austria_hungary_border_reopened_tracker)) { - //console.log('in gensher subcheck - remove non-East German controlled ') game.valid_spaces = game.valid_spaces.filter(n => !(check_opp_control(n) && spaces[n].country !== 'East_Germany')) } else { - //console.log('remove all controlled spaces') game.valid_spaces = game.valid_spaces.filter(n => !check_opp_control(n)) } } else { - //console.log('remove all dem controlled spaces') game.valid_spaces = game.valid_spaces.filter(n => !check_opp_control(n)) } } @@ -2619,7 +2491,6 @@ function add_infl(space) { function remove_infl(space) { push_undo() - //log(`Removed 1 influence from %${space}.`) log_summary(`Removed £ SP from %${space}.`) if (game.remove_opponent_infl === true) { @@ -2664,7 +2535,6 @@ function do_sc(space) { game.vp ++ if (check_vp()) { game.state = 'game.over' - //console.log('after check_vp, game.state', game.state) return } } @@ -2674,16 +2544,8 @@ function do_sc(space) { let roll = roll_d6() log(`Roll: D${roll}`) - /* - //Check if support check is being done with game.played_card or a subsequent card (e.g. Common European Home, Dash for the West, etc) - if (game.vm_event > 0) { - roll+= cards[game.vm_event].ops - log(`+${cards[game.vm_event].ops} from card ops`) - } - */ // Check for the Crowd Turns Against Ceausescu - //else if (game.is_pwr_struggle) { roll += game.vm_available_ops logi(`+${game.vm_available_ops} from Ceausescu`) @@ -2697,7 +2559,6 @@ function do_sc(space) { logi('+2 TST award') } else { - //let modifier = 0 let card_ops = get_card_ops(this_card()) roll += card_ops @@ -2748,7 +2609,6 @@ function do_sc(space) { // Events which affect adjacency - The Wall const adj = count_adj(space) - //console.log('adj', adj) if (game.active === COM && game.persistent_events.includes(9) && spaces[space].country === 'East_Germany') { logi('No adjacency for Democrats due to C9') logi('C9 no longer in effect') @@ -2819,7 +2679,7 @@ function do_sc(space) { } else { log_msg_gap('Change influence: 0 SP') } - if (game.active === COM && game.persistent_events.includes(39) && spaces[space].space_id === 66) { + if (game.active === COM && game.persistent_events.includes(C_ECO_GLASNOST) && spaces[space].space_id === S_RUSE) { log_msg_gap('+1 VP from C39') game.vp++ if (check_vp()) { @@ -2828,7 +2688,7 @@ function do_sc(space) { } // If Austria-Hungary Border Reopened used, all future support checks must be in East Germany - if (game.persistent_events.includes(58)){ + if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)){ if (game.austria_hungary_border_reopened_tracker) { game.valid_spaces = game.valid_spaces.filter(n => spaces[n].country === 'East_Germany') } @@ -2840,7 +2700,6 @@ function do_sc(space) { function valid_spaces_setup() { game.valid_spaces = [] let valid_spaces_set = new Set(); - //console.log('in vs setup, state', game.state) for (let i =0 ; i <= 74 ; i++) { space = spaces[i] @@ -2864,7 +2723,6 @@ function valid_spaces_setup() { function valid_spaces_sc() { let valid_spaces_set = new Set(); - //console.log('valid spaces sc, persistent events', game.persistent_events) for (let i = 0 ; i <= 74; i++) { space = spaces[i] @@ -2910,7 +2768,6 @@ function valid_spaces_sc() { function valid_spaces_support_loss() { let valid_spaces_set = new Set(); for (let i = 0; i < game.demInfl.length; i++) { - //console.log('spaces.length', game.demInfl.length, 'i', i) space = spaces[i] if (game.active === DEM) { infl = game.demInfl[i] @@ -2929,38 +2786,9 @@ function valid_spaces_support_loss() { game.valid_spaces = Array.from(valid_spaces_set); return game.valid_spaces; } -/* -function valid_spaces_support_falters() { - let valid_spaces_set = new Set(); - if (game.active === DEM) { - for (let piece of game.pieces) { - if (!piece) continue - let space = spaces.find(s => s && s.space_id === piece.space_id); - if (space && piece.comInfl > 0 && space.country === game.pwr_struggle_in) { - valid_spaces_set.add(space.space_id); - } - } - } else { - for (let piece of game.pieces) { - if (!piece) continue - let space = spaces.find(s => s && s.space_id === piece.space_id); - if (space && piece.demInfl > 0 && space.country === game.pwr_struggle_in) { - valid_spaces_set.add(space.space_id); - } - } - } - // Convert the set to an array before returning - game.valid_spaces = Array.from(valid_spaces_set); - return game.valid_spaces; -} - */ function valid_spaces_infl() { - /*if (game.state.startsWith('vm')) { - console.log('valid_spaces_infl called from VM') - } else { - console.log('valid_spaces_infl called not from VM') - }*/ + // Check if function is called from the VM or not, take relevant ops variable let ops = game.state.startsWith('vm') ? game.vm_available_ops : game.available_ops; @@ -2980,19 +2808,15 @@ function valid_spaces_infl() { let adjacent_spaces = get_adjusted_adjacency(space.space_id) for (let adj_space_id of adjacent_spaces) { - //console.log('adj_space_id', adj_space_id) if (adj_space_id) { const adj_piece = spaces[adj_space_id]; - //console.log('adjacent piece name', adj_piece.name_unique) - + // Check if the adjacent space is controlled by the opponent const opponent_control = check_opp_control(adj_piece.space_id) - //console.log('controlled?', opponent_control) - + //Check for Genscher. Can always place in East Germany even with 1 op if (game.active === DEM && adj_piece.country === 'East_Germany' && game.persistent_events.includes(63)){ - // console.log('space added with genscher') valid_spaces_set.add(adj_piece.space_id) } @@ -3014,7 +2838,7 @@ function valid_cards(player_hand, presence) { if (game.phase === 0) { for (let c of player_hand) { let card = power_cards.find(card => card && card.number === c); - if (card.number === 52) {continue} // Never add tactics fails + if (card.number === C_TACTICS_FAILS) {continue} // Never add tactics fails if (card.name === game.tactics_fails) {continue} //Cannot play the suit of Tactics Fails if (card.socio === 0) { valid_cards_set.add(card.number); @@ -3059,74 +2883,35 @@ function count_adj(id) { for (let adj_space_id of adjacent_spaces) { if (adj_space_id) { const adj_piece = spaces.find(piece => piece && piece.space_id === adj_space_id); - //console.log('adj_piece.space_id', adj_piece.space_id, 'space', space) if (adj_piece && adj_piece.space_id !== space.space_id) { if (check_dem_control(adj_piece.space_id)) { - //console.log('added DEM space', spaces[adj_piece.space_id].name) dem_adj++ } if (check_com_control(adj_piece.space_id)) { - //console.log('added COM space', spaces[adj_piece.space_id].name) com_adj++ } } } } - //console.log('dem_adj: ', dem_adj, 'com_adj: ', com_adj) return {dem_adj, com_adj} } -/*function count_adj_worker(space_id) { - const space = spaces[space_id] - let dem_adj = 0 - let com_adj = 0 - - for (let adj_space_id of space.adjacent) { - if (adj_space_id) { - const adj_space = spaces[adj_space_id] - if (adj_space && adj_space.socio === 4) { - const adj_piece = game.pieces.find(piece => piece && piece.space_id === adj_space_id ); - if (adj_piece) { - if (adj_piece.demCtrl === 1 ) { - dem_adj++ - } - if (adj_piece.comCtrl === 1 ) { - com_adj++ - } - } - } - } - } - return {dem_adj, com_adj} -} */ - function check_control(space_id) { - //console.log('in check control, space', spaces[space_id].name_unique) 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) { - //console.log('true') return true; } else { - //console.log('false') return false; } } function check_opp_control(space_id) { - if (spaces[space_id].country === 'Romania') { - //console.log('in check opp control, space', spaces[space_id].name_unique) - } if (game.active === DEM && ((game.comInfl[space_id] - game.demInfl[space_id]) >= spaces[space_id].stability)) { - if (spaces[space_id].country === 'Romania') { - //console.log('control true') - } return true; } else if (game.active === COM && ((game.demInfl[space_id] - game.comInfl[space_id]) >= spaces[space_id].stability)) { - //console.log('true') return true; } else { - //console.log('false') return false; } } @@ -3352,7 +3137,6 @@ function score_country(country) { let com_vp = 0 //Check for presence let presence = check_presence(country) -// console.log('presence: ', presence) //If one side has domination or control if (presence.dem_control || presence.dem_domination) { @@ -3447,21 +3231,6 @@ function score_country(country) { //Calculate change VP - /*let dem_vp = 0 - if (presence.dem_spaces > 0) {dem_vp += value_presence} - if (presence.dem_domination) {dem_vp += value_presence} - if (presence.dem_control && country !== "Hungary") { - dem_vp += value_control - } - else if (presence.dem_control && country === "Hungary") {dem_vp += 2} - dem_vp += presence.dem_battlegrounds - - let com_vp = 0 - if (presence.com_spaces > 0) {com_vp += value_presence} - if (presence.com_domination) {com_vp += value_presence} - if (presence.com_control && country !== "Hungary") {com_vp += value_presence} - else if (presence.com_control && country === "Hungary") {com_vp += 2} - com_vp += presence.com_battlegrounds */ let change_vp = dem_vp + com_vp game.vp += change_vp if (change_vp > 0 ) { @@ -3489,24 +3258,19 @@ function get_end_infl_prompt() { } function permanently_remove(card) { - //console.log('permanently removing card:', card) if (game.strategy_removed.includes(card)) {return} - //log_msg_gap(`C${cards[card].number} permanently removed`) remove_from_discard(card) card_index = game.table_cards.indexOf(card) if (card_index !== -1) { - //console.log('sub 2 called') game.table_cards.splice(card_index, 1) } game.strategy_removed.push(card) - //console.log('game.strategy_removed', game.strategy_removed) } function check_vp() { if (game.vp >= 20) { goto_game_over(DEM, `${DEM} won an Automatic Victory!`) - //console.log('after goto_game_over, game.state', game.state) return true } else if(game.vp <= -20) { goto_game_over(COM, `${COM} won an Automatic Victory!`) @@ -3528,13 +3292,11 @@ function goto_game_over(result, victory) { game.victory = victory log_h1("Game Over") log(game.victory) - //console.log('game over, game.state', game.state) return } function reset_austria_hungary_border_reopened() { - //game.austria_hungary_border_reopened_checked = false game.austria_hungary_border_reopened_tracker = false } @@ -3596,7 +3358,6 @@ function select_card(card){ game.persistent_events = game.persistent_events.filter(n => n !== 99) } game.state = 'play_card' - //console.log('game.state', game.state) } function find_event(card) { @@ -3642,9 +3403,8 @@ function get_events(card){ } function event_is_playable(card) { -// console.log('game.stasi_card', game.stasi_card, 'card', card) //Reformer never playable here - if (card === 67) { + if (card === C_REFORMER_REHABILITATED) { return false } //Check for Common European Hmme under Stasi @@ -3802,7 +3562,6 @@ function end_round() { //Check if the game is over! if (game.state === 'game_over') { - // console.log('in end') return} //Check if the card has been removed or played to table, and if a card has been not been played. If not, discard. @@ -3812,14 +3571,14 @@ function end_round() { //Reset game.played_card = 0 - game.temp = 0 - game.vm_event = 0 - game.phase = 0 + delete game.temp + delete game.vm_event + delete game.phase game.remove_opponent_infl = false game.is_pwr_struggle = false game.vm_infl_to_do = false /*Can get rid of this and use game.return_state? */ game.vm_event_to_do = false - game.vm_active_country = '' + delete game.vm_active_country game.return_state = '' game.discard = false game.return = '' @@ -3869,9 +3628,6 @@ function end_round() { throw new Error(`Wrong number of cards: ${card_check.length}`) } - - - //console.log('game.dem_tst_position ', game.dem_tst_position , 'game.com_tst_position ', game.com_tst_position ) //Check if the Reformer is playable check_reformer() @@ -3957,15 +3713,14 @@ function end_round() { } if (game.round_player === DEM) { - if(game.persistent_events.includes(13)) { - // console.log('stasi sub function') + if(game.persistent_events.includes(C_STASI)) { if (game.active !== DEM) { next_player() } log_h3('C13') game.state = 'stasi_end_round' return - } else if(game.round_player === DEM && game.persistent_events.includes(5)){ + } else if(game.round_player === DEM && game.persistent_events.includes(C_GENERAL_STRIKE)){ game.state = 'general_strike' game.round ++ log_h2(`Action Round ${game.round}`) @@ -3985,36 +3740,8 @@ function end_round() { } } } - //game.state = 'choose_card' Does this do anything any more? } -/* -function end_turn(){ - /*End Turn sequence - TST support check - Verify held cards - New Year's Eve Party - Advance Turn Marker - -// CHECK FOR OPTIONAL SUPPORT CHECK - if (game.dem_tst_position >=6 && game.com_tst_position <= 5) { - if (game.active !== DEM) { - next_player_() - } - game.state = 'tst_support_check' - } - if (game.com_tst_position >=6 && game.dem_tst_position <= 5) { - if (game.active !== COM) { - next_player_() - } - game.state = 'tst_support_check' - } - - -//CHECK HELD CARDS - -} */ - function new_turn() { clear_undo() game.turn ++ @@ -4029,10 +3756,10 @@ function new_turn() { delete game.selected_space //Remove events that only last one turn - game.persistent_events = game.persistent_events.filter(n => n !== 25) /*Perestroika*/ - game.persistent_events = game.persistent_events.filter(n => n !== 50) /*Sinatra Doctrine*/ - game.persistent_events = game.persistent_events.filter(n => n !== 13) /*Stasi*/ - game.persistent_events = game.persistent_events.filter(n => n !== C_HONECKER) /*Honecker*/ + game.persistent_events = game.persistent_events.filter(n => n !== C_PERESTROIKA) + game.persistent_events = game.persistent_events.filter(n => n !== C_THE_SINATRA_DOCTRINE) + game.persistent_events = game.persistent_events.filter(n => n !== C_STASI) + game.persistent_events = game.persistent_events.filter(n => n !== C_HONECKER) delete game.prudence delete game.stasi_card @@ -4041,26 +3768,22 @@ function new_turn() { game.persistent_events = game.persistent_events.filter(n => n !== 58) delete game.austria_hungary_border_reopened_tracker log(`C58 no longer in effect`) - //permanently_remove(58) } //Elena if (game.persistent_events.includes(101)) { game.persistent_events = game.persistent_events.filter(n => n !== 101) log(`C101 no longer in effect`) - //permanently_remove(101) } //GrenzTruppen if (game.persistent_events.includes(59)) { game.persistent_events = game.persistent_events.filter(n => n !== 59) log(`C59 no longer in effect`) - //permanently_remove(59) } //Foreign Currency Debt Burden if (game.persistent_events.includes(49)) { game.persistent_events = game.persistent_events.filter(n => n !== 49) delete game.foreign_currency_debt_burden log(`C49 no longer in effect`) - //permanently_remove(49) } //FRG Embassies if (game.persistent_events.includes(74)) { @@ -4081,7 +3804,6 @@ function new_turn() { game.persistent_events = game.persistent_events.filter(n => n !== 100) delete game.stand_fast log(`C100 no longer in effect`) - //permanently_remove(100) } if (game.samizdat_card > 0 ) { @@ -4098,18 +3820,13 @@ function new_turn() { add_lateyear() } if (game.turn > 1) { - if (game.persistent_events.includes(65)) { + if (game.persistent_events.includes(C_PRESIDENTIAL_VISIT)) { game.com_hand_limit = 7 log('Communist draws 7 cards due to C65') - //permanently_remove(65) - game.persistent_events = game.persistent_events.filter(n => n !== 65) + game.persistent_events = game.persistent_events.filter(n => n !== C_PRESIDENTIAL_VISIT) } - //console.log('deck', game.strategy_deck) - //console.log('game.com_hand_limit', game.com_hand_limit, 'communist hand before draw', game.communist_hand) draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.dem_hand_limit, game.com_hand_limit) game.com_hand_limit = 8 - //console.log('communist hand after draw', game.communist_hand) - } //Check if TST effects need to be resolved @@ -4134,7 +3851,6 @@ function new_turn() { } else { log_h2("Action Round " + game.round) log_side() - //console.log('in start new AR call, game.active', game.active) if (game.persistent_events.includes(5)) { log_h3('C5') game.state = 'general_strike' @@ -4147,7 +3863,6 @@ function new_turn() { function next_player() { clear_undo() - //console.log('next player called') if (game.active === DEM) game.active = COM else @@ -4158,7 +3873,6 @@ function next_player() { function change_player() { clear_undo() - //console.log('next player called') if (game.active === DEM) game.active = COM else @@ -4190,13 +3904,9 @@ function draw_deck(deck) { } function draw_cards(deck, democrat_hand, communist_hand, dem_hand_limit, com_hand_limit) { - //console.log('game.valid_cards at start of draw cards: ', game.valid_cards) - let turn = 'communist'; // Start with the communist player - //console.log('game.strategy_deck', game.strategy_deck) - //console.log('deck', deck, 'democrat_hand', democrat_hand, 'communist_hand', communist_hand, 'dem_hand_limit', dem_hand_limit, 'com_hand_limit', com_hand_limit) - while (democrat_hand.length < dem_hand_limit || communist_hand.length < com_hand_limit) { - //console.log('deck.length: ', deck.length) - //console.log('discard.length', game.strategy_discard ) + //Start with the communist player + let turn = 'communist'; + while (democrat_hand.length < dem_hand_limit || communist_hand.length < com_hand_limit) { if (deck.length === 0) { log_h3('--- Reshuffle ---') @@ -4206,16 +3916,12 @@ function draw_cards(deck, democrat_hand, communist_hand, dem_hand_limit, com_han else if (turn === 'communist' && communist_hand.length < com_hand_limit) { communist_hand.push(draw_card(deck)); - //console.log('game.valid_cards after communist draw: ', JSON.stringify(game.valid_cards)); - turn = 'democrat'; + turn = 'democrat'; } else if(turn === 'communist' && communist_hand.length === com_hand_limit) { turn = 'democrat'; } else if (turn === 'democrat' && democrat_hand.length < dem_hand_limit) { democrat_hand.push(draw_card(deck)); - //console.log('democrat_hand: ', democrat_hand) - - //console.log('game.valid_cards after democrat draw: ', JSON.stringify(game.valid_cards)); turn = 'communist'; } else if (turn === 'democrat' && democrat_hand.length === dem_hand_limit) { @@ -4227,8 +3933,6 @@ function draw_cards(deck, democrat_hand, communist_hand, dem_hand_limit, com_han } function draw_card(deck) { - //console.log('draw card called with:', deck) - //console.log('game.strategy_deck before', game.strategy_deck) if (deck.length === 0) { log_h3('--- Reshuffle ---') @@ -4236,13 +3940,10 @@ function draw_card(deck) { game.strategy_discard = [] } const randomIndex = Math.floor(random(deck.length)) - //console.log('card chosen:', randomIndex) - //console.log('game.strategy_deck after', game.strategy_deck) return deck.splice(randomIndex, 1)[0]; } function discard(card) { - //console.log('in discard(card)') let find_card if (!game.is_pwr_struggle) { @@ -4267,11 +3968,9 @@ function discard(card) { } game.power_struggle_discard.push(card) - //log(`Discarded P${power_cards[card].number}`) } } function silent_discard(card) { - //console.log('in discard(card)') let find_card if (!game.is_pwr_struggle) { if (game.active === COM) { @@ -4304,7 +4003,6 @@ function remove_from_discard(card) { } function discard_card(hand) { - //let find_card let card = Math.floor(random(hand.length)) let discarded_card = hand.splice(card, 1)[0] if (game.is_pwr_struggle) { @@ -4364,12 +4062,10 @@ function reset_power() { } if (game.persistent_events.includes(54) && game.pwr_struggle_in === 'Romania'){ permanently_remove(54) - //game.table_cards = game.table_cards.filter(card => card !== 54) + } if (game.pwr_struggle_in === 'Romania' && game.persistent_events.includes(C_SECURITATE)){ - //permanently_remove(C_SECURITATE) - //game.table_cards = game.table_cards.filter(card => card !== C_SECURITATE) game.persistent_events = game.persistent_events.filter(n => n !== C_SECURITATE) } } @@ -4405,40 +4101,6 @@ function check_common_european_home() { function this_card() { return game.vm_event > 0 ? game.vm_event : game.played_card } -/* -function get_ops(card) { - let ops = cards[card].ops - if (game.active === COM) { - //Check TST op bonus - if (ops === 1 && game.com_tst_position >=2 && game.dem_tst_position <=1) { - ops++ - } - //Events that influence ops - if (game.persistent_events.includes(25)) { - ops++ - } - if (game.prudence.COM && game.prudence.COM <0) { - ops += game.prudence.COM - } - - } else { - //Check TST op bonus - if (ops === 1 && game.dem_tst_position >=2 && game.com_tst_position <=1) { - ops++ - } - //Events that influence ops - if (game.persistent_events.includes(50)) { - ops++ - } - if (game.prudence.DEM && game.prudence.DEM <0) { - ops += game.prudence.DEM - } - } - //Ops can never be less than one - if (ops <1) { ops = 1 } - return ops -} - */ const pluralize = (count, noun, suffix = 's') => `${count} ${noun}${Math.abs(count) !== 1 ? suffix : ''}` @@ -4652,13 +4314,11 @@ function vm_exec() { } function vm_inst(a) { - //console.log('game.vm.fp', game.vm.fp, 'game.vm.ip', game.vm.ip) return CODE[game.vm.fp][game.vm.ip][a] } function vm_next() { game.vm.ip++; - //console.log('vm_next called, game.vm.ip', game.vm.ip) vm_exec(); } @@ -4681,8 +4341,6 @@ function vm_log() { } function vm_if() { - //console.log('game.temp', game.temp) -// console.log('vm_operand(1)', vm_operand(1)) if (!vm_operand(1)) { let balance = 1 while (balance > 0) { @@ -4715,11 +4373,7 @@ function vm_endif() { } function vm_goto_step(step) { - // console.log('vm_goto_step called, target:', step) - //console.log('game.vm.ip', game.vp.ip) for (let i = game.vm.ip; i < CODE[game.vm.fp].length; i++) { - //console.log('i', i) - //console.log('step', CODE[game.vm.fp][i][0]) if (CODE[game.vm.fp][i][0] === step) { game.vm.ip = i; vm_exec(); @@ -4732,8 +4386,6 @@ function vm_goto_step(step) { function vm_goto(op, nop, dir, step) { - //console.log('vm_inst(0)', vm_inst(0), op, nop) -// console.log('vm_inst(0)', vm_inst(1), op, nop) let balance = 1 while (balance > 0) { game.vm.ip += dir @@ -4749,12 +4401,10 @@ function vm_goto(op, nop, dir, step) { } function event_prompt(str) { - //console.log('event_prompt called with', str) if (typeof str === "undefined") str = CODE[game.vm.fp][game.vm.prompt][1] if (typeof str === "function") str = str() - //console.log('str:', str) if (!str) { str = "" } @@ -4778,9 +4428,6 @@ function pop_vm_prompt() { } function vm_return() { - - //console.log('in vm_return, game.vm_infl_to_do', game.vm_infl_to_do, 'return state', game.return_state) - //Remove temporary vm variables delete game.support_check_modifier delete game.vm_max_infl @@ -4788,7 +4435,7 @@ function vm_return() { delete game.communist_hand_red game.vm_event = 0 /*Reset to 0 now that event has been completed. Hopefully this doesn't cause issues! */ - if (game.persistent_events.includes(58)) { + if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) { reset_austria_hungary_border_reopened() } @@ -4801,33 +4448,11 @@ function vm_return() { vm_end_event() } else { - game.state = 'vm_end_event' - /*if (!game.vm_infl_to_do) { - /*if ((game.active === DEM && game.round_player !==DEM) || (game.active === COM && game.round_player !== COM)) { - game.state = 'vm_end_event' - } else { - game.state = 'vm_end_event' - //end_round() - //} - } else { - console.log('vm_infl_to_do true') - vm_end_event() - }*/ } } function vm_end_event() { - //game.view_opp_hand = false -// console.log('in vm_return, game.return:', game.return, 'game.return_state:', game.return_state, 'game.vm_infl_to_do', game.vm_infl_to_do, 'game.vm_event_to_do', game.vm_event_to_do) - /*if (!game.vm_infl_to_do && !game.vm_event_to_do) { - if (game.round_player !== game.active) { - change_player() - log_h2('End of Action Round') - } - end_round() - return - } /*Go direct to end round if card fully resolved */ if (game.return !== game.active) { next_player()} if (game.return_state === 'power_struggle') { @@ -4835,13 +4460,12 @@ function vm_end_event() { } if (game.return_state && game.return_state !== '') { game.state = game.return_state - //console.log( 'game.state', game.state) } else if (game.vm_infl_to_do) { - game.state = 'resolve_opponent_event'} /*Can use game.return state for this? */ - //else {game.state = "play_card"} - else{ - end_round()} + game.state = 'resolve_opponent_event'} + else { + end_round() + } } /* ================== VM ACTIONS =========================== */ @@ -4893,7 +4517,6 @@ function vm_valid_spaces_opponent () { } } game.valid_spaces = valid_spaces -// console.log('game.valid_spaces', game.valid_spaces) vm_next() } @@ -4988,7 +4611,6 @@ function vm_valid_spaces_country_opp () { function vm_valid_spaces_country_sc () { let valid_spaces = [] let country = '' - //console.log('in vm_valid_spaces_country_sc') if (vm_operand(1)) { country = vm_operand(1) } else { @@ -5018,11 +4640,6 @@ function vm_valid_spaces_country_sc () { } } game.valid_spaces = valid_spaces - - //Check for Foreign Currency Debt Burden - /*if (game.persistent_events.includes(49) && game.active === COM) { - game.valid_spaces = game.valid_spaces.filter(n => spaces[n].country !== game.foreign_currency_debt_burden) - }*/ vm_next() } @@ -5097,8 +4714,6 @@ function vm_take_control(space) { if ((current_infl - opponent_infl) < stability) { game.demInfl[space] += stability - current_infl + opponent_infl - //game.pieces[space].demCtrl = 1 - //game.pieces[space].comCtrl = 0 } } else if (game.active === COM) { let current_infl = game.comInfl[space] @@ -5107,8 +4722,6 @@ function vm_take_control(space) { if ((current_infl - opponent_infl) < stability) { game.comInfl[space] += stability - current_infl + opponent_infl - //game.pieces[space].comCtrl = 1 - //game.pieces[space].demCtrl = 0 } } game.valid_spaces = game.valid_spaces.filter(id => id !== space) @@ -5118,14 +4731,10 @@ function vm_take_control(space) { function vm_do_add_infl(space) { push_undo() - //console.log('in vm_do_add_infl, space', space, 'ops', game.vm_available_ops, 'ahbr tracker', game.austria_hungary_border_reopened_tracker, 'ahbr in events', game.persistent_events.includes(58)) - - //log(`Added 1 influence in %${space}.`) - log_summary(`Added £ SP in %${space}.`) //If AHBR - check AHBR condition - 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 } @@ -5156,8 +4765,7 @@ function vm_do_add_infl(space) { check_control_change(space) // 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(58) && game.austria_hungary_border_reopened_tracker) { - //console.log('in award extra op') + if (game.vm_available_ops === 0 && game.active === DEM && game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED) && game.austria_hungary_border_reopened_tracker) { game.vm_available_ops ++ log('+1 Op from C58') game.austria_hungary_border_reopened_tracker = false @@ -5172,7 +4780,7 @@ function vm_do_add_infl(space) { if (game.active === DEM) { //Check Genscher and AHBR - 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_com_control(n) && spaces[n].country !== 'East_Germany')) } else { game.valid_spaces = game.valid_spaces.filter(n => !check_com_control(n)) @@ -5190,8 +4798,6 @@ function vm_do_add_infl(space) { function vm_do_add_infl_free(space) { push_undo() - //log(`Added 1 influence in %${space}.`) - log_summary(`Added £ SP in %${space}.`) // Update influence values @@ -5203,9 +4809,6 @@ function vm_do_add_infl_free(space) { game.vm_available_ops-- // Check whether spaces are controlled check_control_change(space) - - - //console.log('game pieces:', game.pieces[space]) } function vm_add_infl() { @@ -5246,8 +4849,6 @@ function vm_add_limited_infl() { function vm_do_add_limited_infl(space, max_infl) { push_undo() - //log(`Added 1 influence in %${space}.`) - log_summary(`Added £ SP in %${space}.`) game.vm_available_ops -- @@ -5267,8 +4868,6 @@ function vm_do_add_limited_infl(space, max_infl) { game.vm_influence_added[space] ++ - //console.log('valid_spaces before update', game.valid_spaces) - //console.log('influence added:', game.vm_influence_added[space], 'max infl', max_infl) if (game.vm_influence_added[space] === max_infl) { game.valid_spaces = game.valid_spaces.filter(id => id !== space); } @@ -5299,7 +4898,6 @@ function vm_remove_x_opp_infl() { function vm_do_remove_infl(space) { push_undo() - //log(`Removed 1 influence from %${space}.`) log_summary(`Removed £ SP from %${space}.`) if (!game.vm_influence_added) { @@ -5519,9 +5117,6 @@ function vm_adamec() { function vm_army_backs_revolution() { game.persistent_events = game.persistent_events.filter(n => n !== C_SECURITATE) game.playable_cards = game.playable_cards.filter(n => n !== C_SECURITATE) - /*if (game.table_cards.includes(C_SECURITATE)) { - permanently_remove(C_SECURITATE) - }*/ vm_next() } @@ -5529,15 +5124,13 @@ function vm_austria_hungary_border_reopened() { game.persistent_events.push(58) permanently_remove(58) game.austria_hungary_border_reopened_tracker = false - //game.table_cards.push(58) - //remove_from_discard(58) vm_next() } function vm_betrayal() { - if (game.demInfl[58] > 0 ) { game.valid_spaces.push(58) } - if (game.demInfl[65] >0 ) { game.valid_spaces.push(65) } - game.vm_available_ops = Math.max(game.demInfl[58], game.demInfl[65]) + if (game.demInfl[S_ORTHODOX_CHURCH_ROMANIA] > 0 ) { game.valid_spaces.push(S_ORTHODOX_CHURCH_ROMANIA) } + if (game.demInfl[S_ORTHODOX_CHURCH_BULGARIA] >0 ) { game.valid_spaces.push(S_ORTHODOX_CHURCH_BULGARIA) } + game.vm_available_ops = Math.max(game.demInfl[S_ORTHODOX_CHURCH_ROMANIA], game.demInfl[S_ORTHODOX_CHURCH_BULGARIA]) game.state = 'vm_switch_infl' } @@ -5559,7 +5152,6 @@ function vm_brought_in_for_questioning() { if (game.active === COM) { game.active = DEM } - //game.return = game.active game.phase = 0 game.state = 'vm_brought_in_for_questioning' } @@ -5586,7 +5178,6 @@ function vm_ceausescu() { if (adj_cluj && game.comInfl[S_BUCURESTI]>0) { game.valid_spaces = [S_BUCURESTI] game.vm_available_ops = 1 - //next_player() game.remove_opponent_infl = false game.state = 'vm_remove_infl' } @@ -5615,15 +5206,14 @@ function vm_civic_forum() { function vm_common_european_home() { let valid_cards = []; for (let c of cards) { - //if (c === null) {continue} if (game.active === DEM) { if (c && c.side === 'C') { - valid_cards.push(c.number) + valid_cards.push(c.number) } } else { - if (c && c.side === 'D') { - valid_cards.push(c.number) - } + if (c && c.side === 'D') { + valid_cards.push(c.number) + } } } game.valid_cards = valid_cards @@ -5678,9 +5268,8 @@ function vm_elena(){ function vm_eliminate(space_id) { log(`Eliminated %${space_id}`) - const adjacent_spaces = spaces[space_id].adjacent.filter(Number.isInteger); - // Eliminate the democrat influence and move the communist influence to Bucuresti +// 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 @@ -5701,24 +5290,17 @@ function vm_eliminate(space_id) { function get_adjusted_adjacency(space_id) { let adjacent_spaces = spaces[space_id].adjacent; if (adjacent_spaces.includes(game.systematization)) { - //console.log('in get adjusted adjacency, systemization',game.systematization) - //console.log('adjacent_spaces', adjacent_spaces) } if (game.systematization !== 0) { - //console.log('in systematization check') let eliminated_space_id = game.systematization; return adjacent_spaces.map(adj_space_id => { if (adj_space_id === eliminated_space_id) { - // Replace the eliminated space with its adjacencies - //console.log('in map check, return', spaces[eliminated_space_id].adjacent) return spaces[eliminated_space_id].adjacent; } - //console.log('2nd check, return', adj_space_id) return adj_space_id; }).flat(); // Flatten in case the eliminated space has multiple adjacencies } - //console.log('final adjacent spaces', adjacent_spaces) return adjacent_spaces; } @@ -5732,8 +5314,6 @@ function vm_foreign_currency_debt_burden() { if (check_vp()) { return } - //game.table_cards.push(49) - //remove_from_discard(49) game.persistent_events.push(49) game.state = 'vm_foreign_currency_debt_burden' } @@ -5780,7 +5360,7 @@ function vm_goodbye_lenin() { game.communist_hand_red.push(card) } } - //Check if these cards are playabl + //Check if these cards are playable for (let card of game.communist_hand_red) { if (cards[card].playable || game.playable_cards.includes(card)) { game.valid_cards.push(card) @@ -5803,8 +5383,6 @@ function vm_government_resigns() { function vm_grenztruppen() { game.persistent_events.push(59) permanently_remove(59) - //game.table_cards.push(59) - //remove_from_discard(59) vm_next() } @@ -5901,8 +5479,6 @@ function vm_kremlin_coup() { return } game.support_check_modifier = 1 - //countries = ['Poland', 'Hungary', 'East_Germany', 'Bulgaria', 'Czechoslovakia', 'Romania'] - //revolutions: {'East_Germany': false, 'Poland': false, 'Czechoslovakia': false, 'Hungary': false, 'Romania': false, 'Bulgaria': false} game.temp = [] countries.forEach(country => { if (!game.revolutions[find_country_index(country)]) { @@ -5935,7 +5511,6 @@ function vm_legacy_of_1968() { function vm_li_peng() { game.persistent_events.push(53) - //game.table_cards.push(53) remove_from_discard(53) vm_next() } @@ -6018,25 +5593,9 @@ function vm_poszgay() { } function vm_power_struggle() { - //console.log('in vm_power_struggle. game.vm_event', game.vm_event, 'game.active', game.active, 'game.view_opp_hand', game.view_opp_hand) game.is_pwr_struggle = true - - /* TO DELETE? - //Check if Power Struggle is because of an event - */ - - if (game.vm_event > 0) { - game.pwr_struggle_in = countries[scoring_cards.indexOf(game.vm_event)] - log_h2(`C${game.vm_event}`) - } -/* - //Otherwise set Power Struggle country normally - else { - console.log('vm_power_struggle, country set normally') - game.pwr_struggle_in = countries[scoring_cards.indexOf(game.played_card)] - log_h2(`C${game.played_card}`) - }*/ - + game.pwr_struggle_in = countries[scoring_cards.indexOf(game.vm_event)] + log_h2(`C${game.vm_event}`) //Check for Securitate if (game.pwr_struggle_in === 'Romania' && game.persistent_events.includes(C_SECURITATE)) { @@ -6049,8 +5608,6 @@ function vm_power_struggle() { function vm_presidential_visit() { game.persistent_events.push(65) - //game.table_cards.push(65) - //remove_from_discard(65) log_msg_gap('C65 in effect') vm_next() } @@ -6124,7 +5681,6 @@ function vm_samizdat() { function vm_securitate() { game.persistent_events.push(C_SECURITATE) permanently_remove(C_SECURITATE) - //game.table_cards.push(C_SECURITATE) vm_next() } @@ -6160,7 +5716,6 @@ function vm_stand_fast() { if (game.active === DEM) { game.stand_fast = DEM } else {game.stand_fast = COM} - //game.table_cards.push(100) vm_next() } @@ -6250,13 +5805,10 @@ function vm_the_tyrant_is_gone_prep() { function vm_tyrant_block() { logi(`Has no effect after C${C_THE_TYRANT_IS_GONE}`) vm_next() - //game.state = 'vm_tyrant_block' } function vm_the_wall () { game.persistent_events.push(C_THE_WALL) - //game.strategy_removed.push(9) - //game.table_cards.push(9) log_msg_gap('C9 in effect') vm_next() } @@ -6271,7 +5823,6 @@ function vm_the_wall_must_go() { } function vm_warsaw_pact_summit() { - game.warsaw_pact_summit = true /*What does this do? */ game.state = 'vm_warsaw_pact_summit' } @@ -6555,7 +6106,6 @@ states.vm_add_x_infl = { get inactive() { return `resolve ${clean_name(cards[this_card()].name)}: add Support Points.` }, -// inactive: `resolve ${cards[this_card()].name}: add influence.`, prompt () { if (game.vm_event === 101 && game.valid_spaces.length === 0) { view.prompt = `${clean_name(cards[this_card()].name)}: the Romanian Elite space no longer exists.` @@ -6567,10 +6117,7 @@ states.vm_add_x_infl = { for (let space_id of game.valid_spaces) { gen_action_space(space_id) } - } /*else { - view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.` - gen_action('done') - }*/ + } }, space(space) { push_undo() @@ -6602,10 +6149,7 @@ states.vm_add_limited_infl = { for (let space_id of game.valid_spaces) { gen_action_space(space_id); } - } /*else { - view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.` - gen_action('done') - }*/ + } }, space(space) { vm_do_add_limited_infl(space, game.vm_max_infl) @@ -6619,15 +6163,6 @@ states.vm_add_limited_infl = { vm_next() } }, - /*done () { - push_undo() - if (game.summary.length > 0) { - pop_summary() - log_br() - } - game.vm_event_done = true - vm_next() - }*/ } states.vm_remove_infl = { @@ -6693,30 +6228,14 @@ states.vm_remove_x_infl = { for (let space_id of game.valid_spaces) { gen_action_space(space_id); } - } /*else { - if (game.vm_infl_to_do) { - view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done. Return control to phasing player.` - gen_action('done') - return - } else { - view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.` - gen_action('done') - return - } - }*/ + } }, space(space) { vm_do_remove_x_infl(space) - /*if (game.vm_event === 68) { - vm_next() - return - }*/ if (game.vm_available_ops === 0) { game.vm_event_done = true vm_next() } - /*game.vm_event_done = true - vm_next()*/ }, done () { game.vm_event_done = true @@ -6736,17 +6255,7 @@ states.vm_remove_limited_infl = { } else if (game.valid_spaces.length === 0 && game.vm_available_ops > 0) { view.prompt = `${clean_name(cards[this_card()].name)}: no further SP to remove.` gen_action('done') - } /*else { - if (game.vm_infl_to_do) { - view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done. Return control to phasing player.` - gen_action('done') - return - } else { - view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.` - gen_action('done') - return - } - }*/ + } }, space(space) { vm_do_remove_limited_infl(space, game.vm_max_infl) @@ -6780,10 +6289,7 @@ states.vm_remove_all_infl = { for (let space_id of game.valid_spaces) { gen_action_space(space_id); } - } /*else { - view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.` - gen_action('done') - }*/ + } }, space(space) { vm_do_remove_all_infl(space) @@ -6801,17 +6307,11 @@ states.vm_remove_all_infl = { states.vm_support_check_prep = { inactive: 'do support checks.', prompt () { - /*if (game.vm_available_ops === 0) { - view.prompt = `${clean_name(cards[this_card()].name)}. Support check: done.` - gen_action('done') - } else */ if (game.valid_spaces.length === 0) { view.prompt = `${clean_name(cards[this_card()].name)}: no valid targets for support check.` gen_action('done') } else { - //if (game.vm_available_ops > 0) { - view.prompt = `${clean_name(cards[this_card()].name)}: ${event_prompt()}. ${pluralize(game.vm_available_ops, 'support check')} remaining.` - //} + view.prompt = `${clean_name(cards[this_card()].name)}: ${event_prompt()}. ${pluralize(game.vm_available_ops, 'support check')} remaining.` for (let space_id of game.valid_spaces) { if (!space_id) continue gen_action_space(space_id); @@ -6831,15 +6331,13 @@ states.vm_support_check_prep = { } //Then check Austria-Hungary Border Reopened normally - //console.log('game.austria_hungary_border_reopened_checked', game.austria_hungary_border_reopened_checked) - if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) { + if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) { if (game.active === DEM && game.vm_available_ops > 1) { if (spaces[game.selected_space].country === 'East_Germany' && game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED) && game.active === DEM) { game.state = 'vm_austria_hungary_border_reopened_check' return } - //game.state = 'do_support_check' - } /*else { */ + } } game.state = 'vm_do_support_check' }, @@ -6853,11 +6351,6 @@ states.vm_support_check_prep = { states.vm_ceh_support_check_prep = { inactive: 'do support checks.', prompt () { - /*if (game.vm_available_ops === 0) { - view.prompt = 'Support checks: done.' - gen_action('done') - return - }*/ if (game.vm_available_ops > 0) { view.prompt = `Select a space. ${pluralize(game.vm_available_ops, 'support check')} remaining.` @@ -6871,7 +6364,6 @@ states.vm_ceh_support_check_prep = { game.selected_space = space //Then check Austria-Hungary Border Reopened normally - //console.log('game.austria_hungary_border_reopened_checked', game.austria_hungary_border_reopened_checked) if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) { if (game.active === DEM && game.vm_available_ops > 1) { @@ -6879,14 +6371,10 @@ states.vm_ceh_support_check_prep = { game.state = 'vm_austria_hungary_border_reopened_check' return } - //game.state = 'do_support_check' - } /*else { */ + } } game.state = 'vm_ceh_do_support_check' }, - /*done () { - vm_next () - }*/ } @@ -6930,10 +6418,7 @@ states.vm_austria_hungary_border_reopened_check = { states.vm_1_support_check_prep = { inactive: 'do support checks.', prompt () { - /*if (game.vm_available_ops === 0) { - view.prompt = `${clean_name(cards[this_card()].name)}. Support check: done.` - gen_action('done') - } else */if (game.valid_spaces.length === 0) { + if (game.valid_spaces.length === 0) { view.prompt = `${clean_name(cards[this_card()].name)}: no valid targets for support check.` gen_action('done') } else { @@ -6981,11 +6466,6 @@ states.vm_do_support_check = { states.vm_tiananmen_square_attempt = { inactive: 'do Tiananmen Square', prompt () { - /*if (game.active === DEM && game.dem_tst_attempted_this_turn > 0 || game.active === COM && game.com_tst_attempted_this_turn > 0) { - view.prompt = 'Tiananmen Square Track attempt: done.' - gen_action('done') - return - }*/ view.prompt = 'Tiananmen Square: roll a die' gen_action('roll') }, @@ -6993,9 +6473,6 @@ states.vm_tiananmen_square_attempt = { clear_undo() do_tst_attempt () }, - /*done () { - vm_next() - }*/ } //================================== EVENT SPECIFIC STATES ====================================== @@ -7032,10 +6509,6 @@ states.vm_adamec = { states.vm_brought_in_for_questioning = { inactive: 'discard a card.', prompt() { - /*if (game.phase === 1) { - view.prompt = 'Discard a card: done.' - gen_action('done') - } else */ if (game.democrat_hand.length === 0) { view.prompt = 'Brought in for Questioning. No cards to discard.' gen_action('pass') @@ -7049,7 +6522,6 @@ states.vm_brought_in_for_questioning = { game.vm_event = discard_card(game.democrat_hand) game.phase = 1 if (cards[game.vm_event].side === 'C' && (cards[game.vm_event].playable || game.playable_cards.includes(game.vm_event))) { - //game.return = game.active if (!game.vm_infl_to_do) { if(game.round_player === DEM) { game.return = COM @@ -7070,9 +6542,6 @@ states.vm_brought_in_for_questioning = { log('No cards to discard') vm_return() }, - /*done() { - vm_return() - }*/ } states.vm_central_committee_reshuffle = { @@ -7093,7 +6562,7 @@ states.vm_central_committee_reshuffle = { if (!game.revolutions[5]) {gen_action('romania')} } }, - east_germany() { /*Updated for zero index spaces*/ + east_germany() { push_undo() game.vm_active_country = "East_Germany" log(`Chose ${country_name(game.vm_active_country)}`) @@ -7155,7 +6624,6 @@ states.vm_common_european_home_choose = { }, card(card) { push_undo() - //log(`Played with C${cards[card].number}`) game.valid_cards = [] silent_discard(card) game.vm_event = card @@ -7174,9 +6642,6 @@ states.vm_common_european_home_play = { if (game.active === DEM && game.vm_event === C_KOHL_PROPOSES_REUNIFICATION ) { return /*Special condition if card is actually Kohl Proposes Reunification*/ } - /*if (game.active === DEM && game.dem_tst_attempted_this_turn === 0 || game.active === COM && game.com_tst_attempted_this_turn === 0) { - gen_action('tst') - } */ }, influence(){ push_undo() @@ -7208,13 +6673,8 @@ states.vm_dash_for_the_west = { return `resolve ${clean_name(cards[C_DASH_FOR_THE_WEST].name)}.` }, prompt() { - /* if (game.phase === 1) {*/ - view.prompt = 'Dash for the West: roll a die' - gen_action('roll') - /*} else { - view.prompt = 'Dash for the West: roll a die. Done.' - gen_action('done') - }*/ + view.prompt = 'Dash for the West: roll a die' + gen_action('roll') }, roll() { clear_undo() @@ -7233,13 +6693,9 @@ states.vm_dash_for_the_west = { game.state = 'vm_play_event_from_discard' } else { log(`Fail: more than a ${com_control} required`) - //game.phase++ vm_next() } - },/* - done() { - vm_next() - }*/ + }, } states.vm_play_event_from_discard = { @@ -7256,10 +6712,7 @@ states.vm_play_event_from_discard = { gen_action('pass') gen_action_card(card) } - } /*else { - view.prompt = 'Choose a card: done.' - gen_action('done') - }*/ + } }, card(card) { push_undo() @@ -7267,7 +6720,6 @@ states.vm_play_event_from_discard = { game.vm_event = card game.vm_available_ops = cards[card].ops game.discard = false - //game.return = game.active Does turning this off cause problems? if (switch_events.includes(card)) {next_player()} goto_vm(card) }, @@ -7280,11 +6732,6 @@ states.vm_play_event_from_discard = { } vm_next() }, -/* done(){ - push_undo() - game.discard = false - vm_next() - }*/ } states.vm_deutsche_marks_prep = { @@ -7305,7 +6752,6 @@ states.vm_deutsche_marks_prep = { log(`Gave C${cards[card].number}`) game.valid_cards = [] silent_discard(card) - //next_player() game.state = 'vm_deutsche_marks_confirm' game.vm_event = card }, @@ -7360,12 +6806,6 @@ states.vm_deutsche_marks = { push_undo() log(`Played C${cards[game.vm_event].number} to place SPs`) game.vm_available_ops = get_card_ops(game.vm_event) - - /*cards[game.vm_event].ops - if (game.persistent_events.includes(25)) {game.vm_available_ops++ } - if (game.prudence.COM && game.prudence.COM < 0 ) { - game.vm_available_ops += game.prudence.COM - }*/ valid_spaces_infl() game.state = 'vm_add_infl' }, @@ -7421,10 +6861,7 @@ states.vm_exit_visas_finish = { if (game.temp > 0 ) { view.prompt = 'Exit Visas: draw replacement cards.' gen_action('draw') - } /*else { - view.prompt = 'Exit Visas. Draw cards: done.' - gen_action('done') - } */ + } }, draw() { clear_undo() @@ -7432,9 +6869,6 @@ states.vm_exit_visas_finish = { game.temp = 0 vm_next() }, - /*done() { - vm_next() - }*/ } states.vm_foreign_currency_debt_burden = { @@ -7566,10 +7000,7 @@ states.vm_honecker = { gen_action_card(card) gen_action('pass') } - } /*else { - view.prompt = 'Honecker. Choose a card: done.' - gen_action('done') - }*/ + } }, card(card) { push_undo() @@ -7586,14 +7017,6 @@ states.vm_honecker = { game.discard = false vm_next() }, - /*done(){ - if (game.temp === 0) { - log('Did not take a card') - } - game.discard = false - vm_next() - } */ - } states.vm_inflationary_currency = { @@ -7679,10 +7102,7 @@ states.vm_inflationary_currency_discard = { for (let card of game.valid_cards) { gen_action_card(card) } - } /*else { - view.prompt = 'Inflationary Currency. Discard a card: done.' - gen_action('done') - } */ + } }, card(card) { push_undo() @@ -7703,7 +7123,6 @@ states.vm_inflationary_currency_discard = { next_player() game.vm_available_ops = 1 vm_next() - //game.state = 'vm_support_check_prep' }, done() { if (!game.vm_infl_to_do) { @@ -7764,10 +7183,6 @@ states.vm_kiss_of_death_finish = { } }, event() { - //game.return = game.active - // Remove game.vm_event from the discard - //game.strategy_discard = game.strategy_discard.filter(n => n !== game.vm_event) - goto_vm(game.vm_event) }, done() { @@ -7891,7 +7306,6 @@ states.vm_kremlin_coup_sc_prep = { space(game.selected_space); }, space(space) { - //game.selected_space = space push_undo() game.state = 'vm_kremlin_coup_sc' } @@ -7909,25 +7323,11 @@ states.vm_kremlin_coup_sc = { if (game.temp.length > 0 ){ game.state = 'vm_kremlin_coup_choose_country' } else { - //game.state = 'vm_kremlin_coup_end' vm_next() } } } -/* -states.vm_kremlin_coup_end = { - get inactive() { - return `resolve ${clean_name(cards[this_card()].name)}.` - }, - prompt() { - view.prompt = `${clean_name(cards[this_card()].name)} Support checks: done.` - gen_action('done') - }, - done() { - vm_next() - } -} -*/ + states.vm_laszlo_tokes = { get inactive() { return `resolve ${clean_name(cards[game.played_card].name)}.` @@ -7944,12 +7344,10 @@ states.vm_laszlo_tokes = { game.valid_spaces = game.valid_spaces.filter(space_id => spaces[space_id].country === 'Romania') game.phase = 3 vm_next() - //game.state = 'vm_add_infl' }, support_check() { push_undo() game.vm_available_ops = 2 - //game.state = 'vm_support_check_prep' valid_spaces_sc() game.valid_spaces = game.valid_spaces.filter(space_id => spaces[space_id].country === 'Romania') vm_next() @@ -7965,15 +7363,11 @@ states.vm_switch_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: No SPs to remove.` gen_action('pass') } else { - /*if (game.vm_available_ops > 0 ) {*/ view.prompt = `${clean_name(cards[game.played_card].name)}: ${event_prompt()}.` for (let space_id of game.valid_spaces) { gen_action_space(space_id); } - } /*else { - view.prompt = 'Influence replaced.' - gen_action('done') - }*/ + } }, space(space) { push_undo() @@ -7986,9 +7380,6 @@ states.vm_switch_infl = { pass() { vm_next() } - /*done() { - vm_next() - }*/ } states.vm_malta_summit = { @@ -7996,14 +7387,9 @@ states.vm_malta_summit = { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { - /*if (game.phase === 1) {*/ - view.prompt = 'Malta Summit: roll a die.' - gen_action('roll') - /*} else { - view.prompt = 'Done.' - gen_action('done') - }*/ - }, + view.prompt = 'Malta Summit: roll a die.' + gen_action('roll') +}, roll() { clear_undo() let roll = roll_d6() @@ -8025,19 +7411,14 @@ states.vm_malta_summit = { if (game.comInfl[S_SZOMBATHELY] > 0 ) {game.valid_spaces.push(S_SZOMBATHELY)} if (game.comInfl[S_CLUJ_NAPOCA] > 0 ) {game.valid_spaces.push(S_CLUJ_NAPOCA)} if (game.comInfl[S_STARA_ZAGORA] > 0 ) {game.valid_spaces.push(S_STARA_ZAGORA)} - //game.vm_available_ops = 5 game.remove_opponent_infl = true vm_next() } else { log('Summit failed. Required 4 or more') - //game.phase++ vm_goto_step(vm_permanently_remove) } }, - /*done() { - vm_next() - }*/ } states.vm_modrow = { @@ -8070,13 +7451,8 @@ states.vm_nepotism = { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { - //if (game.phase === 1 ) { - view.prompt = 'Nepotism: roll a die.' - gen_action('roll') - /*} else { - view.prompt = 'Roll a die: done.' - gen_action('done') - }*/ + view.prompt = 'Nepotism: roll a die.' + gen_action('roll') }, roll() { clear_undo() @@ -8090,12 +7466,9 @@ states.vm_nepotism = { else { log(`Roll: D${roll} adds 1 SP`) game.vm_available_ops = 1} - //game.phase = 2 + vm_next() }, - /*done() { - vm_next() - }*/ } states.vm_new_years_eve_party = { @@ -8122,7 +7495,6 @@ states.vm_new_years_eve_party = { if (check_vp()) { return } - //game.table_cards.push(104) permanently_remove(C_NEW_YEARS_EVE_PARTY) vm_next() }, @@ -8206,15 +7578,10 @@ states.vm_nomenklatura_add = { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { - /*if (game.vm_available_ops === 0 || game.valid_spaces.length === 0 ) { - view.prompt = 'Nomenklatura. Add SPs: done.' - gen_action('done') - } else { */ - view.prompt = `Nomenklatura: add 3 SPs to any Elite space(s). ${pluralize(game.vm_available_ops, 'SP')} remaining.` - for (let space_id of game.valid_spaces) { - gen_action_space(space_id); - } - //} + view.prompt = `Nomenklatura: add 3 SPs to any Elite space(s). ${pluralize(game.vm_available_ops, 'SP')} remaining.` + for (let space_id of game.valid_spaces) { + gen_action_space(space_id); + } }, space(space) { push_undo() @@ -8228,14 +7595,6 @@ states.vm_nomenklatura_add = { vm_next() } }, -/* done() { - push_undo() - if (game.summary.length > 0) { - pop_summary() - log_br() - } - vm_next() - }*/ } states.vm_samizdat = { @@ -8258,11 +7617,8 @@ states.vm_samizdat = { }, pass() { push_undo() - //if (game.samizdat_card > 0) {game.state = 'vm_samizdat_finish'} - /*else { */ log('Did not set aside a card') vm_next() - //} } } @@ -8271,23 +7627,14 @@ states.vm_samizdat_finish = { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { - /*if (game.phase ) { - view.prompt = 'Samizdat: done.' - gen_action('done') - } else {*/ - view.prompt = 'Draw a replacement card.' - gen_action('draw') - //} + view.prompt = 'Draw a replacement card.' + gen_action('draw') }, draw() { clear_undo() game.democrat_hand.push(draw_card(game.strategy_deck)) vm_next() - //game.phase ++ }, - /*done() { - vm_next() - }*/ } states.vm_shock_therapy = { @@ -8307,10 +7654,7 @@ states.vm_shock_therapy = { 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') - } */ + } else { view.prompt = 'Shock Therapy: roll a die.' gen_action('roll') @@ -8364,7 +7708,6 @@ states.vm_shock_therapy = { vm_next() } else { log('C93 is unsuccessful. Required 3 or more') - //game.phase++ permanently_remove(93) vm_return() } @@ -8373,10 +7716,6 @@ states.vm_shock_therapy = { log('Passed') vm_return() } - /*done() { - permanently_remove(93) - vm_return() - }*/ } states.vm_social_democratic_platform_adopted = { @@ -8442,15 +7781,10 @@ states.vm_systematization = { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { - /*if (game.systematization === 0) { */ - view.prompt = 'Systematization: eliminate a space in Romania.' - for (let space_id of game.valid_spaces) { - gen_action_space(space_id); - } - /*} else { - view.prompt = 'Systematization: done.' - gen_action('done') - }*/ + view.prompt = 'Systematization: eliminate a space in Romania.' + for (let space_id of game.valid_spaces) { + gen_action_space(space_id); + } }, space(space) { push_undo() @@ -8460,9 +7794,6 @@ states.vm_systematization = { game.persistent_events.push(C_SYSTEMATIZATION) /*IS THIS STILL NEEDED?*/ vm_next() }, -/* done() { - vm_next() - } */ } states.vm_the_chinese_solution = { @@ -8574,41 +7905,19 @@ states.vm_the_tyrant_is_gone = { game.the_tyrant_is_gone = space game.valid_spaces = [] game.persistent_events.push(C_THE_TYRANT_IS_GONE) - - // vm_next() }, done () { vm_next() } } -/* -states.vm_tyrant_block ={ - get inactive() { - return `resolve ${clean_name(cards[this_card()].name)}.` - }, - prompt() { - view.prompt = `${clean_name(cards[this_card()].name)} has no effect after The Tyrant Has Gone.` - gen_action('done') - }, - done() { - push_undo() - vm_next() - } -}*/ - states.vm_the_wall_must_go = { get inactive() { return `resolve ${clean_name(cards[this_card()].name)}.` }, prompt() { - /*if (game.the_wall_must_go['dem_wins'] === 2 || game.the_wall_must_go['com_wins'] === 2) { - view.prompt = '"The Wall Must Go!" Rolls: done.' - gen_action('done') - } else { */ - view.prompt = ('The Wall Must Go! Roll a die.') - gen_action('roll') - //} + view.prompt = ('The Wall Must Go! Roll a die.') + gen_action('roll') }, roll() { clear_undo() @@ -8667,35 +7976,6 @@ states.vm_the_wall_must_go = { game.the_wall_must_go['com_roll'] = 0 } }, - /*done() { - if (game.the_wall_must_go['dem_wins'] === 2) { - game.persistent_events.push(86) - log('+3 VP') - game.vp += 3 - if (check_vp()) { - return - } - for (let i = 0; i < spaces.length; i++) { - let space = spaces[i] - if (space.country === 'East_Germany' && game.comInfl[i] > 0){ - game.valid_spaces.push(space.space_id) - } - } - if (!game.vm_infl_to_do) { - if (game.round_player === DEM) { - game.return = COM - } else { - game.return = DEM - } - } - if (game.active === DEM) {next_player()} - vm_next () - } else { - permanently_remove(86) - delete game.the_wall_must_go - vm_return() - } - }*/ } states.vm_warsaw_pact_summit = { @@ -8717,7 +7997,6 @@ states.vm_warsaw_pact_summit = { } game.vm_available_ops = 4 game.phase = 3 - //game.state = 'vm_add_infl' vm_next() }, support_check(){ @@ -8729,7 +8008,6 @@ states.vm_warsaw_pact_summit = { } } game.vm_available_ops = 2 - //game.state = 'vm_support_check_prep' vm_next() } } @@ -8775,12 +8053,6 @@ states.vm_we_are_the_people_add = { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { - /* if (!game.vm_influence_added[6]) { - view.prompt = '"We are the People!" Add SPs: done.' - gen_action('done') - return - }*/ - view.prompt = `"We are the People!": you must add the ${pluralize(game.vm_influence_added[S_LUTHERAN_CHURCH],'SP')} to spaces in Germany.` for (let space_id of game.valid_spaces) { gen_action_space(space_id); @@ -8798,14 +8070,6 @@ states.vm_we_are_the_people_add = { vm_next() } }, - /*done() { - push_undo() - if (game.summary.length > 0) { - pop_summary() - log_br() - } - vm_next() - }*/ } states.vm_workers_revolt = { @@ -8841,14 +8105,8 @@ states.vm_workers_revolt_finish = { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { - //if (game.selected_space > 0) { - view.prompt = `Target: ${spaces[game.selected_space].name_unique}. Roll a die.` - gen_action('roll') - /* } else { - view.prompt = 'Workers Revolt: done.' - gen_action('done') - }*/ - + view.prompt = `Target: ${spaces[game.selected_space].name_unique}. Roll a die.` + gen_action('roll') }, roll() { clear_undo() @@ -8870,11 +8128,8 @@ states.vm_workers_revolt_finish = { game.selected_space = 0 vm_next() }, - /*done() { - vm_next() - }*/ -} +} // ==================== TIANANMEN SQUARE TRACK STATES ===================== states.vm_tst_3_prep = { @@ -8906,10 +8161,7 @@ states.vm_tst_3 = { for (let card of game.valid_cards) { gen_action_card(card) } - } /*else { - view.prompt = 'Discard cards: done.' - gen_action('done') - }*/ + } }, card(card) { push_undo() @@ -8920,9 +8172,6 @@ states.vm_tst_3 = { vm_next() } }, - /*done() { - vm_next() - }*/ } states.vm_tst_4 = { @@ -8961,18 +8210,12 @@ states.vm_tst_4 = { states.vm_tst_6 = { inactive: 'make their free support check.', prompt() { - /* if (game.vm_available_ops === 0) { - view.prompt = 'Tiananmen Square Track award support check: done.' - gen_action('done') - return - } else {*/ - view.prompt = 'Tiananmen Square Track award: you have a free 2 Ops support check.' - for (let space_id of game.valid_spaces) { - if (space_id) { - gen_action_space(space_id); - } + view.prompt = 'Tiananmen Square Track award: you have a free 2 Ops support check.' + for (let space_id of game.valid_spaces) { + if (space_id) { + gen_action_space(space_id); } - //} + } }, space(space) { push_undo() @@ -8982,10 +8225,6 @@ states.vm_tst_6 = { } game.state = 'vm_tst_6_sc' }, - /*done () { - push_undo() - vm_next() - }*/ } states.vm_tst_6_sc = { @@ -9123,22 +8362,13 @@ states.vm_support_surges_1 = { }, draw() { if (game.active === DEM) { - //console.log('hand before', game.dem_pwr_hand) draw_cards(game.power_struggle_deck, game.dem_pwr_hand, game.com_pwr_hand, game.dem_pwr_hand.length+1, game.com_pwr_hand.length) game.temp = game.dem_pwr_hand[game.dem_pwr_hand.length-1] - //console.log('hand after', game.dem_pwr_hand, 'game.temp', game.temp) } else { - //console.log('hand before', game.com_pwr_hand) draw_cards(game.power_struggle_deck, game.dem_pwr_hand, game.com_pwr_hand, game.dem_pwr_hand.length, game.com_pwr_hand.length+1) game.temp = game.com_pwr_hand[game.com_pwr_hand.length-1] - //console.log('hand after', game.com_pwr_hand, 'game.temp', game.temp) } game.state = 'vm_support_surges_2' - - //game.phase = 0 - //log('Drew 2 cards') - //log('Surrenders initiative') - //vm_next() } } @@ -9167,10 +8397,6 @@ states.vm_support_surges_2 = { game.temp = game.com_pwr_hand[game.com_pwr_hand.length - 1] } game.state = 'vm_support_surges_3' - /*game.phase = 0 - log('Drew 2 cards') - log('Surrenders initiative') - vm_next()*/ } } |