diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 201 |
1 files changed, 150 insertions, 51 deletions
@@ -708,8 +708,12 @@ states.play_card = { push_undo() check_ligachev_event(game.played_card) //log_gap(`Played C${game.played_card} for the event`) - if (!scoring_cards.includes(game.played_card)) + if (scoring_cards.includes(game.played_card)) + log_struggle_banner(game.played_card) + else { + log_event_banner() log_event(game.played_card) + } game.vm_infl_to_do = false game.return = game.active if (switch_events.includes(game.played_card)) { @@ -721,6 +725,7 @@ states.play_card = { }, opp_event() { push_undo() + log_ops_banner() check_ligachev_event(game.played_card) //log_gap(`Resolved opponent event C${game.played_card}`) log_event(game.played_card) @@ -738,6 +743,7 @@ states.play_card = { }, influence() { push_undo() + log_ops_banner() check_ligachev_non_event() //log_gap(`Played C${game.played_card} to place SPs`) log('Placed SP:') @@ -752,6 +758,7 @@ states.play_card = { }, tst() { push_undo() + log_ops_banner() check_ligachev_non_event() //log_gap(`Played C${game.played_card} to the Tiananmen Square Track`) log('Tiananmen Square Attempt:') @@ -760,6 +767,7 @@ states.play_card = { }, support_check() { push_undo() + log_ops_banner() check_ligachev_non_event() //log_gap(`Played C${game.played_card} for Support Checks`) log('Support Checks:') @@ -771,6 +779,7 @@ states.play_card = { tst_7() { /* Cancel opponent event */ push_undo() + log_ops_banner() check_ligachev_non_event() log(`Event cancelled using TST Award.`) game.tst_7 = true @@ -780,10 +789,11 @@ states.play_card = { tst_8() { /* Play card for ops and event */ push_undo() + log_tst_8_banner() game.vm_event_to_do = true game.vm_infl_to_do = true game.tst_8 = true - log(`Uses TST Award: event and operations.`) + //log(`Uses TST Award: event and operations.`) game.state = 'vm_tst_8' }, end_round() { @@ -1061,7 +1071,7 @@ states.support_check_prep = { if (game.return !== game.active) { next_player() } - log_h2('Raise the Stakes') + log_h3('Raise the Stakes') log(`${game.active}:`) game.state = 'raise_stakes_1' return @@ -1210,7 +1220,7 @@ states.draw_power_cards = { game.persistent_events.push(THE_CROWD_TURNS_AGAINST_CEAUSESCU_OCCURRED) game.state = 'the_crowd_turns_against_ceausescu_prep' } else { - log_h2('Raise the Stakes') + log_h3('Raise the Stakes') log(`${game.active}:`) game.state = 'raise_stakes_1' } @@ -1286,7 +1296,7 @@ states.the_crowd_turns_against_ceausescu_infl = { if (game.return !== game.active) { change_player() } - log_h2('Raise the Stakes') + log_h3('Raise the Stakes') log(`${game.active}:`) game.state = 'raise_stakes_1' }, @@ -2014,43 +2024,43 @@ states.new_years_eve_party = { }, east_germany() { push_undo() - log('Chose to score East Germany') + log('Chose to score East Germany.') game.vm_event = C_POWER_STRUGGLE_EAST_GERMANY goto_vm(C_POWER_STRUGGLE_EAST_GERMANY) }, poland() { push_undo() - log('Chose to score Poland') + log('Chose to score Poland.') game.vm_event = C_POWER_STRUGGLE_POLAND goto_vm(C_POWER_STRUGGLE_POLAND) }, czechoslovakia() { push_undo() - log('Chose to score Czechoslovakia') + log('Chose to score Czechoslovakia.') game.vm_event = C_POWER_STRUGGLE_CZECHOSLOVAKIA goto_vm(C_POWER_STRUGGLE_CZECHOSLOVAKIA) }, hungary() { push_undo() - log('Chose to score Hungary') + log('Chose to score Hungary.') game.vm_event = C_POWER_STRUGGLE_HUNGARY goto_vm(C_POWER_STRUGGLE_HUNGARY) }, romania() { push_undo() - log('Chose to score Romania') + log('Chose to score Romania.') game.vm_event = C_POWER_STRUGGLE_ROMANIA goto_vm(C_POWER_STRUGGLE_ROMANIA) }, bulgaria() { push_undo() - log('Chose to score Bulgaria') + log('Chose to score Bulgaria.') game.vm_event = C_POWER_STRUGGLE_BULGARIA goto_vm(C_POWER_STRUGGLE_BULGARIA) }, pass() { push_undo() - log('No final power struggle') + log('No final power struggle.') if (game.vp > 0) { goto_game_over(DEM, `New Year's Eve Party: ${DEM} wins on Victory Point Track!`) } else if (game.vp < 0) { @@ -2159,7 +2169,7 @@ states.stasi_play_card = { if (game.democrat_hand.includes(C_COMMON_EUROPEAN_HOME) && cards[card].side === "C") { game.state = 'stasi_resolve_common_european_home' } else { - log(`Played C${card}.`) + //log(`Played C${card}.`) game.state = 'play_card' } }, @@ -2796,7 +2806,7 @@ function get_icons(starting_control, end_control) { function do_tst_attempt() { let roll = roll_d6() - logi(`D${roll} roll`) + logi(`D${roll} from roll`) roll += game.available_ops logi(`+${game.available_ops} from card ops`) @@ -3212,7 +3222,7 @@ function goto_game_over(result, victory) { function goto_struggle() { game.raised_stakes_discard = 0 game.valid_cards = [] - log_h2('Play Cards') + log_h3('Play Cards') change_player() game.state = 'power_struggle' do_valid_cards() @@ -3237,7 +3247,7 @@ function end_stasi() { next_player() game.valid_spaces = [] if (game.persistent_events.includes(C_GENERAL_STRIKE)) { - log_h3('C' + C_GENERAL_STRIKE) + log('.cC' + C_GENERAL_STRIKE) game.state = 'general_strike' } else { game.state = 'choose_card' @@ -3250,7 +3260,7 @@ function end_goddess() { if (game.active === DEM) { next_player() } else { - log_side() + //log_side() } if (game.persistent_events.includes(C_GENERAL_STRIKE)) { game.state = 'general_strike' @@ -3291,10 +3301,12 @@ function select_card(card) { find_card = game.democrat_hand.indexOf(card) game.democrat_hand.splice(find_card, 1) } - game.available_ops = get_card_ops(card) game.state = 'play_card' - if (!scoring_cards.includes(card)) - log(`Played C${card}.`) +} +function finish_select_card() { + if (!scoring_cards.includes(game.played_card)) + game.available_ops = get_card_ops(game.played_card) + log(`Played C${game.played_card}.`) } function check_ligachev_non_event() { @@ -3537,8 +3549,8 @@ function get_card_ops(card) { let ops = cards[card].ops if (game.persistent_events.includes(C_PERESTROIKA) && game.active === COM) { if ( - game.state === 'choose_card' || - game.state === 'stasi_play_card' || + game.state === 'play_card' || + //game.state === 'stasi_play_card' || game.state === 'general_strike' || game.state === 'vm_deutsche_marks' ) { @@ -3548,8 +3560,8 @@ function get_card_ops(card) { } if (game.persistent_events.includes(C_THE_SINATRA_DOCTRINE) && game.active === DEM) { if ( - game.state === 'choose_card' || - game.state === 'stasi_play_card' || + game.state === 'play_card' || + //game.state === 'stasi_play_card' || game.state === 'vm_laszlo_tokes' ) { log(`+1 op from C${C_THE_SINATRA_DOCTRINE}.`) @@ -3562,8 +3574,8 @@ function get_card_ops(card) { (game.active === COM && game.com_tst_position >= 2 && game.dem_tst_position <= 1 && cards[card].ops === 1) ) { if ( - game.state === 'choose_card' || - game.state === 'stasi_play_card' || + game.state === 'play_card' || + //game.state === 'stasi_play_card' || game.state === 'general_strike' ) { log('+1 op from Tiananmen Square Track.') @@ -3573,8 +3585,8 @@ function get_card_ops(card) { if (game.active === DEM && game.prudence && game.prudence.DEM !== 0) { if ( - game.state === 'choose_card' || - game.state === 'stasi_play_card' || + game.state === 'play_card' || + //game.state === 'stasi_play_card' || game.state === 'vm_laszlo_tokes' ) { if (ops > 2) { @@ -3594,7 +3606,7 @@ function get_card_ops(card) { if (game.active === COM && game.prudence && game.prudence.COM < 0) { if ( - game.state === 'choose_card' || + game.state === 'play_card' || game.state === 'general_strike' ) { if (ops > 2) { @@ -3722,6 +3734,14 @@ function end_round() { return } + console.log('in end_round, game.persistent_events.includes(C_CEAUSESCU)', game.persistent_events.includes(C_CEAUSESCU)) + // Check if Ceausescu has been played and if so check end round condition + if (game.persistent_events.includes(C_CEAUSESCU)) { + console.log('in check ceausescu') + if (check_ceausescu()) + return + } + // Check if the card needs to be discarded. let discard_check = [...game.strategy_removed, ...game.persistent_events] if (!discard_check.includes(game.played_card) && game.played_card > 0) { @@ -3837,10 +3857,10 @@ function end_round() { if (game.active !== DEM) { next_player() } else { - log_side() + //log_side() } if (game.democrat_hand.includes(game.stasi_card)) { - log_h3('C' + C_STASI) + //log('.dC' + C_STASI) game.state = 'stasi_play_card' } else { game.stasi_card = 0 @@ -3860,7 +3880,7 @@ function end_round() { if (game.active !== DEM) { next_player() } else { - log_side() + //log_side() } game.state = 'choose_card' return @@ -3882,7 +3902,7 @@ function end_round() { if (game.active !== COM) { next_player() } - log_h3('C' + C_GENERAL_STRIKE) + log('.cC' + C_GENERAL_STRIKE) return } else { game.state = 'choose_card' @@ -3892,7 +3912,7 @@ function end_round() { if (game.active !== COM) { change_player() } - log_side() + //log_side() } } } @@ -3979,9 +3999,9 @@ function new_turn() { game.state = 'tst_goddess' } else { log_h2("Action Round " + game.round) - log_side() + //log_side() if (game.persistent_events.includes(C_GENERAL_STRIKE)) { - log_h3('C' + C_GENERAL_STRIKE) + log('.cC' + C_GENERAL_STRIKE) game.state = 'general_strike' } else { game.state = 'choose_card' @@ -3999,10 +4019,10 @@ function next_player() { clear_undo() if (game.active === DEM) { game.active = COM - log_side() + //log_side() } else { game.active = DEM - log_side() + //log_side() } } @@ -4185,6 +4205,16 @@ function reset_power() { } } +function check_ceausescu() { + game.return = game.active + game.return_state = 'ceausescu_check' + console.log('check_ceausescu, game.return', game.return) + game.vm_infl_to_do = false + game.vm_event = C_CEAUSESCU + goto_vm(game.vm_event) + return true +} + function check_tyrant() { if (game.the_tyrant_is_gone > 0 && check_dem_control(game.the_tyrant_is_gone)) { log_summary('+2 VP from C' + C_THE_TYRANT_IS_GONE + '.') @@ -4264,6 +4294,36 @@ function log(msg) { game.log.push(msg) } +function log_ops_banner() { + if (game.active === DEM) + log('.O.d') + else + log('.O.c') + finish_select_card() +} + +function log_event_banner() { + if (game.active === DEM) + log('.V.d') + else + log('.V.c') +} + +function log_struggle_banner(n) { + if (game.active === DEM) + log('.S.dC' + n) + else + log('.S.cC' + n) +} + +function log_tst_8_banner() { + if (game.active === DEM) + log('.T.d') + else + log('.T.c') + finish_select_card() +} + function log_event(n) { log_br() if (cards[n].side === "C") @@ -4580,6 +4640,7 @@ function prompt_event(str) { } function event_prompt(str) { + console.log('game.vm.fp', game.vm.fp, 'game.vm.prompt', game.vm.prompt) if (typeof str === "undefined") str = CODE[game.vm.fp][game.vm.prompt][1] if (typeof str === "function") @@ -4609,7 +4670,7 @@ function vm_return() { } // Check if end event state is needed - if (game.is_pwr_struggle || game.state === 'vm_tst_6' || game.return_state === 'tiananmen_square_attempt_done') { + if (game.is_pwr_struggle || game.state === 'vm_tst_6' || game.return_state === 'tiananmen_square_attempt_done' || game.return_state === 'ceausescu_check') { vm_end_event() } // Check if auto-resolve opponent event @@ -4625,18 +4686,29 @@ function vm_return() { } function vm_end_event() { + console.log('vm_end_event game.return', game.return, 'game.return_state', game.return_state, 'game.vm_infl_to_do', game.vm_infl_to_do) + if (game.return_state === 'ceausescu_check') { + console.log('1') + end_round() + return + } if (game.return !== game.active) { //next_player() + console.log('2') change_player() } if (game.return_state === 'power_struggle') { + console.log('3') do_valid_cards() } if (game.return_state && game.return_state !== '') { + console.log('4') game.state = game.return_state } else if (game.vm_infl_to_do) { + console.log('in game.vm_infl_to_do') game.state = 'resolve_opponent_event' } else { + console.log('end round called') end_round() } } @@ -5071,24 +5143,28 @@ function vm_remove_all_infl() { function vm_do_remove_all_infl(space) { push_undo() - + let starting_control = check_control(space) if (game.remove_opponent_infl === true) { if (game.active === COM) { - log(`Removed all Democratic SP from %${space}.`) game.demInfl[space] = 0 + let end_control = check_control(space) + log(`Removed all Democratic SP from %${space}${get_icons(starting_control, end_control)}`) } else { - log(`Removed all Communist SP from %${space}.`) game.comInfl[space] = 0 + let end_control = check_control(space) + log(`Removed all Communist SP from %${space}${get_icons(starting_control, end_control)}`) } check_tyrant() } else { if (game.active === COM) { - log(`Removed all Communist SP from %${space}.`) game.comInfl[space] = 0 + let end_control = check_control(space) + log(`Removed all Communist SP from %${space}${get_icons(starting_control, end_control)}`) } else { - log(`Removed all Democratic SP from %${space}.`) game.demInfl[space] = 0 + let end_control = check_control(space) + log(`Removed all Democratic SP from %${space}${get_icons(starting_control, end_control)}`) } check_tyrant() } @@ -5237,9 +5313,15 @@ function vm_bulgarian_turks_expelled() { vm_next() } +function vm_ceausescu_prep() { + game.persistent_events.push(C_CEAUSESCU) + vm_next() +} + function vm_ceausescu() { + game.persistent_events = game.persistent_events.filter(n => n!== C_CEAUSESCU) let adj_cluj = false - + if (game.demInfl[S_TIMISOARA] > 0) { adj_cluj = true } @@ -5253,13 +5335,21 @@ function vm_ceausescu() { adj_cluj = true } + console.log('in vm_ceausescu, adj_cluj', adj_cluj) if (adj_cluj && game.comInfl[S_BUCURESTI] > 0) { + if (game.active !== COM) { + change_player() + game.return = game.active + log_event(C_CEAUSESCU) + } game.valid_spaces = [S_BUCURESTI] game.vm_available_ops = 1 game.remove_opponent_infl = false + log(`Democrat has SP adjacent to ${S_CLUJ_NAPOCA}.`) + log('Removed SP:') game.state = 'vm_remove_infl' } else { - vm_next() + vm_return() } } @@ -5711,14 +5801,14 @@ function vm_power_struggle() { game.raised_stakes_round = 0 game.raised_stakes_discard = 0 game.pwr_struggle_in = countries[scoring_cards.indexOf(game.vm_event)] - log_h2(`C${game.vm_event}`) + //log_h2(`C${game.vm_event}`) // Check for Securitate if (game.pwr_struggle_in === 'Romania' && game.persistent_events.includes(C_SECURITATE)) { log(`C${C_SECURITATE}: Democrat reveals Power Struggle cards.`) game.opp_power_hand = true } - log_h2('Deal Cards') + log_h3('Deal Cards') game.state = 'draw_power_cards' } @@ -6118,6 +6208,7 @@ function vm_kremlin_coup_elite() { states.vm_end_event = { prompt() { prompt_event("Done.") + console.log('in vm_end_event') if (game.vm_infl_to_do || game.return_state === 'vm_tst_8') { gen_action('done') } else { @@ -6321,7 +6412,11 @@ states.vm_remove_infl = { prompt_event(`Remove ${pluralize(game.vm_available_ops, 'opponent SP')}${event_prompt()}.`) } else { - prompt_event(`Remove ${pluralize(game.vm_available_ops,'SP')}${event_prompt()}.`) + console.log('game.vm_event', game.vm_event) + if (game.vm_event === C_CEAUSESCU) + prompt_event(`${event_prompt()}.`) + else + prompt_event(`Remove ${pluralize(game.vm_available_ops,'SP')}${event_prompt()}.`) } for (let space_id of game.valid_spaces) { gen_action_space(space_id) @@ -8855,15 +8950,19 @@ CODE[41] = [ // Ceausescu* [ vm_if, ()=>game.persistent_events.includes(THE_TYRANT_IS_GONE_OCCURRED) ], [ vm_tyrant_block ], [ vm_else ], + [ vm_if, ()=>game.persistent_events.includes(C_CEAUSESCU) ], + [ vm_prompt, 'you must remove 1 SP from Bucharesti' ], + [ vm_ceausescu ], + [ vm_return ], + [ vm_else ], [ vm_if, ()=>!is_auto_resolve(C_CEAUSESCU) ], + [ vm_ceausescu_prep ], [ vm_valid_spaces_country_opp, 'Romania' ], [ vm_prompt, ' from Romania' ], [ vm_remove_opp_infl, 3 ], [ vm_valid_spaces_country_sc, 'Romania' ], [ vm_prompt, 'make a Support Check in Romania' ], [ vm_1_support_check ], - [ vm_prompt, ' from Bucharesti' ], - [ vm_ceausescu ], [ vm_endif ], [ vm_return ], ] |