From 17855b224d88d23cb76f01224b0c7897fc044e38 Mon Sep 17 00:00:00 2001 From: iainp5 Date: Mon, 16 Sep 2024 16:38:16 +0100 Subject: Fix to stasi with no cards and log updates --- rules.js | 215 ++++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 170 insertions(+), 45 deletions(-) diff --git a/rules.js b/rules.js index dd9a117..4274acf 100644 --- a/rules.js +++ b/rules.js @@ -527,7 +527,7 @@ states.play_card ={ }, event() { push_undo() - log(`Played C${cards[game.played_card].number} for the event`) + log_gap(`Played C${cards[game.played_card].number} for the event`) if (scoring_cards.includes(game.played_card)) {game.phase = 0} else {game.phase = 1} game.return = game.active @@ -535,7 +535,7 @@ states.play_card ={ goto_vm(game.played_card) }, opp_event() { - log(`Played C${cards[game.played_card].number} for the event`) + log_gap(`Played C${cards[game.played_card].number} for the event`) game.phase = 1 /*Do I still need this?*/ game.vm_infl_to_do = true game.return = game.active @@ -548,7 +548,7 @@ states.play_card ={ }, influence() { push_undo() - log(`Played C${cards[game.played_card].number} for influence`) + log_gap(`Played C${cards[game.played_card].number} for influence`) // Check if Common European Home played for influence @@ -573,12 +573,12 @@ states.play_card ={ }, tst() { push_undo() - log(`Played C${cards[game.played_card].number} to the Tiananmen Square Track`) + log_gap(`Played C${cards[game.played_card].number} to the Tiananmen Square Track`) game.state='tiananmen_square_attempt' }, support_check() { push_undo() - log(`Played C${cards[game.played_card].number} for support checks`) + log_gap(`Played C${cards[game.played_card].number} for support checks`) // Check if card is opponent card with event that needs to be resolved if (game.phase === 0 && game.active === DEM && cards[game.played_card].side === "C" && game.playable_cards[game.played_card].playable === 1 || game.phase === 0 && game.active === COM && cards[game.played_card].side === "D" && game.playable_cards[game.played_card].playable === 1 ) { @@ -979,9 +979,12 @@ states.draw_power_cards = { if (game.persistent_events['the_crowd_turns_against_ceausescu'] && game.pwr_struggle_in === 'Romania') { if (game.active === COM) { game.return = COM - next_player()} + next_player() + } + log_h3('The Crowd Turns Against Ceausescu') game.state = 'the_crowd_turns_against_ceausescu_prep' } else { + log_h2('Raise the Stakes') game.state = 'raise_stakes_1' } } @@ -999,7 +1002,7 @@ states.the_crowd_turns_against_ceausescu_prep = { 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 ${game.temp} Rally in the Squares.`) + log(`Drew ${pluralize(game.temp, 'Rally in the Square')}.`) game.temp = game.temp * 3 game.state = 'the_crowd_turns_against_ceausescu' } @@ -1052,6 +1055,7 @@ states.the_crowd_turns_against_ceausescu_infl = { if (game.return !== game.active) { next_player() } + log_h2('Raise the Stakes') game.state = 'raise_stakes_1' } } @@ -1136,6 +1140,7 @@ states.raise_stakes_2 = { game.raised_stakes_discard = 0 game.valid_cards = [] next_player() + log_h2('Play Cards') game.state = 'begin_power_struggle' }, done () { @@ -1143,6 +1148,7 @@ states.raise_stakes_2 = { game.raised_stakes_discard = 0 game.valid_cards = [] next_player() + log_h2('Play Cards') game.state = 'begin_power_struggle' }, } @@ -1469,6 +1475,7 @@ states.vp_roll = { }, scoring () { push_undo() + log_h2('Scoring') score_country(game.pwr_struggle_in) game.state = 'finish_scoring' }, @@ -1499,6 +1506,7 @@ states.choose_power = { }, scoring () { push_undo() + score_country(game.pwr_struggle_in) game.state = 'finish_scoring' //game.state = 'score_country' @@ -1745,26 +1753,32 @@ states.new_years_eve_party = { } }, east_germany() { + push_undo() game.pwr_struggle_in = 'East_Germany' goto_vm(42) }, poland() { + push_undo() game.pwr_struggle_in = 'Poland' goto_vm(22) }, czechoslovakia() { + push_undo() game.pwr_struggle_in = 'Czechoslovakia' goto_vm(55) }, hungary() { + push_undo() game.pwr_struggle_in = 'Hungary' goto_vm(23) }, romania() { + push_undo() game.pwr_struggle_in = 'Romania' goto_vm(95) }, bulgaria () { + push_undo() game.pwr_struggle_in = 'Bulgaria' goto_vm(43) }, @@ -1792,8 +1806,13 @@ states.stasi_end_round = { inactive: 'choose next card due to Stasi.', prompt() { if (game.stasi_card === 0 ) { - view.prompt = 'Stasi: you must select your next card to play.' let available_cards = game.democrat_hand + if (available_cards.length === 0) { + view.prompt = 'Stasi: no cards remaining.' + gen_action('pass') + } + view.prompt = 'Stasi: you must select your next card to play.' + for (let card of available_cards) { gen_action_card(card) } @@ -1807,6 +1826,19 @@ states.stasi_end_round = { log_gap(`Stasi: selected C${cards[card].number}`) game.stasi_card = card }, + pass() { + game.stasi_card = 0 + game.round_player = COM + game.round ++ + log_h2(`Action Round ${game.round}`) + next_player() + game.valid_spaces = [] + if (game.persistent_events['general_strike']) { + game.state = 'general_strike' + } else { + game.state = 'choose_card' + } + }, done() { game.round_player = COM game.round ++ @@ -1823,18 +1855,21 @@ states.stasi_end_round = { states.stasi_play_card = { inactive: 'play a card.', - prompt () { + 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; - } - - view.prompt = `Stasi: you must play ${cards[game.stasi_card].name}.` - let available_cards = [game.stasi_card] - for (let card of available_cards) { - gen_action_card(card) + } else if (game.stasi_card === 0) { + view.prompt = 'Stasi: you must pass.' + gen_action('pass') + } else { + view.prompt = `Stasi: you must play ${cards[game.stasi_card].name}.` + let available_cards = [game.stasi_card] + for (let card of available_cards) { + gen_action_card(card) + } } }, card(card) { @@ -1849,6 +1884,10 @@ states.stasi_play_card = { game.available_ops-- } }, + pass () { + log('No cards remaining. Passed') + end_round() + }, done () { game.state = 'play_card' game.stasi_card = 0 @@ -2572,7 +2611,7 @@ function get_value(country) { function permanently_remove(card) { console.log('card:', card) - log(`C${cards[card].number} permanently removed`) + log_msg_gap(`C${cards[card].number} permanently removed`) let card_index = game.strategy_discard.indexOf(card) if (card_index !== -1) { console.log('sub 1 called') @@ -3014,8 +3053,33 @@ 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) { + find_card = game.communist_hand.indexOf(card) + game.communist_hand.splice(find_card, 1) + } else { + find_card = game.democrat_hand.indexOf(card) + game.democrat_hand.splice(find_card, 1) + } + game.strategy_discard.push(card) + log(`Discarded C${cards[card].number}`) + } else if (game.is_pwr_struggle) { + if (game.active === COM) { + find_card = game.com_pwr_hand.indexOf(card); + game.com_pwr_hand.splice(find_card, 1); + } else { + find_card = game.dem_pwr_hand.indexOf(card); + game.dem_pwr_hand.splice(find_card, 1); + } + game.power_struggle_discard.push(card) + //log(`Discarded P${power_cards[card].number}`) + } } function discard_card(hand) { @@ -4527,18 +4591,22 @@ function vm_power_struggle() { //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 { game.pwr_struggle_in = countries[scoring_cards.indexOf(game.played_card)] + log_h2(`C${game.played_card}`) } + //Check for Securitate if (game.pwr_struggle_in === 'Romania' && game.persistent_events['securitate']) { log('C70: Democrat reveals Power Struggle cards') game.view_opp_hand = true } + log_h2('Deal Cards') game.state = 'draw_power_cards' } @@ -5151,13 +5219,13 @@ states.vm_support_check_prep = { } states.vm_1_support_check_prep = { - inactive: 'do support check', + 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 = 'No valid targets for support check.' + view.prompt = `${clean_name(cards[this_card()].name)}.No valid targets for support check.` gen_action('done') } else { view.prompt = `${clean_name(cards[this_card()].name)}: ${event_prompt()}.` @@ -5295,31 +5363,38 @@ states.vm_central_committee_reshuffle = { }, east_germany() { game.vm_active_country = "East_Germany" + log(`Chose ${country_name(game.vm_active_country)}`) game.valid_spaces = [1,2,3,4,5,6,7,8,9,10,11,12] vm_next() }, poland() { game.vm_active_country = "Poland" + log(`Chose ${country_name(game.vm_active_country)}`) game.valid_spaces = [13,14,15,16,17,18,19,20,21,22,23,24,25,26] vm_next() }, czechoslovakia() { game.vm_active_country = "Czechoslovakia" + log(`Chose ${country_name(game.vm_active_country)}`) game.valid_spaces = [27,28,29,30,31,32,33,34,35,36,37] vm_next() }, hungary() { game.vm_active_country = "Hungary" + log(`Chose ${country_name(game.vm_active_country)}`) game.valid_spaces = [38,39,40,41,42,43,44,45,46,47,48,49] vm_next() }, romania() { game.vm_active_country = "Romania" + log(`Chose ${country_name(game.vm_active_country)}`) game.valid_spaces = [50,51,52,53,54,55,56,57,58,59,60,61,62,63] + game.valid_spaces = game.valid_spaces.filter(space => space !== game.persistent_events['systematization']) vm_next() }, bulgaria () { game.vm_active_country = "Bulgaria" + log(`Chose ${country_name(game.vm_active_country)}`) game.valid_spaces = [64,65,66,67,68,69,70,71,72,73,74,75] vm_next() }, @@ -5352,7 +5427,7 @@ states.vm_common_european_home = { push_undo() log(`Played with C${cards[card].number}`) game.valid_cards = [] - discard(card) + silent_discard(card) game.vm_event = card }, influence(){ @@ -5455,7 +5530,7 @@ states.vm_deutsche_marks_prep = { card(card) { log(`Gave C${cards[card].number}`) game.valid_cards = [] - discard(card) + silent_discard(card) next_player() game.state = 'vm_deutsche_marks' game.vm_event = card @@ -5494,14 +5569,14 @@ states.vm_deutsche_marks = { }, support_check() { push_undo() - log(`Played C${cards[game.vm_event].number} for support checks`) + log_gap(`Played C${cards[game.vm_event].number} for support checks`) game.vm_available_ops = 2 game.state='vm_support_check_prep' valid_spaces_sc() }, tst() { push_undo() - log(`Played C${cards[game.vm_event].number} to the Tiananmen Square Track`) + log_gap(`Played C${cards[game.vm_event].number} to the Tiananmen Square Track`) game.state='vm_tiananmen_square_attempt' } } @@ -5564,26 +5639,31 @@ states.vm_foreign_currency_debt_burden = { gen_action('bulgaria') }, east_germany() { + push_undo() game.persistent_events['foreign_currency_debt_burden'] = 'East_Germany' log('Selected East Germany') vm_next() }, poland() { + push_undo() game.persistent_events['foreign_currency_debt_burden'] = 'Poland' log('Selected Poland') vm_next() }, czechoslovakia() { + push_undo() game.persistent_events['foreign_currency_debt_burden'] = 'Czechoslovakia' log('Selected Czechoslovakia') vm_next() }, hungary() { + push_undo() game.persistent_events['foreign_currency_debt_burden'] = 'Hungary' log('Selected Hungary') vm_next() }, bulgaria() { + push_undo() game.persistent_events['foreign_currency_debt_burden'] = 'Bulgaria' log('Selected Bulgaria') vm_next() @@ -5661,6 +5741,7 @@ states.vm_honecker = { if (game.temp === 0) {view.prompt = 'Honecker: choose a card to add to your hand.' for (let card of game.valid_cards) { gen_action_card(card) + gen_action(pass) } } else { view.prompt = 'Honecker. Choose a card: done.' @@ -5677,7 +5758,14 @@ states.vm_honecker = { game.communist_hand.push(card) console.log('removed after honecker', game.strategy_removed) }, + pass(){ + log('Did not take a card') + vm_next() + }, done(){ + if (game.temp === 0) { + log('Did not take a card') + } game.discard = false vm_next() } @@ -6249,22 +6337,34 @@ states.vm_shock_therapy = { }, east_germany() { push_undo() - game.vm_active_country = 'East_Germany'}, + game.vm_active_country = 'East_Germany' + log(`Chose ${country_name(game.vm_active_country)}`) + }, poland() { push_undo() - game.vm_active_country = 'Poland'}, + game.vm_active_country = 'Poland' + log(`Chose ${country_name(game.vm_active_country)}`) + }, czechoslovakia() { push_undo() - game.vm_active_country = 'Czechoslovakia'}, + game.vm_active_country = 'Czechoslovakia' + log(`Chose ${country_name(game.vm_active_country)}`) + }, hungary() { push_undo() - game.vm_active_country = 'Hungary'}, + game.vm_active_country = 'Hungary' + log(`Chose ${country_name(game.vm_active_country)}`) + }, romania() { push_undo() - game.vm_active_country = 'Romania'}, + game.vm_active_country = 'Romania' + log(`Chose ${country_name(game.vm_active_country)}`) + }, bulgaria () { push_undo() - game.vm_active_country = 'Bulgaria'}, + game.vm_active_country = 'Bulgaria' + log(`Chose ${country_name(game.vm_active_country)}`) + }, roll() { clear_undo() let roll = Math.floor(Math.random() * 6) + 1 @@ -6304,31 +6404,37 @@ states.vm_social_democratic_platform_adopted = { if (game.revolutions['Bulgaria']) {gen_action('bulgaria')} }, east_germany() { + push_undo() game.vm_active_country = 'East_Germany' - log(`Selected ${game.vm_active_country}`) + log(`Selected ${country_name(game.vm_active_country)}`) vm_next() }, - poland() { + poland() { + push_undo() game.vm_active_country = 'Poland' - log(`Selected ${game.vm_active_country}`) + log(`Selected ${country_name(game.vm_active_country)}`) vm_next()}, czechoslovakia() { + push_undo() game.vm_active_country = 'Czechoslovakia' - log(`Selected ${game.vm_active_country}`) + log(`Selected ${country_name(game.vm_active_country)}`) vm_next()}, - hungary() { + hungary() { + push_undo() game.vm_active_country = 'Hungary' - log(`Selected ${game.vm_active_country}`) + log(`Selected ${country_name(game.vm_active_country)}`) vm_next() }, romania() { + push_undo() game.vm_active_country = 'Romania' - log(`Selected ${game.vm_active_country}`) + log(`Selected ${country_name(game.vm_active_country)}`) vm_next() }, - bulgaria () { + bulgaria () { + push_undo() game.vm_active_country = 'Bulgaria' - log(`Selected ${game.vm_active_country}`) + log(`Selected ${country_name(game.vm_active_country)}`) vm_next()} } @@ -6363,7 +6469,7 @@ states.vm_the_chinese_solution = { return `resolve ${cards[game.played_card].name}.` }, prompt() { - view.prompt = 'You may give up 3VP to conduct support checks in a country where you hold power.' + view.prompt = 'You may give up 3 VP to conduct support checks in a country where you hold power.' if (!game.revolutions['East_Germany']) {gen_action('east_germany')} if (!game.revolutions['Poland']) {gen_action('poland')} if (!game.revolutions['Czechoslovakia']) {gen_action('czechoslovakia')} @@ -6372,37 +6478,55 @@ states.vm_the_chinese_solution = { if (!game.revolutions['Bulgaria']) {gen_action('bulgaria')} gen_action('pass') }, - east_germany() {game.vm_active_country = 'East_Germany' + east_germany() { + push_undo() + game.vm_active_country = 'East_Germany' + log(`Chose ${country_name(game.vm_active_country)}`) log('+3 VP') game.vp += 3 check_vp() vm_next() }, - poland() { game.vm_active_country = 'Poland' + poland() { + push_undo() + game.vm_active_country = 'Poland' + log(`Chose ${country_name(game.vm_active_country)}`) log('+3 VP') game.vp += 3 check_vp() vm_next() }, - czechoslovakia() { game.vm_active_country = 'Czechoslovakia' + czechoslovakia() { + push_undo() + game.vm_active_country = 'Czechoslovakia' + log(`Chose ${country_name(game.vm_active_country)}`) log('+3 VP') game.vp += 3 check_vp() vm_next() }, - hungary() { game.vm_active_country = 'Hungary' + hungary() { + push_undo() + game.vm_active_country = 'Hungary' + log(`Chose ${country_name(game.vm_active_country)}`) log('+3 VP') game.vp += 3 check_vp() vm_next() }, - romania() { game.vm_active_country = 'Romania' + romania() { + push_undo() + game.vm_active_country = 'Romania' + log(`Chose ${country_name(game.vm_active_country)}`) log('+3 VP') game.vp += 3 check_vp() vm_next() }, - bulgaria () { game.vm_active_country = 'Bulgaria' + bulgaria () { + push_undo() + game.vm_active_country = 'Bulgaria' + log(`Chose ${country_name(game.vm_active_country)}`) log('+3 VP') game.vp += 3 check_vp() @@ -7620,6 +7744,7 @@ CODE[91] = [ // My First Banana* ] CODE[92] = [ // Betrayal + [ vm_prompt, 'choose any Orthodox Church space. Replace all Democratic SPs with Communist SPs' ], [ vm_betrayal ], [ vm_permanently_remove ], [ vm_return ], -- cgit v1.2.3