From 2fcca1ce6223a34bdbee42d38c933332e7dfed17 Mon Sep 17 00:00:00 2001 From: iainp5 Date: Sat, 21 Sep 2024 08:45:15 +0100 Subject: vm_add_infl updated to be consistent with add_inf --- rules.js | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 6b29c4b..0cb5541 100644 --- a/rules.js +++ b/rules.js @@ -2011,6 +2011,7 @@ states.stasi_play_card = { function add_infl(space) { push_undo() + console.log('adding infl to', space) const clicked_space = find_space_index(space) //console.log('at start, event', game.persistent_events['austria_hungary_border_reopened'], 'ahbr', game.austria_hungary_border_reopened, 'tracker', game.austria_hungary_border_reopened_tracker) log(`Added 1 influence in %${clicked_space}.`) @@ -2055,10 +2056,13 @@ function add_infl(space) { // Check for Genscher & Austria Hungary Border Reopened if (game.available_ops === 1) { + console.log(`in Genscher / AHBR check, game.persistent_events['genscher']`, game.persistent_events['genscher']) if (game.active === DEM) { if (game.persistent_events['genscher'] || (game.persistent_events['austria_hungary_border_reopened'] && game.austria_hungary_border_reopened_tracker)) { + console.log('in gensher subcheck - remove non-East German controlled ') game.valid_spaces = game.valid_spaces.filter(n => !(game.pieces[n].comCtrl === 1 && spaces[n].country !== 'East_Germany')) } else { + console.log('remove all controlled spaces') game.valid_spaces = game.valid_spaces.filter(n => game.pieces[n].comCtrl !== 1) } } else { @@ -4008,21 +4012,27 @@ function vm_take_control(space) { function vm_do_add_infl(space) { push_undo() + console.log('adding infl to', space) const clicked_space = find_space_index(space) + //console.log('at start, event', game.persistent_events['austria_hungary_border_reopened'], 'ahbr', game.austria_hungary_border_reopened, 'tracker', game.austria_hungary_border_reopened_tracker) log(`Added 1 influence in %${clicked_space}.`) - + if (spaces[clicked_space].country !== 'East_Germany'){ game.austria_hungary_border_reopened_tracker = false } - + // Check Genscher if (game.persistent_events['genscher'] && game.active === DEM && spaces[clicked_space].country === 'East_Germany') { game.vm_available_ops-- } else if (check_control(clicked_space)) { game.vm_available_ops -= 2 + //Check if Austria Hungary Border Reopened was used to place last SP in a controlled space in East Germany. If so, game.vm_available_op will be negative + if (game.vm_available_ops < 0) { + log(`(Used +1 op from C58)`) + } } else { game.vm_available_ops-- -} + } // Update influence values if (game.active === COM) { @@ -4031,35 +4041,40 @@ 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 + // Check whether spaces are controlled + check_control_change(clicked_space) + + // Check Austria Hungary Border Reopened 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.vm_available_ops ++ - log('+1 influence from Austria-Hungary Border Reopened') + log('+1 influence from C58') game.austria_hungary_border_reopened_tracker = false game.valid_spaces = game.valid_spaces.filter(n => spaces[n].country === 'East_Germany') } - // Check whether spaces are controlled - check_control_change(clicked_space) - // If only 1 IP remaining, may not place in opponent controlled spaces - // Check for Genscher - + + // Check for Genscher & Austria Hungary Border Reopened + if (game.vm_available_ops === 1) { + console.log(`in Genscher / AHBR check, game.persistent_events['genscher']`, game.persistent_events['genscher']) if (game.active === DEM) { - if (!game.persistent_events['genscher']) { - game.valid_spaces = game.valid_spaces.filter(n => game.pieces[n].comCtrl !== 1) - } else { + if (game.persistent_events['genscher'] || (game.persistent_events['austria_hungary_border_reopened'] && game.austria_hungary_border_reopened_tracker)) { + console.log('in gensher subcheck - remove non-East German controlled ') game.valid_spaces = game.valid_spaces.filter(n => !(game.pieces[n].comCtrl === 1 && spaces[n].country !== 'East_Germany')) + } else { + console.log('remove all controlled spaces') + game.valid_spaces = game.valid_spaces.filter(n => game.pieces[n].comCtrl !== 1) } } else { game.valid_spaces = game.valid_spaces.filter(n => game.pieces[n].demCtrl !== 1) } } - if (game.vm_available_ops === 0) {game.valid_spaces = []} - //console.log('game pieces:', game.pieces[clicked_space]) + //Clear valid spaces if no IP remaining. + if (game.vm_available_ops <= 0 ) { + game.valid_spaces = [] + } } function vm_do_add_infl_free(space) { -- cgit v1.2.3