From db5c4c7f8e937b6527a04b097f1c4c61f94ae9c5 Mon Sep 17 00:00:00 2001 From: iainp5 Date: Fri, 11 Oct 2024 09:05:28 +0100 Subject: Updates to SC log --- events.txt | 2 +- play.js | 2 +- rules.js | 106 +++++++++++++++++++++++++++++++++++++------------------------ 3 files changed, 66 insertions(+), 44 deletions(-) diff --git a/events.txt b/events.txt index 5855621..7f83643 100644 --- a/events.txt +++ b/events.txt @@ -25,7 +25,7 @@ valid_spaces_country 'Poland' prompt 'any space(s) in Poland' add_infl_free 4 valid_spaces_country_sc 'Poland' -prompt 'Make Support Checks in Poland' +prompt 'make Support Checks in Poland' support_check 2 permanently_remove diff --git a/play.js b/play.js index 9f4c107..be10507 100644 --- a/play.js +++ b/play.js @@ -238,7 +238,7 @@ function on_log(text) { // eslint-disable-line no-unused-vars text = text.replace(/P(\d+)/g, sub_power_card_name) text = text.replace(/V(\d+)/g, sub_power_card_value) text = text.replace(/%(\d+)/g, sub_space_name) - text = text.replace(/\b[D][1-6]\b/g, sub_die) + text = text.replace(/D[1-6]/g, sub_die) if (text.match(/^\.h1/)) { diff --git a/rules.js b/rules.js index a00f77f..8250dfc 100644 --- a/rules.js +++ b/rules.js @@ -1406,7 +1406,7 @@ states.power_struggle = { }, roll () { let roll = Math.floor(Math.random() * 6) + 1 - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) if (roll >= power_cards[game.played_power_card].value) { log('Initiative roll successful') game.phase = 0 @@ -1516,7 +1516,7 @@ states.support_loss ={ let roll = Math.floor(Math.random() * 6) + 1 let rally_win = 0 let petition_win = 0 - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) if ((game.played_power_card >= 25 && game.played_power_card <= 30) || game.played_power_card === 53) { rally_win = 2} if ((game.played_power_card >= 31 && game.played_power_card <= 36) || game.played_power_card === 54) { petition_win = 2} let modified_roll = roll + game.raised_stakes + rally_win - petition_win @@ -1585,7 +1585,7 @@ states.vp_roll = { }, roll () { let roll = Math.floor(Math.random() * 6) + 1 - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) let rally_win = 0 let petition_win = 0 if ((game.played_power_card >= 25 && game.played_power_card <= 30) || game.played_power_card === 53) {rally_win = 2} @@ -1906,12 +1906,12 @@ states.general_strike = { roll() { clear_undo() let roll = Math.floor(Math.random() * 6) + 1 - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) - log(`+${game.available_ops} from card ops`) + log(`+${game.available_ops} ops`) let total = roll + game.available_ops - log(`Modified total: ${total}`) + log(`TOTAL: ${total}`) if (total > 5) { log('The strike is over.') @@ -2285,7 +2285,7 @@ function do_sc(space) { // Continue with Support Check Logic let roll = Math.floor(Math.random() * 6) + 1 - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) console.log('game.vm_event', game.vm_event) console.log('game.is_pwr_struggle', game.is_pwr_struggle) /* @@ -2300,7 +2300,7 @@ function do_sc(space) { //else if (game.is_pwr_struggle) { roll += game.vm_available_ops - log(`+${game.vm_available_ops} from Ceausescu`) + logi(`+${game.vm_available_ops} from Ceausescu`) } // Check if in Tiananmen Square Track Award @@ -2308,53 +2308,53 @@ function do_sc(space) { else if (game.state === 'vm_tst_6_sc') { roll += get_tst_6_ops() roll += 2 - log('+2 from Tiananmen Square Track award') + logi('+2 TST award') } else { //let modifier = 0 let card_ops = get_card_ops(this_card()) roll += card_ops - log(`+${card_ops} from card ops`) + logi(`+${card_ops} ops`) } if (game.support_check_modifier > 0) { roll += game.support_check_modifier - log(`+${game.support_check_modifier} from event`) + logi(`+${game.support_check_modifier} event`) } // Events which modify SC rolls //Tear Gas if (game.active === COM && game.persistent_events.includes(30) && spaces[clicked_space].socio === 6) { roll ++ - log('+1 from C30') + 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)) { roll++ - log('+1 from C74') + logi('+1 C74') } //GrenzTruppen if (game.active === DEM && spaces[clicked_space].country === 'East_Germany' && game.persistent_events.includes(59)) { roll-- - log('-1 from C59') + 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))){ roll-- - log('-1 from C100') + logi('-1 C100') } //Elena if (game.active === DEM && game.persistent_events.includes(101) && spaces[clicked_space].country === 'Romania') { roll-- - log('-1 from C101') + logi('-1 C101') } //Austria Hungary Border Reopened if (game.active === DEM && game.persistent_events.includes(58) && game.austria_hungary_border_reopened_tracker) { roll++ - log(`+1 from C58`) + logi(`+1 C58`) } // Continue with logic - check for adjacency @@ -2364,11 +2364,11 @@ 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') { - log('No adjacency for Democrats due to C9') - log('C9 no longer in effect') + logi('No adjacency for Democrats due to C9') + logi('C9 no longer in effect') roll += adj.com_adj if (adj.com_adj > 0) { - log(`+${adj.com_adj} from adjacent control`) + logi(`+${adj.com_adj} adjacency`) } game.persistent_events = game.persistent_events.filter(n => n !== 9) @@ -2379,19 +2379,19 @@ function do_sc(space) { roll += adj.dem_adj roll -= adj.com_adj if (adj.dem_adj > 0) { - log(`+${adj.dem_adj} from adjacent control`) + logi(`+${adj.dem_adj} adjacency`) } if (adj.com_adj > 0) { - log(`-${adj.com_adj} from adjacent opponent control`) + logi(`-${adj.com_adj} opponenet adjacency`) } } else { roll += adj.com_adj roll -= adj.dem_adj if (adj.com_adj > 0) { - log(`+${adj.com_adj} from adjacent control`) + logi(`+${adj.com_adj} adjacency`) } if (adj.dem_adj > 0) { - log(`-${adj.dem_adj} from adjacent opponent control`) + logi(`-${adj.dem_adj} opponenet adjacency`) } } } @@ -2399,12 +2399,12 @@ function do_sc(space) { } // Support check calcs - log(`Total support check strength: ${roll}`) + log(`TOTAL: ${roll}`) const stability = spaces[find_space_index(space)].stability - log(`Stability is ${stability}. Defence is ${stability*2}`) + logi(`-${stability*2} (stability * 2)`) const change_infl = Math.max(0, roll - stability*2) if (change_infl > 0) { - log_msg_gap(`${change_infl} point swing`) + 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]) { @@ -2432,7 +2432,7 @@ function do_sc(space) { check_control_change(clicked_space) } else { - log_msg_gap('No change in influence') + log_msg_gap('CHANGE: 0 SP') } if (game.active === COM && game.persistent_events.includes(39) && spaces[clicked_space].space_id === 66) { log_msg_gap('+1 VP from C39') @@ -2761,7 +2761,7 @@ function check_com_control(space_id) { function do_tst_attempt() { let roll = Math.floor(Math.random() * 6) + 1; - log(`Roll: D${roll}`); + log(`ROLL: D${roll}`); roll += game.available_ops log(`+${game.available_ops} from card ops`) @@ -2788,7 +2788,7 @@ function do_tst_attempt() { roll ++ log('+1 from C53') } - log(`Modified die roll: ${roll}`) + log(`TOTAL: ${roll}`) // TIANANMEN SQUARE ATTEMPT game.return = game.active @@ -4298,6 +4298,15 @@ function vm_return() { reset_austria_hungary_border_reopened() } + //Check if end event state is needed + if ((game.active === DEM && game.round_player !==DEM) || (game.active === COM && game.round_player !== COM)) { + game.state = 'vm_end_event' + } else { + 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) { @@ -5895,6 +5904,19 @@ function vm_kremlin_coup_elite() { /* ================== VM STATES ============================== */ +states.vm_end_event = { + get inactive() { + return `resolve ${clean_name(cards[this_card()].name)}.` + }, + prompt () { + view.prompt = `${clean_name(cards[this_card()].name)}: done.` + gen_action('done') + }, + done(){ + vm_end_event() + } +} + states.vm_take_control = { get inactive() { return `resolve ${clean_name(cards[game.played_card].name)}.` @@ -6414,7 +6436,7 @@ states.vm_adamec = { roll() { clear_undo() let roll = Math.floor(Math.random() * 6) + 1 - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) let worker_spaces = spaces.filter(space => space && space.country === 'Czechoslovakia' && space.socio === 4 && check_dem_control(space.space_id)).length if (worker_spaces > 0) { log(`-${worker_spaces} from Democrat controlled worker spaces`) @@ -6601,7 +6623,7 @@ states.vm_dash_for_the_west = { roll() { clear_undo() let roll = Math.floor(Math.random() * 6) + 1 - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) let com_control = check_presence('East_Germany').com_spaces if (roll > com_control) { @@ -7366,7 +7388,7 @@ states.vm_malta_summit = { roll() { clear_undo() let roll = Math.floor(Math.random() * 6) + 1 - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) if (game.stability > 0) { log(`+${game.stability} from USSR Stability Track`) log(`Modified roll: ${roll + game.stability}`) @@ -7412,11 +7434,11 @@ states.vm_modrow = { let roll = Math.floor(Math.random() * 6) + 1 let dem_spaces = spaces.filter(space => space && space.country === 'East_Germany' && check_dem_control(space.space_id)).length if (roll > dem_spaces) { - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) log(`Success. More than the ${dem_spaces} Democratically controlled spaces`) vm_next() } else { - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) log(`Fail. More than ${dem_spaces} required`) permanently_remove(83) vm_return() @@ -7441,13 +7463,13 @@ states.vm_nepotism = { clear_undo() let roll = Math.floor(Math.random() * 6) + 1 if (roll < 3) { - log(`Roll: D${roll} adds 4 SPs`) + log(`ROLL: D${roll} adds 4 SPs`) game.vm_available_ops = 4} else if (roll < 5 ) { - log(`Roll: D${roll} adds 3 SPs`) + log(`ROLL: D${roll} adds 3 SPs`) game.vm_available_ops = 3} else { - log(`Roll: D${roll} adds 1 SP`) + log(`ROLL: D${roll} adds 1 SP`) game.vm_available_ops = 1} //game.phase = 2 vm_next() @@ -7697,7 +7719,7 @@ states.vm_shock_therapy = { worker_farmer++ } } - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) log(`-${worker_farmer} from Communist controlled Worker and Farmer spaces`) log(`Modified roll: ${roll - worker_farmer}`) if ((roll - worker_farmer) > 2) { @@ -7924,7 +7946,7 @@ states.vm_the_wall_must_go = { } let roll = Math.floor(Math.random() * 6) + 1 - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) if (game.active === DEM) { let controlled_spaces = spaces.filter(space => space && space.country === 'East_Germany' && check_dem_control(space.space_id)).length if (controlled_spaces > 0) { @@ -8142,7 +8164,7 @@ states.vm_workers_revolt_finish = { roll() { clear_undo() let roll = Math.floor(Math.random() * 6) + 1 - log(`Roll: D${roll}`) + log(`ROLL: D${roll}`) let adj = count_adj(spaces[game.selected_space].name_unique) if (game.active === DEM) { log(`-${adj.com_adj} from opponent controlled spaces`) @@ -8439,7 +8461,7 @@ CODE[3] = [ // Walesa [ vm_prompt, 'any space(s) in Poland' ], [ vm_add_infl_free, 4 ], [ vm_valid_spaces_country_sc, 'Poland' ], - [ vm_prompt, 'Make Support Checks in Poland' ], + [ vm_prompt, 'make Support Checks in Poland' ], [ vm_support_check, 2 ], [ vm_permanently_remove ], [ vm_return ], -- cgit v1.2.3