From 3d0a13315566d1b7e114a14e652062d286b47a11 Mon Sep 17 00:00:00 2001
From: iainp5 <iain.pearce.ip@gmail.com>
Date: Fri, 20 Sep 2024 10:35:04 +0100
Subject: Updates to Austria Hungary Border Reopened

---
 rules.js | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/rules.js b/rules.js
index 70a08d4..aa0c170 100644
--- a/rules.js
+++ b/rules.js
@@ -1972,6 +1972,11 @@ function add_infl(space) {
 		game.available_ops--
 	} else if (check_control(clicked_space)) {
 		game.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.available_op will be negative
+		if (game.available_ops < 0) {
+			log(`Used +1 from C58`)
+			game.available_ops = 0
+		}  
 	} else {
 	game.available_ops--
 	}
@@ -1996,21 +2001,21 @@ function add_infl(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.available_ops === 1) {
 			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.valid_spaces = game.valid_spaces.filter(n => !(game.pieces[n].comCtrl === 1 && spaces[n].country !== 'East_Germany'))
+				} else {				
+					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)
 			}
 		} 
 
-	//Clear valid spaces if  no IP remaining
+	//Clear valid spaces if no IP remaining. 
 	if (game.available_ops === 0 ) {
 		game.valid_spaces = []
 	}
@@ -2669,7 +2674,7 @@ function score_country(country) {
 				log(`Battlegrounds: -${presence.com_battlegrounds} VP`)
 				com_vp -= presence.com_battlegrounds
 			}
-			log(`Total: ${com_vp} VP`)
+			log(`Total: -${com_vp} VP`)
 		} else {
 			log('No presence: 0 VP')
 		}
@@ -2710,6 +2715,7 @@ function score_country(country) {
 		log_gap(`Communist:`)
 		if (presence.com_spaces > 0) {
 			log(`Presence: -${value_presence} VP`)
+			com_vp -= value_presence
 			if (presence.com_battlegrounds > 0) {
 				log(`Battlegrounds:  -${presence.com_battlegrounds} VP`)
 				com_vp -= presence.com_battlegrounds
@@ -2720,10 +2726,12 @@ function score_country(country) {
 		log_gap('Democrat:')
 		if (presence.dem_spaces > 0) {
 			log(`Presence: +${value_presence} VP`)
+			dem_vp += value_presence
 			if (presence.dem_battlegrounds > 0) {
 				log(`Battlegrounds: +${presence.dem_battlegrounds} VP`)	
 				dem_vp += presence.dem_battlegrounds
 			}
+			log(`Total: +${dem_vp} VP`)
 		} else {
 			log('No presence: 0 VP')
 		}
@@ -5393,7 +5401,15 @@ states.vm_support_check_prep = {
 		push_undo()
 		game.selected_space = find_space_index(space)
 
-		// Check for Austria-Hungary Border Reopened - check on first support check only
+	// Check for Austria-Hungary Border Reopened - check on first support check only
+		//First check for Monday Demonstrations - support checks will always be in East Germany
+		if (game.played_card === 61 || game.vm_event === 61) {
+			game.austria_hungary_border_reopened_tracker = true
+			game.state = 'vm_do_support_check'
+			return
+		}
+
+		//Then check Austria-Hungary Border Reopened normally
 		//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'])
@@ -5663,10 +5679,10 @@ states.vm_dash_for_the_west = {
 	},
 	prompt() {
 		if (game.phase === 1) {
-			view.prompt = 'Roll a die'
+			view.prompt = 'Dash for The West: roll a die'
 			gen_action('roll')
 		} else {
-			view.prompt = 'Roll a die: done.'
+			view.prompt = 'Dash for the West: roll a die. Done.'
 			gen_action('done')
 		}
 	},
-- 
cgit v1.2.3