From a7513b3b48aeb8aa74881aabaaa4766a682e6808 Mon Sep 17 00:00:00 2001 From: iainp5 Date: Thu, 19 Sep 2024 08:52:57 +0100 Subject: Fix for Austria Hungary Border Reopened --- notes.txt | 0 rules.js | 65 ++++++++++++++++++++++++++++++++++++--------------------------- 2 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 notes.txt diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..e69de29 diff --git a/rules.js b/rules.js index 69a1de0..690c1cb 100644 --- a/rules.js +++ b/rules.js @@ -50,9 +50,7 @@ exports.setup = function (seed, scenario, options) { stasi_card: 0, samizdat_card: 0, table_cards: [], - austria_hungary_border_reopened: false, - austria_hungary_border_reopened_tracker: true, - austria_hungary_border_reopened_checked: false, + austria_hungary_border_reopened_tracker: false, temp: 0, available_ops: 0, vm_available_ops: 0, @@ -571,6 +569,9 @@ states.play_card ={ game.phase = 1 /*Do I need this? */ game.vm_event_to_do = true } + + // Set AHBR tracker to true + game.austria_hungary_border_reopened_tracker = true game.state='add_influence' valid_spaces_infl() }, @@ -627,6 +628,8 @@ states.resolve_opponent_event = { }, influence(){ push_undo() + // Set AHBR tracker to true + game.austria_hungary_border_reopened_tracker = true game.state = 'finish_add_infl' valid_spaces_infl() }, @@ -764,6 +767,7 @@ states.add_influence = { }, done() { if(game.vm_event_to_do) { + reset_austria_hungary_border_reopened() game.state = 'resolve_opponent_event'} else { end_round()} @@ -873,9 +877,8 @@ states.support_check_prep = { game.selected_space = find_space_index(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.austria_hungary_border_reopened_checked) { - game.austria_hungary_border_reopened_checked = true + //console.log('game.austria_hungary_border_reopened_checked', game.austria_hungary_border_reopened_checked) + if (game.available_ops > 1) { console.log('in ahb check, country, ', spaces[game.selected_space].country, 'ahb', game.persistent_events['austria_hungary_border_reopened']) if (spaces[game.selected_space].country === 'East_Germany' && game.persistent_events['austria_hungary_border_reopened'] && game.active === DEM) { game.state = 'austria_hungary_border_reopened_check' @@ -895,9 +898,9 @@ states.support_check_prep = { game.state = 'raise_stakes_1' return } - game.austria_hungary_border_reopened_checked = false - game.austria_hungary_border_reopened_used = false + if (game.vm_event_to_do) { + reset_austria_hungary_border_reopened() game.state = 'resolve_opponent_event' } else { end_round() @@ -932,7 +935,7 @@ states.austria_hungary_border_reopened_check = { gen_action('no') }, yes() { - game.austria_hungary_border_reopened_used = true + game.austria_hungary_border_reopened_tracker = true game.state = 'do_support_check' }, no() { @@ -1984,10 +1987,10 @@ function add_infl(space) { check_control_change(clicked_space) // Check Austria Hungary Border Reopened is true and condition has been met - if (game.available_ops === 0 && game.active === DEM && game.persistent_events['austria_hungary_border_reopened'] && game.austria_hungary_border_reopened_tracker && !game.austria_hungary_border_reopened) { + if (game.available_ops === 0 && game.active === DEM && game.persistent_events['austria_hungary_border_reopened'] && game.austria_hungary_border_reopened_tracker) { game.available_ops ++ log('+1 influence from C58') - game.austria_hungary_border_reopened = true + game.austria_hungary_border_reopened_tracker = false game.valid_spaces = game.valid_spaces.filter(n => spaces[n].country === 'East_Germany') } @@ -2136,7 +2139,7 @@ function do_sc(space) { roll-- log('-1 from C101') } - if (game.active === DEM && game.austria_hungary_border_reopened_used) { + if (game.active === DEM && game.persistent_events['austria_hungary_border_reopened'] && game.austria_hungary_border_reopened_tracker) { roll++ log(`+1 from C58`) } @@ -2224,7 +2227,7 @@ function do_sc(space) { } // If Austria-Hungary Border Reopened used, all future support checks must be in East Germany - if (game.austria_hungary_border_reopened_used) { + if (game.austria_hungary_border_reopened_tracker) { game.valid_spaces = game.valid_spaces.filter(n => spaces[n].country === 'East_Germany') } game.selected_space = 0 @@ -2798,6 +2801,11 @@ function goto_game_over(result, victory) { } +function reset_austria_hungary_border_reopened() { + //game.austria_hungary_border_reopened_checked = false + game.austria_hungary_border_reopened_tracker = false +} + // =========== MOVING THROUGH TURNS ============ function end_round() { @@ -2828,6 +2836,8 @@ function end_round() { game.return = '' game.valid_cards = [] game.valid_spaces = [] + reset_austria_hungary_border_reopened() /*This should be redundant! */ + // Check for duplicate card entries let card_check @@ -2870,13 +2880,6 @@ function end_round() { - // Resolve Events - - if (game.persistent_events['austria_hungary_border_reopened']) { - game.austria_hungary_border_reopened = false - game.austria_hungary_border_reopened_tracker = true - } - console.log('game.dem_tst_position ', game.dem_tst_position , 'game.com_tst_position ', game.com_tst_position ) // Check if last round and if so resolve end turn events @@ -3627,6 +3630,10 @@ function vm_return() { console.log('in vm_return, discard:', game.strategy_discard) game.support_check_modifier = 0 game.vm_event = 0 /*Reset to 0 now that event has been completed. Hopefully this doesn't cause issues! */ + if (game.persistent_events['austria_hungary_border_reopened']) { + reset_austria_hungary_border_reopened() + } + //game.view_opp_hand = false console.log('in vm_return, game.vm_return:', game.vm_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) { @@ -3963,11 +3970,12 @@ function vm_do_add_infl(space) { game.pieces[clicked_space].demInfl++ } + /* Will AHBR ever apply in vm add influence? */ // Check Austria Hungary Border Reoponed is true and condition has been met - if (game.vm_available_ops === 0 && game.active === DEM && game.persistent_events['austria_hungary_border_reopened'] && game.austria_hungary_border_reopened_tracker && !game.austria_hungary_border_reopened) { + if (game.vm_available_ops === 0 && game.active === DEM && game.persistent_events['austria_hungary_border_reopened'] && game.austria_hungary_border_reopened_tracker) { game.vm_available_ops ++ log('+1 influence from Austria-Hungary Border Reopened') - game.austria_hungary_border_reopened = true + game.austria_hungary_border_reopened_tracker = false game.valid_spaces = game.valid_spaces.filter(n => spaces[n].country === 'East_Germany') } @@ -4306,8 +4314,6 @@ function vm_army_backs_revolution() { function vm_austria_hungary_border_reopened() { game.persistent_events['austria_hungary_border_reopened'] = true - game.austria_hungary_border_reopened = false - game.austria_hungary_border_reopened_tracker = true game.table_cards.push(58) vm_next() } @@ -5388,9 +5394,8 @@ states.vm_support_check_prep = { game.selected_space = find_space_index(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.austria_hungary_border_reopened_checked) { - game.austria_hungary_border_reopened_checked = true + //console.log('game.austria_hungary_border_reopened_checked', game.austria_hungary_border_reopened_checked) + if (game.vm_available_ops > 1) { console.log('in ahb check, country, ', spaces[game.selected_space].country, 'ahb', game.persistent_events['austria_hungary_border_reopened']) if (spaces[game.selected_space].country === 'East_Germany' && game.persistent_events['austria_hungary_border_reopened'] && game.active === DEM) { game.state = 'vm_austria_hungary_border_reopened_check' @@ -5414,7 +5419,7 @@ states.vm_austria_hungary_border_reopened_check = { gen_action('no') }, yes() { - game.austria_hungary_border_reopened_used = true + game.austria_hungary_border_reopened_tracker = true game.state = 'vm_do_support_check' }, no() { @@ -5923,6 +5928,7 @@ states.vm_goodbye_lenin_ops = { push_undo() game.vm_available_ops = cards[this_card()].ops if (game.persistent_events['sinatra_doctrine']) { + log(`+1 from C50`) game.vm_available_ops++ } valid_spaces_infl() @@ -7119,6 +7125,9 @@ states.vm_tst_6 = { push_undo() console.log('in vm_valid_spaces_sc: game.persistent_events[we_are_the_people]', game.persistent_events['we_are_the_people']) game.selected_space = find_space_index(space) + if (game.active === DEM && game.persistent_events['austria_hungary_border_reopened'] && spaces[space].country === "East_Germany") { + game.austria_hungary_border_reopened_tracker = true + } game.state = 'vm_tst_6_sc' }, done () { -- cgit v1.2.3