From 94beb25a8f8331b35ed94e3b88b64371b74a0d8c Mon Sep 17 00:00:00 2001
From: Cameron Roberts <cameronr@hotmail.ca>
Date: Wed, 2 Oct 2019 21:22:58 -0700
Subject: [PATCH] Fix to security drone unit when security drones have not been
 purchased

---
 src/SecExp/js/secExp.js   |  5 +++++
 src/SecExp/secBarracks.tw | 30 ++++++++++++++++--------------
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/src/SecExp/js/secExp.js b/src/SecExp/js/secExp.js
index aee28142626..8d9588cd3ff 100644
--- a/src/SecExp/js/secExp.js
+++ b/src/SecExp/js/secExp.js
@@ -3837,6 +3837,11 @@ App.SecExp.unit = (function() {
 	function description(input, unitType = '') {
 		const V = State.variables; let r = ``;
 		if (V.SecExp.settings.unitDescriptions === 0) {
+			if(unitType === "Bots" && V.arcologyUpgrade.drones !== 1){
+				r += `The drone security system arcoloy upgrade must be installed before drones can be deployed in battle.`
+				return r;
+			}
+			
 			if (unitType !== "Bots") {
 				r += `\n<strong>${input.platoonName}</strong> `;
 			} else {
diff --git a/src/SecExp/secBarracks.tw b/src/SecExp/secBarracks.tw
index ebe740450ca..73324ddffb9 100644
--- a/src/SecExp/secBarracks.tw
+++ b/src/SecExp/secBarracks.tw
@@ -145,25 +145,27 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> (
 <br>
 <<= App.SecExp.unit.dec($secBots, "Bots")>>
 <br>
-<<if $secBots.active == 1>>
-	<<link "Review Equipment and upgrades" "seeUnit">>
-		<<set $targetUnit = "secBots">>
-	<</link>>
-	<<if $secBots.troops < $secBots.maxTroops>>
-		|
-		<<link "Replenish the unit" "secBarracks">>
+<<if $arcologyUpgrade.drones == 1>>
+	<<if $secBots.active == 1>>
+		<<link "Review Equipment and upgrades" "seeUnit">>
+			<<set $targetUnit = "secBots">>
+		<</link>>
+		<<if $secBots.troops < $secBots.maxTroops>>
+			|
+			<<link "Replenish the unit" "secBarracks">>
+				<<run cashX(forceNeg(($secBots.maxTroops - $secBots.troops) * $secBotsCost), "securityExpansion")>>
+				<<set $secBots.troops = $secBots.maxTroops>>
+			<</link>>
+		<</if>>
+	<<else>>
+		<<link "Rebuild the unit" "secBarracks">>
 			<<run cashX(forceNeg(($secBots.maxTroops - $secBots.troops) * $secBotsCost), "securityExpansion")>>
 			<<set $secBots.troops = $secBots.maxTroops>>
+			<<set $secBots.active = 1>>
 		<</link>>
 	<</if>>
-<<else>>
-	<<link "Rebuild the unit" "secBarracks">>
-		<<run cashX(forceNeg(($secBots.maxTroops - $secBots.troops) * $secBotsCost), "securityExpansion")>>
-		<<set $secBots.troops = $secBots.maxTroops>>
-		<<set $secBots.active = 1>>
-	<</link>>
 <</if>>
-
+	
 <br><br>__Slaves__
 <br>/* slaves */
 You are free to organize your menial slaves into fighting units. Currently you have <<print num($menials)>> slaves available, while <<print num($slavesEmployedManpower)>> are already employed as soldiers. During all your battles you lost a total of <<print num($slavesTotalCasualties)>>.
-- 
GitLab