From c8cb24b8dc13895573db5c37a47ee74c27cdabd2 Mon Sep 17 00:00:00 2001
From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com>
Date: Fri, 20 Oct 2023 05:57:04 +0200
Subject: fix helo/air for scenario setup

---
 rules.js | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/rules.js b/rules.js
index 88587ff..17aecca 100644
--- a/rules.js
+++ b/rules.js
@@ -1200,8 +1200,8 @@ const SCENARIOS = {
 	},
 	"1958": {
 		gov_psl: 50,
-		air_avail: 6,
-		helo_avail: 4,
+		air_max: 6,
+		helo_max: 4,
 		naval: 2,
 		fln_psl: 60,
 		is_morocco_tunisia_independent: true,
@@ -1209,8 +1209,8 @@ const SCENARIOS = {
 	},
 	"1960": {
 		gov_psl: 45,
-		air_avail: 7,
-		helo_avail: 5,
+		air_max: 7,
+		helo_max: 5,
 		naval: 3,
 		fln_psl: 45,
 		is_morocco_tunisia_independent: true,
@@ -1389,6 +1389,7 @@ function setup_scenario(scenario_name) {
 
 	let scenario = SCENARIOS[scenario_name]
 	Object.assign(game, scenario)
+	restore_air_helo_avail()
 
 	log(`FLN PSL=${game.fln_psl}`)
 	game.fln_ap = roll_nd6(2)
@@ -4477,6 +4478,12 @@ function unit_and_area_recovery() {
 	})
 }
 
+function restore_air_helo_avail() {
+	game.air_avail = game.air_max
+	game.helo_avail = game.helo_max
+	// log(`Air Avail=${game.air_avail} Helo Avail=${game.helo_avail}`)
+}
+
 function unit_redeployment() {
 	log_h3("Redeployment")
 	for_each_non_neutralized_unit_in_algeria(u => {
@@ -4496,10 +4503,6 @@ function unit_redeployment() {
 			}
 		}
 	})
-
-	game.air_avail = game.air_max
-	game.helo_avail = game.helo_max
-	// log(`Air Avail=${game.air_avail} Helo Avail=${game.helo_avail}`)
 }
 
 function roll_coup_table(drm=0) {
@@ -4805,6 +4808,7 @@ function goto_turn_interphase() {
 
 	unit_and_area_recovery()
 	unit_redeployment()
+	restore_air_helo_avail()
 	final_psl_adjustment()
 
 	if (check_victory())
-- 
cgit v1.2.3