summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2024-09-21 11:34:03 +0100
committeriainp5 <iain.pearce.ip@gmail.com>2024-09-21 11:34:03 +0100
commit27b3605dc838fded565fb1b75f3efc6b1ed6f033 (patch)
treea26e5acb6f8d4505fa68fa3942d0c0d0bef259c8
parent2fcca1ce6223a34bdbee42d38c933332e7dfed17 (diff)
download1989-dawn-of-freedom-27b3605dc838fded565fb1b75f3efc6b1ed6f033.tar.gz
Fix for valid_spaces_infl called in VM
-rw-r--r--rules.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/rules.js b/rules.js
index 0cb5541..90c9179 100644
--- a/rules.js
+++ b/rules.js
@@ -2412,30 +2412,42 @@ function valid_spaces_support_falters() {
}
function valid_spaces_infl() {
+ console.log('valid_spaces_infl called')
+
+ // Check if function is called from the VM or not, take relevant ops variable
+ let ops = game.state.startsWith('vm') ? game.vm_available_ops : game.available_ops;
+
let valid_spaces_set = new Set();
// Iterate over all spaces to find the ones with the player's influence
for (let piece of game.pieces) {
if (!piece) continue
+ console.log('checking piece:', piece)
const player_influence = game.active === COM ? piece.comInfl : piece.demInfl;
// If the piece has the player's influence, add it and its adjacent spaces to the set
if (player_influence > 0) {
+ console.log(piece, 'added to set')
valid_spaces_set.add(piece.space_id);
// Check adjacency information
for (let adj_space_id of piece.adjacent) {
+ console.log('checking adjacent space', spaces[adj_space_id].name_unique)
if (adj_space_id) {
const adj_piece = game.pieces.find(p => p && p.space_id === adj_space_id);
-
+ console.log('adjacent piece', adj_piece)
// Check if the adjacent space is controlled by the opponent
const opponent_control = game.active === COM ? adj_piece.demCtrl : adj_piece.comCtrl;
+ console.log('controlled?', opponent_control)
+ console.log('genscher?', game.persistent_events['genscher'])
//Check for Genscher. Can always place in East Germany even with 1 op
if (game.active === DEM && adj_piece.country === 'East_Germany' && game.persistent_events['genscher']){
+ console.log('space added with genscher')
valid_spaces_set.add(adj_piece.space_id)
}
// Otherwise, only add the adjacent space if the available_ops >= 2 or the space is not controlled by the opponent
- if (game.available_ops >= 2 || !opponent_control) {
+ if (ops >= 2 || !opponent_control) {
+ console.log('space added normally')
valid_spaces_set.add(adj_piece.space_id)
}
}
@@ -4012,7 +4024,7 @@ function vm_take_control(space) {
function vm_do_add_infl(space) {
push_undo()
- console.log('adding infl to', space)
+ console.log('in vm_do_add_infl, space', 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}.`)
@@ -5208,6 +5220,7 @@ states.vm_take_control = {
states.vm_add_infl = {
inactive: 'add influence.',
prompt () {
+ console.log('in vm add infl')
if (game.vm_available_ops > 0 && game.valid_spaces.length === 0 ) {
view.prompt = 'No available spaces remaining. Add influence: done.'
gen_action('done')
@@ -6002,6 +6015,7 @@ states.vm_goodbye_lenin = {
return `resolve ${clean_name(cards[game.played_card].name)}.`
},
prompt() {
+ console.log('in vm_goodbye lenin')
if (game.valid_cards.length > 0 ) {
view.prompt = 'Choose a card to play for the event, or play Goodbye Lenin for operations'
for (let card of game.valid_cards) {
@@ -6048,7 +6062,9 @@ states.vm_goodbye_lenin_ops = {
log(`+1 from C50`)
game.vm_available_ops++
}
+ console.log('goodbye lenin: influence selected')
valid_spaces_infl()
+
game.state = 'vm_add_infl'
},
support_check() {