From a7af708bc617267d3498e273a4f30f0b6ac04106 Mon Sep 17 00:00:00 2001 From: iainp5 Date: Mon, 14 Oct 2024 22:39:17 +0100 Subject: Updates to end action round --- play.js | 1 + rules.js | 118 +++++++++++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 85 insertions(+), 34 deletions(-) diff --git a/play.js b/play.js index f90e207..dd38b44 100644 --- a/play.js +++ b/play.js @@ -696,6 +696,7 @@ if (view.persistent_events.includes(97)) { action_button("tst", "Tiananmen Square Track") action_button("roll", "Roll a die") action_button("done", "Done") + action_button("end_round", "End Round") action_button("undo", "Undo") console.log('view.strategy_deck', view.strategy_deck) diff --git a/rules.js b/rules.js index cf074d3..0259fda 100644 --- a/rules.js +++ b/rules.js @@ -449,7 +449,8 @@ states.choose_card = { }, pass() { log('No cards remaining. Passed') - end_round() + //end_round() + game.state = 'end_round' } } @@ -470,9 +471,10 @@ states.play_card ={ return `play ${clean_name(cards[game.played_card].name)}.` }, prompt () { - if (game.phase >= 1) { - view.prompt = `${clean_name(cards[game.played_card].name)}: done.` - gen_action('done') + if (game.phase >= 1) { /*Finish here when playing your own event */ + console.log('in play card') + view.prompt = `${clean_name(cards[game.played_card].name)}: done. End the Action Round.` + gen_action('end_round') return } @@ -528,11 +530,13 @@ states.play_card ={ push_undo() console.log('played event, game.active', game.active, 'game.view_opp_hand', game.view_opp_hand) log_gap(`Played C${cards[game.played_card].number} for the event`) + game.vm_infl_to_do = false if (scoring_cards.includes(game.played_card)) {game.phase = 0} else {game.phase = 1} game.return = game.active if (switch_events.includes(game.played_card)) {next_player()} game.vm_event = game.played_card + console.log('before event, game.vm_infl_to_do', game.vm_infl_to_do) goto_vm(game.vm_event) }, opp_event() { @@ -622,7 +626,7 @@ states.play_card ={ game.tst_8 = true game.state = 'vm_tst_8' }, - done () { + end_round () { end_round() } @@ -647,7 +651,7 @@ states.resolve_opponent_event = { gen_action('opp_event') } else { view.prompt = 'Event resolved. End the action round.' - gen_action('done') + gen_action('end_round') } }, influence(){ @@ -689,7 +693,7 @@ states.resolve_opponent_event = { game.tst_7 = true game.vm_event_to_do = false }, - done() { + end_round() { /*if(game.round_player === COM && game.active === DEM) { log_h3('End of Communist Action Round') change_player() @@ -724,7 +728,8 @@ states.finish_add_infl = { log_br() } - end_round() + //end_round() + game.state = 'end_round' } } @@ -759,7 +764,8 @@ states.finish_support_check_prep = { game.state = 'finish_do_support_check' }, done () { - end_round() + //end_round() + game.state = 'end_round' } } @@ -826,7 +832,9 @@ states.add_influence = { reset_austria_hungary_border_reopened() game.state = 'resolve_opponent_event'} else { - end_round()} + //end_round() + game.state = 'end_round' + } } } @@ -853,6 +861,7 @@ states.tiananmen_square_attempt_success = { gen_action('done') }, done () { + push_undo() if (game.vm_event > 200) { goto_vm(game.vm_event) } else { @@ -868,6 +877,7 @@ states.tiananmen_square_attempt_fail = { gen_action('done') }, done () { + push_undo() game.state = 'tiananmen_square_attempt_done' } } @@ -875,11 +885,12 @@ states.tiananmen_square_attempt_fail = { states.tiananmen_square_attempt_done = { inactive: 'do Tiananmen Square Attempt.', prompt () { - view.prompt = 'Tiananmen Square Track attempt: done.' + view.prompt = 'Tiananmen Square Track attempt: done. End the Action Round.' gen_action('done') }, done () { end_round() + //game.state = 'end_round' } } @@ -1017,7 +1028,8 @@ states.support_check_prep = { reset_austria_hungary_border_reopened() game.state = 'resolve_opponent_event' } else { - end_round() + //end_round() + game.state = 'end_round' } } } @@ -1042,7 +1054,7 @@ states.do_support_check = { } states.austria_hungary_border_reopened_check = { - inactive: 'decide Austria-Hungary Border Reopened', + inactive: 'decide Austria-Hungary Border Reopened.', prompt() { view.prompt = 'Austria-Hungary Border Reopened: will both support checks be in East Germany?' gen_action('yes') @@ -1057,6 +1069,17 @@ states.austria_hungary_border_reopened_check = { } } +states.end_round = { + inactive: 'finish playing a card.', + prompt() { + view.prompt = 'End the Action Round.' + gen_action('end_round') + }, + end_round() { + end_round() + } +} + //======================= POWER STRUGGLE =============================== states.draw_power_cards = { @@ -1757,7 +1780,8 @@ states.finish_scoring ={ return } reset_power() - end_round() + //end_round() + game.state = 'end_round' } } @@ -1961,7 +1985,8 @@ states.general_strike = { game.phase = 1 }, done () { - end_round() + //end_round() + game.state = 'end_round' } } @@ -1982,7 +2007,8 @@ states.honecker ={ pass() { log('C15: passed') game.persistent_events = game.persistent_events.filter(n => n !== 15) - end_round() + //end_round() + game.state = 'end_round' } } @@ -2157,10 +2183,11 @@ states.stasi_play_card = { }, pass () { log('No cards remaining. Passed') - end_round() + //end_round() + game.state = 'end_round' }, done () { - game.stasi_card = 0 + //game.stasi_card = 0 if (game.democrat_hand.includes(21)) { game.state = 'stasi_resolve_common_european_home' } else { @@ -2315,13 +2342,12 @@ function do_sc(space) { return } } - console.log('continue support check, game.state', game.state) + // Continue with Support Check Logic let roll = Math.floor(Math.random() * 6) + 1 log(`Roll: D${roll}`) - console.log('game.vm_event', game.vm_event) - console.log('game.is_pwr_struggle', game.is_pwr_struggle) + /* //Check if support check is being done with game.played_card or a subsequent card (e.g. Common European Home, Dash for the West, etc) if (game.vm_event > 0) { @@ -2704,7 +2730,7 @@ function count_adj(id) { for (let adj_space_id of adjacent_spaces) { if (adj_space_id) { const adj_piece = spaces.find(piece => piece && piece.space_id === adj_space_id); - console.log('adj_piece.space_id', adj_piece.space_id, 'space', space) + //console.log('adj_piece.space_id', adj_piece.space_id, 'space', space) if (adj_piece && adj_piece.space_id !== space.space_id) { if (check_dem_control(adj_piece.space_id)) { console.log('added DEM space', spaces[adj_piece.space_id].name) @@ -3261,7 +3287,7 @@ function event_is_playable(card) { return false } //Check for Common European Hmme under Stasi - else if (game.persistent_events.includes(13) && card === 21 && game.active === DEM) { + else if (game.stasi_card === 21 && card === 21 && game.active === DEM) { return false } //Check for The Chinese Solution @@ -3382,6 +3408,7 @@ function get_tst_6_ops() { // =========== MOVING THROUGH TURNS ============ function end_round() { + console.log('end round, game.persistent_events.includes(13)', game.persistent_events.includes(13)) //Check if the game is over! if (game.state === 'game_over') { console.log('in end') @@ -4344,7 +4371,7 @@ function pop_vm_prompt() { function vm_return() { - console.log('in vm_return') + console.log('in vm_return, game.vm_infl_to_do', game.vm_infl_to_do) //Remove temporary vm variables delete game.support_check_modifier @@ -4361,9 +4388,14 @@ function vm_return() { if (game.is_pwr_struggle || game.state === 'vm_tst_6') { vm_end_event() } else { - if ((game.active === DEM && game.round_player !==DEM) || (game.active === COM && game.round_player !== COM)) { - game.state = 'vm_end_event' + if (!game.vm_infl_to_do) { + /*if ((game.active === DEM && game.round_player !==DEM) || (game.active === COM && game.round_player !== COM)) { + game.state = 'vm_end_event' + } else {*/ + game.state = 'vm_end_event' + //} } else { + console.log('vm_infl_to_do true') vm_end_event() } } @@ -4389,8 +4421,11 @@ function vm_end_event() { game.state = game.return_state console.log( 'game.state', game.state) } - else if (game.vm_infl_to_do) {game.state = 'resolve_opponent_event'} /*Can use game.return state for this? */ - else {game.state = "play_card"} + else if (game.vm_infl_to_do) { + game.state = 'resolve_opponent_event'} /*Can use game.return state for this? */ + //else {game.state = "play_card"} + else{ + end_round()} } /* ================== VM ACTIONS =========================== */ @@ -5460,6 +5495,7 @@ function vm_laszlo_tokes() { } function vm_legacy_of_martial_law() { + console.log('in martial law, game.vm_infl_to_do', game.vm_infl_to_do) game.vm_available_ops = 1 game.state = 'vm_switch_infl' } @@ -5932,10 +5968,15 @@ states.vm_end_event = { return `resolve ${clean_name(cards[this_card()].name)}.` }, prompt () { - view.prompt = `${clean_name(cards[this_card()].name)}: done.` - gen_action('done') + console.log('in vm_end_event') + view.prompt = `${clean_name(cards[this_card()].name)}: done. End the Action Round.` + gen_action('end_round') }, - done(){ + end_round(){ + console.log('end round clicked - vm_end_event called') + if (!game.vm_infl_to_do) { + game.return_state = '' + } vm_end_event() } } @@ -5995,6 +6036,7 @@ states.vm_add_infl = { } }, done () { + push_undo() if (game.summary.length > 0) { pop_summary() log_br() @@ -6032,6 +6074,7 @@ states.vm_add_infl_free = { } }, done () { + push_undo() game.valid_spaces = [] game.vm_event_done = true if (game.summary.length > 0) { @@ -6069,6 +6112,7 @@ states.vm_add_x_infl = { //vm_next() }, done () { + push_undo() game.vm_event_done = true vm_next() } @@ -6101,6 +6145,7 @@ states.vm_add_limited_infl = { } }, done () { + push_undo() if (game.summary.length > 0) { pop_summary() log_br() @@ -6290,6 +6335,7 @@ states.vm_support_check_prep = { game.state = 'vm_do_support_check' }, done () { + push_undo() game.vm_available_ops = 0 vm_next () } @@ -6394,6 +6440,7 @@ states.vm_1_support_check_prep = { game.state = 'vm_do_support_check' }, done () { + push_undo() game.vm_available_ops = 0 vm_next () } @@ -7621,6 +7668,7 @@ states.vm_nomenklatura_add = { if (game.vm_available_ops === 0 ) {game.valid_spaces = []} }, done() { + push_undo() if (game.summary.length > 0) { pop_summary() log_br() @@ -8157,6 +8205,7 @@ states.vm_we_are_the_people_add = { if (game.vm_influence_added[6] === 0 ) {game.valid_spaces = []} }, done() { + push_undo() if (game.summary.length > 0) { pop_summary() log_br() @@ -8330,6 +8379,7 @@ states.vm_tst_6 = { game.state = 'vm_tst_6_sc' }, done () { + push_undo() vm_next() } } @@ -8367,8 +8417,8 @@ states.vm_tst_8 = { gen_action('event') } else if (!game.vm_event_to_do && !game.vm_infl_to_do) { - view.prompt = 'Event and operations: done.' - gen_action('done') + view.prompt = 'Event and operations: done. End the Action Round' + gen_action('end_round') } }, event() { @@ -8386,7 +8436,7 @@ states.vm_tst_8 = { game.return_state = 'vm_tst_8' goto_vm(208) }, - done() { + end_round() { game.tst_8 = true end_round() } -- cgit v1.2.3