From 48c6287c7a4251b9043877265cca98970e8f88be Mon Sep 17 00:00:00 2001 From: iainp5 Date: Sat, 12 Oct 2024 16:51:29 +0100 Subject: Removed name unique from actions --- data.js | 2 +- play.css | 4 +- play.js | 17 +- rules.js | 558 +++++++++++++++++++++++++++++++-------------------------------- 4 files changed, 292 insertions(+), 289 deletions(-) diff --git a/data.js b/data.js index 897de39..a4a64a8 100644 --- a/data.js +++ b/data.js @@ -83,7 +83,7 @@ const cards = [ {number: 2, period: 1, side: 'D', name: 'Solidarity Legalized*', ops: 4, remove: 1, playable: true, red: true}, {number: 3, period: 1, side: 'D', name: 'Walesa*', ops: 3, remove: 1, playable: false, red: false}, {number: 4, period: 1, side: 'D', name: 'Michnik*', ops: 1, remove: 1, playable: true, red: false}, - {number: 5, period: 1, side: 'D', name: 'General Strike', ops: 3, remove: 0, playable: true, red: false}, + {number: 5, period: 1, side: 'D', name: 'General Strike*', ops: 3, remove: 0, playable: true, red: false}, {number: 6, period: 1, side: 'C', name: 'Brought in for Questioning', ops: 3, remove: 0, playable: true, red: false}, {number: 7, period: 1, side: 'C', name: 'State Run Media*', ops: 2, remove: 1, playable: true, red: false}, {number: 8, period: 1, side: 'N', name: 'Prudence', ops: 4, remove: 0, playable: true, red: false}, diff --git a/play.css b/play.css index 0e7ef68..535ba84 100644 --- a/play.css +++ b/play.css @@ -143,7 +143,7 @@ header.your_turn { background-color: orange; } display: none; } -#events_panel, #played_card_panel, #table_panel, #samizdat_panel { +#hand_panel, #events_panel, #played_card_panel, #table_panel, #samizdat_panel, #opp_hand_panel, #power_panel, #ceausescu_panel { min-width: 200px; width: auto; /*display: inline-block;*/ @@ -571,7 +571,7 @@ left: 660px} .discard_card, .event_card { background-size: contain; height: 150px; - padding: 5px; + margin: 5px; border-radius: 5px; transition: transform .3s ease; } diff --git a/play.js b/play.js index f8d5cf5..f90e207 100644 --- a/play.js +++ b/play.js @@ -71,7 +71,7 @@ const spaceCharacteristicsElement = document.getElementById('space-characteristi spaceArea.style.width = width + 'px'; spaceArea.style.height = height + 'px'; spaceArea.style.zIndex = 2; - spaceArea.my_space = space.name_unique; + spaceArea.my_space = space.space_id; spaceArea.addEventListener('mousedown', on_click_space); //CREATE DEMOCRATIC INFLUENCE MARKERS FOR EACH SPACE @@ -80,7 +80,7 @@ const spaceCharacteristicsElement = document.getElementById('space-characteristi dem_img.style.display = 'none' dem_img.id=`${space.name_unique}_demInfl` dem_img.style.zIndex = 1 - dem_img.my_space = space.name_unique; + dem_img.my_space = space.space_id; dem_img.addEventListener('mousedown', on_click_space); spaceArea.appendChild(dem_img) @@ -91,7 +91,7 @@ const spaceCharacteristicsElement = document.getElementById('space-characteristi demInflValue.id=`${space.name_unique}_demInflValue` demInflValue.innerText=space.demInfl demInflValue.style.zIndex = 1 - demInflValue.my_space = space.name_unique; + demInflValue.my_space = space.space_id; demInflValue.addEventListener('mousedown', on_click_space); spaceArea.appendChild(demInflValue) @@ -101,7 +101,7 @@ const spaceCharacteristicsElement = document.getElementById('space-characteristi com_img.style.display='none' com_img.id=`${space.name_unique}_comInfl` com_img.style.zIndex = 1 - com_img.my_space = space.name_unique; + com_img.my_space = space.space_id; com_img.addEventListener('mousedown', on_click_space); spaceArea.appendChild(com_img) @@ -112,7 +112,7 @@ const spaceCharacteristicsElement = document.getElementById('space-characteristi comInflValue.id=`${space.name_unique}_comInflValue` comInflValue.innerText=space.comInfl comInflValue.style.zIndex = 1 - comInflValue.my_space = space.name_unique; + comInflValue.my_space = space.space_id; comInflValue.addEventListener('mousedown', on_click_space); spaceArea.appendChild(comInflValue) //} @@ -182,11 +182,12 @@ function is_card_enabled(card) { function on_click_space(evt) { if (evt.button === 0) { const space = evt.target.my_space; - //console.log('on_click_space_called with space:', space); + console.log('on_click_space_called with space:', space); if (send_action('infl', space)) { + console.log('send_action with infl:', space); evt.stopPropagation(); } else if (send_action('sc', space)) { - //console.log('send_action with sc:', space); + console.log('send_action with sc:', space); evt.stopPropagation(); } else { // console.log('send_action failed for space:', space); @@ -554,6 +555,8 @@ if (view.ceausescu_cards && view.ceausescu_cards.length > 0 && view.is_pwr_strug for (let c of view.ceausescu_cards) { let power_card = ui.power_cards[c] document.getElementById("ceausescu_hand").appendChild(power_card); + power_card.classList.remove('discard_card') + } } else { document.getElementById("ceausescu_panel").classList.add("hide") diff --git a/rules.js b/rules.js index 617dcb6..cf074d3 100644 --- a/rules.js +++ b/rules.js @@ -230,9 +230,9 @@ exports.view = function(state, player) { view.power_hand = game.com_pwr_hand.sort((a, b) => a - b) } - if (game.active === DEM) { + if (player === DEM) { view.samizdat = game.samizdat_card - } + } if (game.state === "game_over") { view.prompt = game.victory @@ -268,7 +268,7 @@ exports.view = function(state, player) { // === ACTIONS =========== function gen_action(action, argument) { -console.log('gen_action called with ', action, ' and ', argument) +//console.log('gen_action called with ', action, ' and ', argument) if (argument === undefined) { //console.log('argument undefined') view.actions[action] = 1 @@ -315,7 +315,7 @@ exports.action = function (state, player, action, arg) { // ============= GAME STATES ======================= states.com_init = { - inactive: 'place starting SPs', + inactive: 'place starting SPs.', prompt() { console.log('state:', game.state, 'game.valid_spaces', game.valid_spaces) if (game.available_ops == 0) { @@ -328,9 +328,7 @@ states.com_init = { view.prompt = `Place ${pluralize(game.available_ops,'starting SP')}.` } for (let space_id of game.valid_spaces) { - if (space_id) { - gen_action_infl(spaces[space_id].name_unique); - } + gen_action_infl(space_id); } }, infl(space) { @@ -375,7 +373,7 @@ states.dem_init = { view.prompt = `Place ${pluralize(game.available_ops,'starting SP')}.` } for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } }, infl(space) { @@ -714,7 +712,7 @@ states.finish_add_infl = { // Generate actions for valid spaces for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique) + gen_action_infl(space_id) } }, infl(space) { @@ -740,13 +738,13 @@ states.finish_support_check_prep = { } else { view.prompt = `Select a space. ${pluralize(game.available_ops, 'support check')} remaining.` for (let space_id of game.valid_spaces) { - gen_action_sc(spaces[space_id].name_unique) + gen_action_sc(space_id) } } }, sc(space) { push_undo() - game.selected_space = find_space_index(space) + 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)){ @@ -789,7 +787,7 @@ states.finish_do_support_check = { }, roll() { clear_undo() - do_sc(spaces[game.selected_space].name_unique) + do_sc(game.selected_space) game.available_ops-- if (game.available_ops === 0) { game.valid_spaces = [] @@ -812,7 +810,7 @@ states.add_influence = { // Generate actions for valid spaces for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } }, infl(space) { @@ -847,11 +845,19 @@ states.tiananmen_square_attempt = { states.tiananmen_square_attempt_success = { inactive: 'do Tiananmen Square Attempt.', prompt () { - view.prompt = 'Tiananmen Square Track attempt successful.' + if (game.vm_event > 200) { + view.prompt = 'Tiananmen Square Track attempt successful. Go to TST Award.' + } else { + view.prompt = 'Tiananmen Square Track attempt successful.' + } gen_action('done') }, done () { - end_round() + if (game.vm_event > 200) { + goto_vm(game.vm_event) + } else { + game.state = 'tiananmen_square_attempt_done' + } } } @@ -861,6 +867,17 @@ states.tiananmen_square_attempt_fail = { view.prompt = 'Tiananmen Square Track attempt failed.' gen_action('done') }, + done () { + game.state = 'tiananmen_square_attempt_done' + } +} + +states.tiananmen_square_attempt_done = { + inactive: 'do Tiananmen Square Attempt.', + prompt () { + view.prompt = 'Tiananmen Square Track attempt: done.' + gen_action('done') + }, done () { end_round() } @@ -964,13 +981,13 @@ states.support_check_prep = { view.prompt = `Select a space. ${pluralize(game.available_ops, 'support check')} remaining.` for (let space_id of game.valid_spaces) { - gen_action_sc(spaces[space_id].name_unique) + gen_action_sc(space_id) } } }, sc(space) { push_undo() - game.selected_space = find_space_index(space) + 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) @@ -1014,7 +1031,7 @@ states.do_support_check = { }, roll() { clear_undo() - do_sc(spaces[game.selected_space].name_unique) + do_sc(game.selected_space) game.available_ops-- if (game.available_ops === 0) { game.valid_spaces = [] @@ -1182,7 +1199,7 @@ states.the_crowd_turns_against_ceausescu_infl = { view.prompt = `Add SPs: ${game.vm_available_ops} remaining` for (let space of game.valid_spaces) { - gen_action_infl(spaces[space].name_unique) + gen_action_infl(space) } }, infl(space) { @@ -1506,7 +1523,7 @@ states.support_loss ={ view.prompt = `Support Loss: remove ${pluralize(game.available_ops,'SP')}.` for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique) + gen_action_infl(space_id) } } else if (game.phase === 1 && game.available_ops === 0 ) { view.prompt = 'Support Loss: finished.' @@ -1712,6 +1729,11 @@ states.the_tyrant_is_gone ={ if (game.active !== DEM) { next_player() } + if (game.round_player === DEM) { + game.return = COM + } else { + game.return = DEM + } log_h3(`C97`) game.vm_event = 97 goto_vm(game.vm_event) @@ -1726,7 +1748,7 @@ states.finish_scoring ={ } , done() { console.log('game.return_state', game.return_state) - log('Power Struggle resolved') /*At this point log card dicarded or permanently removed? */ + 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' return @@ -2173,24 +2195,22 @@ states.stasi_resolve_common_european_home = { function add_infl(space) { push_undo() console.log('adding infl to', 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_summary(`Added £ SP in %${clicked_space}`) + //log(`Added 1 influence in %${space}`) + log_summary(`Added £ SP in %${space}`) //If AHBR - check AHBR conditions if (game.persistent_events.includes(58)) { - if (spaces[clicked_space].country !== 'East_Germany'){ + if (spaces[space].country !== 'East_Germany'){ game.austria_hungary_border_reopened_tracker = false } } // Check Genscher - if (game.persistent_events.includes(63) && game.active === DEM && spaces[clicked_space].country === 'East_Germany') { + if (game.persistent_events.includes(63) && game.active === DEM && spaces[space].country === 'East_Germany') { game.available_ops-- log_summary(`(-1 op due to C63)`) - } else if (check_opp_control(clicked_space)) { + } else if (check_opp_control(space)) { game.available_ops -= 2 //Check if Austria Hungary Border Reopened was used to place last SP in a controlled space in East Germany. If so, game.available_op will be negative if (game.available_ops < 0) { @@ -2202,13 +2222,13 @@ function add_infl(space) { // Update influence values if (game.active === COM) { - game.comInfl[clicked_space]++ + game.comInfl[space]++ } else { - game.demInfl[clicked_space]++ + game.demInfl[space]++ } // Check whether spaces are controlled - check_control_change(clicked_space) + check_control_change(space) // Check Austria Hungary Border Reopened is true and condition has been met if (game.available_ops === 0 && game.active === DEM && game.persistent_events.includes(58) && game.austria_hungary_border_reopened_tracker) { @@ -2246,49 +2266,47 @@ 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_summary(`Removed £ SP from %${clicked_space}.`) + //log(`Removed 1 influence from %${space}.`) + log_summary(`Removed £ SP from %${space}.`) if (game.remove_opponent_infl === true) { if (game.active === COM) { - game.demInfl[clicked_space]-- - if (game.demInfl[clicked_space] === 0) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space); + game.demInfl[space]-- + if (game.demInfl[space] === 0) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space); } } else { - game.comInfl[clicked_space]-- - if (game.comInfl[clicked_space] === 0) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space); + game.comInfl[space]-- + if (game.comInfl[space] === 0) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space); } } - check_control_change(clicked_space) + check_control_change(space) } else { if (game.active === COM) { - game.comInfl[clicked_space]-- - if (game.comInfl[clicked_space] === 0) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space); + game.comInfl[space]-- + if (game.comInfl[space] === 0) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space); } } else { - game.demInfl[clicked_space]-- - if (game.demInfl[clicked_space] === 0) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space); + game.demInfl[space]-- + if (game.demInfl[space] === 0) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space); } } - check_control_change(clicked_space) + check_control_change(space) } game.available_ops-- } function do_sc(space) { clear_undo() - let clicked_space = find_space_index(space) - log_gap(`Support check: %${clicked_space}`) + log_gap(`Support check: %${space}`) //Check Helsinki Final Act - if (game.active === COM && game.persistent_events.includes(26) && (spaces[clicked_space].socio === 5 || spaces[clicked_space].socio === 6) ) { + if (game.active === COM && game.persistent_events.includes(26) && (spaces[space].socio === 5 || spaces[space].socio === 6) ) { log('+1 VP from C26') game.vp ++ if (check_vp()) { @@ -2341,29 +2359,29 @@ function do_sc(space) { // Events which modify SC rolls //Tear Gas - if (game.active === COM && game.persistent_events.includes(30) && spaces[clicked_space].socio === 6) { + if (game.active === COM && game.persistent_events.includes(30) && spaces[space].socio === 6) { roll ++ logi('+1 C30') permanently_remove(30) game.persistent_events = game.persistent_events.filter(n => n !== 30) } //FRG Embassies - if (game.active === DEM && spaces[clicked_space].region === 'Eastern Europe' && game.persistent_events.includes(74)) { + if (game.active === DEM && spaces[space].region === 'Eastern Europe' && game.persistent_events.includes(74)) { roll++ logi('+1 C74') } //GrenzTruppen - if (game.active === DEM && spaces[clicked_space].country === 'East_Germany' && game.persistent_events.includes(59)) { + if (game.active === DEM && spaces[space].country === 'East_Germany' && game.persistent_events.includes(59)) { roll-- logi('-1 C59') } //Stand Fast - if ((game.active === COM && game.stand_fast === DEM && check_dem_control(clicked_space)) || (game.active === DEM && game.stand_fast === COM && check_com_control(clicked_space))){ + if ((game.active === COM && game.stand_fast === DEM && check_dem_control(space)) || (game.active === DEM && game.stand_fast === COM && check_com_control(space))){ roll-- logi('-1 C100') } //Elena - if (game.active === DEM && game.persistent_events.includes(101) && spaces[clicked_space].country === 'Romania') { + if (game.active === DEM && game.persistent_events.includes(101) && spaces[space].country === 'Romania') { roll-- logi('-1 C101') } @@ -2379,7 +2397,7 @@ function do_sc(space) { const adj = count_adj(space) console.log('adj', adj) - if (game.active === COM && game.persistent_events.includes(9) && spaces[clicked_space].country === 'East_Germany') { + 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') roll += adj.com_adj @@ -2416,41 +2434,40 @@ function do_sc(space) { // Support check calcs log(`Total: ${roll}`) - const stability = spaces[find_space_index(space)].stability + const stability = spaces[space].stability logi(`-${stability*2} (stability * 2)`) const change_infl = Math.max(0, roll - stability*2) if (change_infl > 0) { log_msg_gap(`Change: ${change_infl} SP`) - let clicked_space = find_space_index(space) if(game.active === DEM) { - if (change_infl > game.comInfl[clicked_space]) { - const residual = change_infl - game.comInfl[clicked_space] - game.comInfl[clicked_space] = 0 - game.demInfl[clicked_space] += residual + if (change_infl > game.comInfl[space]) { + const residual = change_infl - game.comInfl[space] + game.comInfl[space] = 0 + game.demInfl[space] += residual } else { - game.comInfl[clicked_space] -= change_infl + game.comInfl[space] -= change_infl } - if (game.comInfl[clicked_space] === 0) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space) + if (game.comInfl[space] === 0) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space) } } else { - if (change_infl > game.demInfl[clicked_space]) { - const residual = change_infl - game.demInfl[clicked_space] - game.demInfl[clicked_space] = 0 - game.comInfl[clicked_space] += residual + if (change_infl > game.demInfl[space]) { + const residual = change_infl - game.demInfl[space] + game.demInfl[space] = 0 + game.comInfl[space] += residual } else { - game.demInfl[clicked_space] -= change_infl + game.demInfl[space] -= change_infl } - if (game.demInfl[clicked_space] === 0) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space) + if (game.demInfl[space] === 0) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space) } } - check_control_change(clicked_space) + check_control_change(space) } else { log_msg_gap('Change: 0 SP') } - if (game.active === COM && game.persistent_events.includes(39) && spaces[clicked_space].space_id === 66) { + if (game.active === COM && game.persistent_events.includes(39) && spaces[space].space_id === 66) { log_msg_gap('+1 VP from C39') game.vp++ if (check_vp()) { @@ -2677,8 +2694,8 @@ function do_valid_cards() { valid_cards(game.com_pwr_hand, presence.com_leaders)} } -function count_adj(name_unique) { - const space = spaces[find_space_index(name_unique)] +function count_adj(id) { + const space = spaces[id] let dem_adj = 0 let com_adj = 0 @@ -2808,7 +2825,7 @@ function do_tst_attempt() { // TIANANMEN SQUARE ATTEMPT game.return = game.active - game.return_state = 'tiananmen_square_attempt_success' + game.return_state = 'tiananmen_square_attempt_done' if (game.active === DEM) { game.dem_tst_attempted_this_turn = 1 if (roll >= dem_tst_req[game.dem_tst_position]) { @@ -2833,9 +2850,9 @@ function do_tst_attempt() { } //Check if TST events occur - if (game.dem_tst_position === 3 && game.com_tst_position < 3) {goto_vm(203)} - else if (game.dem_tst_position === 4 && game.com_tst_position < 4) {goto_vm(204)} - else {game.state = 'tiananmen_square_attempt_success'} + if (game.dem_tst_position === 3 && game.com_tst_position < 3) {game.vm_event = 203} + else if (game.dem_tst_position === 4 && game.com_tst_position < 4) {game.vm_event = 204} + game.state = 'tiananmen_square_attempt_success' } else { log(`${dem_tst_req[game.dem_tst_position]} required: fail`) game.dem_tst_attempted = 1 @@ -2846,12 +2863,6 @@ function do_tst_attempt() { if (roll >= com_tst_req[game.com_tst_position]) { log(`${com_tst_req[game.com_tst_position]} required: success`) game.com_tst_position++ - - //Check if they have reached the final box - Chinese Solution playable - if (game.com_tst_position === 8) { - game.playable_cards.push(96) - } - game.com_tst_attempted = 0 //Check if they have reached box 7 or 8 first @@ -2871,9 +2882,9 @@ function do_tst_attempt() { } //Check if TST events occur - if (game.com_tst_position === 3 && game.dem_tst_position < 3) {goto_vm(203)} - else if (game.com_tst_position === 4 && game.dem_tst_position < 4) {goto_vm(204)} - else {game.state = 'tiananmen_square_attempt_success'} + if (game.com_tst_position === 3 && game.dem_tst_position < 3) {game.vm_event = 203} + else if (game.com_tst_position === 4 && game.dem_tst_position < 4) {game.vm_event = 204} + game.state = 'tiananmen_square_attempt_success' } else { log(`${com_tst_req[game.com_tst_position]} required: fail`) game.com_tst_attempted = 1 @@ -3253,6 +3264,10 @@ function event_is_playable(card) { else if (game.persistent_events.includes(13) && card === 21 && game.active === DEM) { return false } + //Check for The Chinese Solution + else if (game.com_tst_position === 8 && card === 96) { + return true + } //Then check normally else if (cards[card].playable) { return true @@ -3482,6 +3497,13 @@ function end_round() { // Resolve end action round //Stasi check if(game.round_player === COM && game.persistent_events.includes(13)) { + //If in Honecker, turn ends + if (game.round === 8) { + clear_undo() + game.state = 'end_turn_4_5_4' + return + } + //Otherwise go to Stasi game.round_player = DEM if (game.active !== DEM) { next_player() @@ -4610,54 +4632,52 @@ function vm_take_control_prep() { } function vm_take_control(space) { - let clicked_space = find_space_index(space) if (game.active === DEM) { - let current_infl = game.demInfl[clicked_space] - let opponent_infl = game.comInfl[clicked_space] - let stability = spaces[clicked_space].stability + let current_infl = game.demInfl[space] + let opponent_infl = game.comInfl[space] + let stability = spaces[space].stability if ((current_infl - opponent_infl) < stability) { - game.demInfl[clicked_space] += stability - current_infl + opponent_infl - //game.pieces[clicked_space].demCtrl = 1 - //game.pieces[clicked_space].comCtrl = 0 + 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[clicked_space] - let opponent_infl = game.demInfl[clicked_space] - let stability = spaces[clicked_space].stability + let current_infl = game.comInfl[space] + let opponent_infl = game.demInfl[space] + let stability = spaces[space].stability if ((current_infl - opponent_infl) < stability) { - game.comInfl[clicked_space] += stability - current_infl + opponent_infl - //game.pieces[clicked_space].comCtrl = 1 - //game.pieces[clicked_space].demCtrl = 0 + 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 !== clicked_space) - log(`Took control of %${clicked_space}`) + game.valid_spaces = game.valid_spaces.filter(id => id !== space) + log(`Took control of %${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)) - const clicked_space = find_space_index(space) - //log(`Added 1 influence in %${clicked_space}.`) + //log(`Added 1 influence in %${space}.`) - log_summary(`Added £ SP in %${clicked_space}.`) + log_summary(`Added £ SP in %${space}.`) //If AHBR - check AHBR condition if (game.persistent_events.includes(58)) { - if (spaces[clicked_space].country !== 'East_Germany'){ + if (spaces[space].country !== 'East_Germany'){ game.austria_hungary_border_reopened_tracker = false } } // Check Genscher - if (game.persistent_events.includes(63) && game.active === DEM && spaces[clicked_space].country === 'East_Germany') { + if (game.persistent_events.includes(63) && game.active === DEM && spaces[space].country === 'East_Germany') { game.vm_available_ops-- log_summary(`(-1 op due to C63)`) - } else if (check_opp_control(clicked_space)) { + } else if (check_opp_control(space)) { game.vm_available_ops -= 2 //Check if Austria Hungary Border Reopened was used to place last SP in a controlled space in East Germany. If so, game.vm_available_op will be negative if (game.vm_available_ops < 0) { @@ -4669,13 +4689,13 @@ function vm_do_add_infl(space) { // Update influence values if (game.active === COM) { - game.comInfl[clicked_space]++ + game.comInfl[space]++ } else { - game.demInfl[clicked_space]++ + game.demInfl[space]++ } // Check whether spaces are controlled - check_control_change(clicked_space) + check_control_change(space) console.log('before check, ahbr in events', game.persistent_events.includes(58), 'tracker', game.austria_hungary_border_reopened_tracker) // Check Austria Hungary Border Reopened is true and condition has been met @@ -4715,23 +4735,22 @@ 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 %${space}.`) - log_summary(`Added £ SP in %${clicked_space}.`) + log_summary(`Added £ SP in %${space}.`) // Update influence values if (game.active === COM) { - game.comInfl[clicked_space]++ + game.comInfl[space]++ } else { - game.demInfl[clicked_space]++ + game.demInfl[space]++ } game.vm_available_ops-- // Check whether spaces are controlled - check_control_change(clicked_space) + check_control_change(space) - //console.log('game pieces:', game.pieces[clicked_space]) + //console.log('game pieces:', game.pieces[space]) } function vm_add_infl() { @@ -4751,16 +4770,15 @@ function vm_add_x_infl() { function vm_do_add_x_infl(space) { push_undo() - const clicked_space = find_space_index(space) - log(`Added ${game.vm_available_ops} SPs in %${clicked_space}.`) + log(`Added ${game.vm_available_ops} SPs in %${space}.`) if (game.active === COM) { - game.comInfl[clicked_space] += game.vm_available_ops + game.comInfl[space] += game.vm_available_ops } else { - game.demInfl[clicked_space] += game.vm_available_ops + game.demInfl[space] += game.vm_available_ops } - check_control_change(clicked_space) + check_control_change(space) game.vm_available_ops = 0 game.valid_spaces = [] } @@ -4773,34 +4791,33 @@ 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 %${space}.`) - log_summary(`Added £ SP in %${clicked_space}.`) + log_summary(`Added £ SP in %${space}.`) game.vm_available_ops -- if (!game.vm_influence_added) { game.vm_influence_added = {}; } - if (!game.vm_influence_added[clicked_space]) { - game.vm_influence_added[clicked_space] = 0; + if (!game.vm_influence_added[space]) { + game.vm_influence_added[space] = 0; } if (game.active === COM) { - game.comInfl[clicked_space] ++ + game.comInfl[space] ++ } else { - game.demInfl[clicked_space] ++ + game.demInfl[space] ++ } - game.vm_influence_added[clicked_space] ++ + game.vm_influence_added[space] ++ //console.log('valid_spaces before update', game.valid_spaces) - //console.log('influence added:', game.vm_influence_added[clicked_space], 'max infl', max_infl) - if (game.vm_influence_added[clicked_space] === max_infl) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space); + //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); } - check_control_change(clicked_space) + check_control_change(space) if (game.vm_available_ops === 0) {game.valid_spaces = [] } } @@ -4823,90 +4840,88 @@ 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_summary(`Removed £ SP from %${clicked_space}.`) + //log(`Removed 1 influence from %${space}.`) + log_summary(`Removed £ SP from %${space}.`) if (!game.vm_influence_added) { game.vm_influence_added = {}; } - if (!game.vm_influence_added[clicked_space]) { - game.vm_influence_added[clicked_space] = 0; + if (!game.vm_influence_added[space]) { + game.vm_influence_added[space] = 0; } if (game.remove_opponent_infl === true) { if (game.active === COM) { - game.demInfl[clicked_space]-- - if (game.demInfl[clicked_space] === 0) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space); + game.demInfl[space]-- + if (game.demInfl[space] === 0) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space); } } else { - game.comInfl[clicked_space]-- - if (game.comInfl[clicked_space] === 0) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space); + game.comInfl[space]-- + if (game.comInfl[space] === 0) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space); } } } else { if (game.active === COM) { - game.comInfl[clicked_space]-- - if (game.comInfl[clicked_space] === 0) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space); + game.comInfl[space]-- + if (game.comInfl[space] === 0) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space); } } else { - game.demInfl[clicked_space]-- - if (game.demInfl[clicked_space] === 0) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space); + game.demInfl[space]-- + if (game.demInfl[space] === 0) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space); } } } - check_control_change(clicked_space) - game.vm_influence_added[clicked_space]++ + check_control_change(space) + game.vm_influence_added[space]++ game.vm_available_ops-- if (game.vm_available_ops===0) {game.valid_spaces = []} } function vm_do_remove_x_infl(space) { push_undo() - const clicked_space = find_space_index(space) if (game.remove_opponent_infl) { if (game.active === COM) { - if (game.demInfl[clicked_space] >= game.vm_available_ops) { - game.demInfl[clicked_space] -= game.vm_available_ops + if (game.demInfl[space] >= game.vm_available_ops) { + game.demInfl[space] -= game.vm_available_ops } else { - game.vm_available_ops = game.demInfl[clicked_space] - game.demInfl[clicked_space] -= game.vm_available_ops + game.vm_available_ops = game.demInfl[space] + game.demInfl[space] -= game.vm_available_ops } } else { - if (game.comInfl[clicked_space] >= game.vm_available_ops) { - game.comInfl[clicked_space] -= game.vm_available_ops + if (game.comInfl[space] >= game.vm_available_ops) { + game.comInfl[space] -= game.vm_available_ops } else { - game.vm_available_ops = game.comInfl[clicked_space] - game.comInfl[clicked_space] -= game.vm_available_ops + game.vm_available_ops = game.comInfl[space] + game.comInfl[space] -= game.vm_available_ops } } } else { if (game.active === COM) { - if (game.comInfl[clicked_space] >= game.vm_available_ops) { - game.comInfl[clicked_space] -= game.vm_available_ops + if (game.comInfl[space] >= game.vm_available_ops) { + game.comInfl[space] -= game.vm_available_ops } else { - game.vm_available_ops = game.comInfl[clicked_space] - game.comInfl[clicked_space] -= game.vm_available_ops + game.vm_available_ops = game.comInfl[space] + game.comInfl[space] -= game.vm_available_ops } } else { - if (game.demInfl[clicked_space] >= game.vm_available_ops) { - game.demInfl[clicked_space] -= game.vm_available_ops + if (game.demInfl[space] >= game.vm_available_ops) { + game.demInfl[space] -= game.vm_available_ops } else { - game.vm_available_ops = game.demInfl[clicked_space] - game.demInfl[clicked_space] -= game.vm_available_ops + game.vm_available_ops = game.demInfl[space] + game.demInfl[space] -= game.vm_available_ops } } } - log(`Removed ${game.vm_available_ops} SPs from %${clicked_space}`) - check_control_change(clicked_space) + log(`Removed ${game.vm_available_ops} SPs from %${space}`) + check_control_change(space) game.vm_available_ops = 0 game.valid_spaces = [] @@ -4921,8 +4936,7 @@ function vm_remove_limited_opp_infl() { function vm_do_remove_limited_infl(space, max_infl) { push_undo() - const clicked_space = find_space_index(space) - log(`Removed SP from %${clicked_space}.`) + log(`Removed SP from %${space}.`) game.vm_available_ops -- @@ -4930,29 +4944,29 @@ function vm_do_remove_limited_infl(space, max_infl) { game.vm_influence_added = {}; } - if (!game.vm_influence_added[clicked_space]) { - game.vm_influence_added[clicked_space] = 0; + if (!game.vm_influence_added[space]) { + game.vm_influence_added[space] = 0; } if (game.active === COM) { - game.demInfl[clicked_space] -- - if (game.demInfl[clicked_space] === 0) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space) + game.demInfl[space] -- + if (game.demInfl[space] === 0) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space) } } else { - game.comInfl[clicked_space] -- - if (game.comInfl[clicked_space] === 0) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space) + game.comInfl[space] -- + if (game.comInfl[space] === 0) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space) } } - game.vm_influence_added[clicked_space] ++ + game.vm_influence_added[space] ++ - if (game.vm_influence_added[clicked_space] === max_infl) { - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space); + if (game.vm_influence_added[space] === max_infl) { + game.valid_spaces = game.valid_spaces.filter(id => id !== space); } - check_control_change(clicked_space) + check_control_change(space) if (game.vm_available_ops === 0) {game.valid_spaces = []} } @@ -4963,27 +4977,26 @@ function vm_remove_all_infl() { function vm_do_remove_all_infl(space) { push_undo() - const clicked_space = find_space_index(space) - log(`Removed all SP from %${clicked_space}.`) + log(`Removed all SP from %${space}.`) if (game.remove_opponent_infl === true) { if (game.active === COM) { - game.demInfl[clicked_space] = 0 + game.demInfl[space] = 0 } else { - game.comInfl[clicked_space] = 0 + game.comInfl[space] = 0 } - check_control_change(clicked_space) + check_control_change(space) } else { if (game.active === COM) { - game.comInfl[clicked_space] = 0 + game.comInfl[space] = 0 } else { - game.demInfl[clicked_space] = 0 + game.demInfl[space] = 0 } - check_control_change(clicked_space) + check_control_change(space) } game.vm_available_ops -- - game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space) + game.valid_spaces = game.valid_spaces.filter(id => id !== space) } function vm_replace_all_infl(space_id) { @@ -5013,14 +5026,14 @@ function vm_support_check_modified() { game.state = 'vm_support_check_prep' } -function vm_switch_infl(space){ +function vm_switch_infl(id){ push_undo() - let clicked_space = find_space_index(space) - game.demInfl[clicked_space] -= game.vm_available_ops - game.comInfl[clicked_space] += game.vm_available_ops - log(`Replaced ${pluralize(game.vm_available_ops,'SP')} in ${spaces[clicked_space].name_unique}`) + + game.demInfl[id] -= game.vm_available_ops + game.comInfl[id] += game.vm_available_ops + log(`Replaced ${pluralize(game.vm_available_ops,'SP')} in %${id}`) game.vm_available_ops = 0 - check_control_change(clicked_space) + check_control_change(id) } /* ===================== EVENT SPECIFIC FUNCTIONS ========== */ @@ -5210,37 +5223,11 @@ function vm_eliminate(space_id) { //console.log('adjacency before: Iasi', game.pieces[53].adjacent, 'Ploesti:', game.pieces[59].adjacent, 'Bucharesti:', game.pieces[61].adjacent) - // Remove clicked_space from the adjacency lists of its adjacent spaces - /* adjacent_spaces.forEach(s => { - game.pieces[s].adjacent = spaces[s].adjacent.filter(id => id !== space_id); - }); - - //console.log('adjacency after: Iasi', game.pieces[53].adjacent, 'Ploesti:', game.pieces[59].adjacent, 'Bucharesti:', game.pieces[61].adjacent) - - // Connect adjacent spaces to each other - // No longer used - spaces done dynamically -/* - for (let i = 0; i < adjacent_spaces.length; i++) { - for (let j = i + 1; j < adjacent_spaces.length; j++) { - console.log(' checking i,', spaces[adjacent_spaces[i]].name, 'j', spaces[adjacent_spaces[j]].name) - if (!game.pieces[adjacent_spaces[i]].adjacent.includes(adjacent_spaces[j])) { - game.pieces[adjacent_spaces[i]].adjacent.push(adjacent_spaces[j]); - } - if (!game.pieces[adjacent_spaces[j]].adjacent.includes(adjacent_spaces[i])) { - game.pieces[adjacent_spaces[j]].adjacent.push(adjacent_spaces[i]); - } - } - } - - console.log('adjacency after addition: Iasi', game.pieces[53].adjacent, 'Ploesti:', game.pieces[59].adjacent, 'Bucharesti:', game.pieces[61].adjacent) - // Clear the adjacency list of the clicked space - game.pieces[space_id].adjacent = []; -*/ // Eliminate the democrat influence and move the communist influence to Bucuresti game.demInfl[space_id] = 0 game.comInfl[61] += game.comInfl[space_id] if (game.comInfl[space_id] > 0 ) { - log(`${game.comInfl[space_id]} Communist SP relocated to Bucuresti`) + log(`${pluralize(game.comInfl[space_id],'Communist SP')} relocated to %61`) } game.comInfl[space_id] = 0 @@ -5965,7 +5952,7 @@ states.vm_take_control = { } else if (game.vm_available_ops > 0 ) { view.prompt = `${clean_name(cards[this_card()].name)}: take control of ${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } } else { view.prompt = `${clean_name(cards[this_card()].name)}. Take control: done.` @@ -5994,7 +5981,7 @@ states.vm_add_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: add ${pluralize(game.vm_available_ops,'SP')}${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique) + gen_action_infl(space_id) } } else { view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.` @@ -6031,7 +6018,7 @@ states.vm_add_infl_free = { view.prompt = `${clean_name(cards[this_card()].name)}: add ${game.vm_available_ops} SPs to ${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } } else { view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.` @@ -6065,7 +6052,7 @@ states.vm_add_x_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: Add ${game.vm_available_ops} SPs to ${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique) + gen_action_infl(space_id) } } else { view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.` @@ -6075,6 +6062,9 @@ states.vm_add_x_infl = { infl(space) { push_undo() vm_do_add_x_infl(space) + if (game.vm_event === 105) { + vm_next() + } //game.vm_event_done = true //vm_next() }, @@ -6097,7 +6087,7 @@ states.vm_add_limited_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: add ${pluralize(game.vm_available_ops,'SP')} to ${event_prompt()}.` } for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } } else { view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.` @@ -6141,14 +6131,13 @@ states.vm_remove_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: remove ${pluralize(game.vm_available_ops,'SP')}${event_prompt()}.` } for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } }, infl(space) { push_undo() vm_do_remove_infl(space) - const clicked_space = find_space_index(space) - game.vm_active_country = spaces[clicked_space].country + game.vm_active_country = spaces[space].country /*if (game.vm_available_ops === 0 || game.valid_spaces.length === 0) { vm_next() }*/ @@ -6176,7 +6165,7 @@ states.vm_remove_x_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: remove ${pluralize(game.vm_available_ops,'SP')} from ${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } } else { view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.` @@ -6201,7 +6190,7 @@ states.vm_remove_limited_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: remove ${pluralize(game.vm_available_ops,'SP')}${event_prompt()}, no more than ${game.vm_max_infl} per space.` for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } } 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.` @@ -6236,7 +6225,7 @@ states.vm_remove_all_infl = { } else if (game.vm_available_ops > 0) { view.prompt = `${clean_name(cards[this_card()].name)}: remove all SPs from ${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } } else { view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.` @@ -6245,8 +6234,7 @@ states.vm_remove_all_infl = { }, infl(space) { vm_do_remove_all_infl(space) - const clicked_space = find_space_index(space) - game.vm_active_country = spaces[clicked_space].country + game.vm_active_country = spaces[space].country /*if (game.vm_available_ops === 0 || game.valid_spaces.length === 0) { vm_next() }*/ @@ -6272,13 +6260,13 @@ states.vm_support_check_prep = { } for (let space_id of game.valid_spaces) { if (!space_id) continue - gen_action_sc(spaces[space_id].name_unique); + gen_action_sc(space_id); } } }, sc(space) { push_undo() - game.selected_space = find_space_index(space) + game.selected_space = space // Check for Austria-Hungary Border Reopened - check on first support check only //First check for Monday Demonstrations - support checks will always be in East Germany @@ -6319,13 +6307,13 @@ states.vm_ceh_support_check_prep = { view.prompt = `Select a space. ${pluralize(game.vm_available_ops, 'support check')} remaining.` for (let space_id of game.valid_spaces) { - gen_action_sc(spaces[space_id].name_unique) + gen_action_sc(space_id) } } }, sc(space) { push_undo() - game.selected_space = find_space_index(space) + 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) @@ -6355,7 +6343,7 @@ states.vm_ceh_do_support_check = { }, roll() { clear_undo() - do_sc(spaces[game.selected_space].name_unique) + do_sc(game.selected_space) game.vm_available_ops-- if (game.vm_available_ops === 0) { @@ -6396,13 +6384,13 @@ states.vm_1_support_check_prep = { for (let space_id of game.valid_spaces) { if (!space_id) continue - gen_action_sc(spaces[space_id].name_unique); + gen_action_sc(space_id); } } }, sc(space) { push_undo() - game.selected_space = find_space_index(space) + game.selected_space = space game.state = 'vm_do_support_check' }, done () { @@ -6419,7 +6407,7 @@ states.vm_do_support_check = { }, roll() { clear_undo() - do_sc(spaces[game.selected_space].name_unique) + do_sc(game.selected_space) game.vm_available_ops-- if (game.vm_available_ops === 0) { game.valid_spaces = [] @@ -7263,13 +7251,17 @@ states.vm_kremlin_coup_take_control = { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { - if (game.valid_spaces.length === 0){ + if (game.valid_spaces.includes(game.systematization)) { + view.prompt = `Kremlin Coup! ${country_name(game.vm_active_country)}'s Elite space no longer exists.` + gen_action('done') + } + else if (game.valid_spaces.length === 0){ view.prompt = `Kremlin Coup! ${country_name(game.vm_active_country)}'s Elite space is already controlled.` gen_action('done') } else { view.prompt = `Kremlin Coup! Take control of the Elite space in ${country_name(game.vm_active_country)}.` for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } } }, @@ -7300,10 +7292,10 @@ states.vm_kremlin_coup_sc_prep = { }, prompt() { view.prompt = `Kremlin Coup! Conduct a support check in ${country_name(game.vm_active_country)}'s Bureaucratic space.` - gen_action_sc(spaces[game.selected_space].name_unique); + gen_action_sc(game.selected_space); }, sc(space) { - //game.selected_space = find_space_index(space) + //game.selected_space = space game.state = 'vm_kremlin_coup_sc' } } @@ -7316,7 +7308,7 @@ states.vm_kremlin_coup_sc = { }, roll() { clear_undo() - do_sc(spaces[game.selected_space].name_unique) + do_sc(game.selected_space) if (game.temp.length > 0 ){ game.state = 'vm_kremlin_coup_choose_country' } else { @@ -7378,7 +7370,7 @@ states.vm_switch_infl = { /*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_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } } /*else { view.prompt = 'Influence replaced.' @@ -7592,7 +7584,7 @@ states.vm_nomenklatura_remove = { view.prompt = 'Nomenklatura: remove all Democratic SPs from Elite spaces.' for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } } }, @@ -7619,7 +7611,7 @@ states.vm_nomenklatura_add = { } 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_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } } }, @@ -7821,7 +7813,7 @@ states.vm_systematization = { /*if (game.systematization === 0) { */ view.prompt = 'Systematization: eliminate a space in Romania.' for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } /*} else { view.prompt = 'Systematization: done.' @@ -7830,9 +7822,9 @@ states.vm_systematization = { }, infl(space) { push_undo() - vm_eliminate(find_space_index(space)) + vm_eliminate(space) game.valid_spaces = [] - game.systematization = find_space_index(space) + game.systematization = space game.persistent_events.push(69) vm_next() }, @@ -7936,7 +7928,7 @@ states.vm_the_tyrant_is_gone = { view.prompt = 'The Tyrant is Gone: Select a space in Romania for the Ceausescus to flee to.' for (let space_id of game.valid_spaces) { if (!space_id) continue - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } } else { view.prompt = 'Select a space: done.' @@ -7945,8 +7937,9 @@ states.vm_the_tyrant_is_gone = { }, infl(space) { push_undo() - log(`The Ceausescus flee to %${find_space_index(space)}`) - game.the_tyrant_is_gone = find_space_index(space) + log(`The Ceausescus flee to %${space}`) + game.the_tyrant_is_gone = space + game.valid_spaces = [] game.persistent_events.push(97) }, done () { @@ -8117,7 +8110,7 @@ states.vm_we_are_the_people_remove = { view.prompt = '"We are the People!": remove up to 4 SPs from the Lutherian Church.' gen_action('done') for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } } else { view.prompt = '"We are the People!" Remove SPs: done.' @@ -8155,7 +8148,7 @@ states.vm_we_are_the_people_add = { view.prompt = `"We are the People!": you must add the ${pluralize(game.vm_influence_added[6],'SP')} to spaces in Germany.` gen_action('done') for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } }, infl(space) { @@ -8177,13 +8170,22 @@ states.vm_workers_revolt = { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { + if (game.valid_spaces.length === 0 ) { + view.prompt = 'Workers Revolt: no valid spaces to select.' + gen_action('pass') + return + } view.prompt = 'Workers Revolt: select a Worker Space in a country your opponent has power.' for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique) + gen_action_infl(space_id) } }, + pass() { + push_undo() + vm_next() + }, infl(space) { - game.selected_space = find_space_index(space) + game.selected_space = space log(`Chose %${game.selected_space}`) game.state = 'vm_workers_revolt_finish' } @@ -8208,7 +8210,7 @@ states.vm_workers_revolt_finish = { clear_undo() let roll = Math.floor(Math.random() * 6) + 1 log(`Roll: D${roll}`) - let adj = count_adj(spaces[game.selected_space].name_unique) + let adj = count_adj(game.selected_space) if (game.active === DEM) { log(`-${adj.com_adj} from opponent controlled spaces`) roll -= adj.com_adj @@ -8285,10 +8287,10 @@ states.vm_tst_4 = { gen_action('done') return } - view.prompt = 'Tiananmen Square Track award: select a space to remove SPs' + view.prompt = `Tiananmen Square Track award: remove ${pluralize(game.vm_available_ops,'SP')}.` for (let space_id of game.valid_spaces) { - gen_action_infl(spaces[space_id].name_unique); + gen_action_infl(space_id); } }, infl(space) { @@ -8314,14 +8316,14 @@ states.vm_tst_6 = { 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_sc(spaces[space_id].name_unique); + gen_action_sc(space_id); } } } }, sc(space) { push_undo() - game.selected_space = find_space_index(space) + game.selected_space = space if (game.active === DEM && game.persistent_events.includes(58) && spaces[space].country === "East_Germany") { game.austria_hungary_border_reopened_tracker = true } @@ -8340,7 +8342,7 @@ states.vm_tst_6_sc = { }, roll() { clear_undo() - do_sc(spaces[game.selected_space].name_unique) + do_sc(game.selected_space) game.vm_available_ops-- game.valid_spaces = [] game.state = 'vm_tst_6' @@ -9395,8 +9397,6 @@ CODE[110] = [ // Malta Summit* // #endregion - - // ============= TIANANMEN SQUARE TRACK AWARDS ==================== CODE[203] = [//Tiananmen Square space 3 award [vm_tst_3], -- cgit v1.2.3