diff options
author | iainp5 <iain.pearce.ip@gmail.com> | 2024-09-21 08:45:15 +0100 |
---|---|---|
committer | iainp5 <iain.pearce.ip@gmail.com> | 2024-09-21 08:45:15 +0100 |
commit | 2fcca1ce6223a34bdbee42d38c933332e7dfed17 (patch) | |
tree | 6b4c118afee8e7fb247cb18621032851396d3c04 /rules.js | |
parent | 657df8663eac0495878981a3e461c26d98a08494 (diff) | |
download | 1989-dawn-of-freedom-2fcca1ce6223a34bdbee42d38c933332e7dfed17.tar.gz |
vm_add_infl updated to be consistent with add_inf
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 47 |
1 files changed, 31 insertions, 16 deletions
@@ -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) {
|