From 7cc6a0edd1302338f71727f91b218334bc4dc91d Mon Sep 17 00:00:00 2001
From: Blank_Alt <>
Date: Sat, 3 Oct 2020 15:38:05 +1300
Subject: [PATCH] inital commit

---
 src/Mods/SecExp/buildings/secBarracks.tw |  8 ++++----
 src/Mods/SecExp/edicts.tw                |  8 ++++----
 src/Mods/SecExp/js/secExp.js             | 16 ++++++++++++++++
 src/Mods/SecExp/securityReport.tw        | 12 ++++++------
 4 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/src/Mods/SecExp/buildings/secBarracks.tw b/src/Mods/SecExp/buildings/secBarracks.tw
index 3e9d4c6e9d4..9a606abe232 100644
--- a/src/Mods/SecExp/buildings/secBarracks.tw
+++ b/src/Mods/SecExp/buildings/secBarracks.tw
@@ -303,13 +303,13 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> (
 	<div class="content">
 		You founded the $arcologies[0].name free militia. You are now able to organize your citizens into fighting units.
 		<<if $SecExp.edicts.defense.militia === 2>>
-			The militia is composed entirely of volunteers, your manpower is approximately 1.5% of the citizens population of your arcology.
+			The militia is composed entirely of volunteers, your manpower is <<= num(App.SecExp.militiaCap()*100)>>% of the citizens population of your arcology.
 		<<elseif $SecExp.edicts.defense.militia === 3>>
-			With the establishment of conscription, your available manpower has increased to now approximately 3% of the arcology's citizens population.
+			With the establishment of conscription, your available manpower has increased to now <<= num(App.SecExp.militiaCap()*100)>>% of the arcology's citizens population.
 		<<elseif $SecExp.edicts.defense.militia === 4>>
-			By establishing obligatory military service to obtain citizenship you have enlarged your manpower pool to be approximately 5% of the arcology's citizens population.
+			By establishing obligatory military service to obtain citizenship you have enlarged your manpower pool to be <<= num(App.SecExp.militiaCap()*100)>>% of the arcology's citizens population.
 		<<elseif $SecExp.edicts.defense.militia === 5>>
-			With the adoption of a militarized society, your available manpower has swelled to be approximately 15% of the arcology's citizens population.
+			With the adoption of a militarized society, your available manpower has swelled to be <<= num(App.SecExp.militiaCap()*100)>>% of the arcology's citizens population.
 		<</if>>
 		Your current total manpower is <<print num(App.SecExp.Manpower.totalMilitia)>>, of which <<print num(App.SecExp.Manpower.employedMilitia)>> is in active duty. You lost in total <<print num($militiaTotalCasualties)>> citizens, leaving you with <<print num($militiaFreeManpower)>> available citizens.
 		<br>Default unit name: <<textbox "$SecExp.defaultNames.militia" $SecExp.defaultNames.militia "secBarracks">> |
diff --git a/src/Mods/SecExp/edicts.tw b/src/Mods/SecExp/edicts.tw
index 5a1a2cccd40..e9187393bf8 100644
--- a/src/Mods/SecExp/edicts.tw
+++ b/src/Mods/SecExp/edicts.tw
@@ -421,7 +421,7 @@
 			<<else>>
 				<br>//Not enough Authority.//
 			<</if>>
-			<br>&nbsp;&nbsp;&nbsp;&nbsp;//Will replenish militia manpower slowly and will cap at 2% of the total citizens population.//
+			<br>&nbsp;&nbsp;&nbsp;&nbsp;//Will replenish militia manpower slowly and will cap at <<= num(App.SecExp.militiaCap(2)*100)>>% of the total citizens population.//
 		<</if>>
 
 		<<if $SecExp.edicts.defense.militia === 3>>
@@ -434,7 +434,7 @@
 			<<else>>
 				<br>//Not enough Authority.//
 			<</if>>
-			<br>&nbsp;&nbsp;&nbsp;&nbsp;//Will replenish militia manpower moderately fast and will cap at 5% of the total citizens population, but has a high authority cost//
+			<br>&nbsp;&nbsp;&nbsp;&nbsp;//Will replenish militia manpower moderately fast and will cap at <<= num(App.SecExp.militiaCap(3)*100)>>% of the total citizens population, but has a high authority cost//
 		<</if>>
 		<<if $SecExp.edicts.defense.militia === 4>>
 			<br>''Obligatory military service:'' every citizen is required to register and serve under the militia.
@@ -446,7 +446,7 @@
 			<<else>>
 				<br>//Not enough Authority.//
 			<</if>>
-			<br>&nbsp;&nbsp;&nbsp;&nbsp;//Will quickly replenish militia manpower and will cap at 10% of the total citizens population, but has a very high authority cost//
+			<br>&nbsp;&nbsp;&nbsp;&nbsp;//Will quickly replenish militia manpower and will cap at <<= num(App.SecExp.militiaCap(4)*100)>>% of the total citizens population, but has a very high authority cost//
 		<</if>>
 		<<if $SecExp.edicts.defense.militia === 5>>
 			<br>''Militarized Society:'' every adult citizen is required to train and actively participate in the military of the arcology.
@@ -458,7 +458,7 @@
 			<<else>>
 				<br>//Not enough Authority.//
 			<</if>>
-			<br>&nbsp;&nbsp;&nbsp;&nbsp;//Will very quickly replenish militia manpower and will cap at 20% of the total citizens population, but has an extremely high authority cost//
+			<br>&nbsp;&nbsp;&nbsp;&nbsp;//Will very quickly replenish militia manpower and will cap at <<= num(App.SecExp.militiaCap(5)*100)>>% of the total citizens population, but has an extremely high authority cost//
 		<</if>>
 
 
diff --git a/src/Mods/SecExp/js/secExp.js b/src/Mods/SecExp/js/secExp.js
index 6249ab30eb2..da6cdb20ff9 100644
--- a/src/Mods/SecExp/js/secExp.js
+++ b/src/Mods/SecExp/js/secExp.js
@@ -1,3 +1,19 @@
+/**
+ * Returns the raw percetnage of socity that can be drafted.
+ */
+App.SecExp.militiaCap = function(x = 0) {
+	x = x || V.SecExp.edicts.defense.militia;
+	if (x === 2) {
+		return 0.02;
+	} else if (x === 3) {
+		return 0.05;
+	} else if (x === 4) {
+		return 0.1;
+	} else if (x === 5) {
+		return 0.2;
+	}
+};
+
 App.SecExp.initTrade = function() {
 	if (V.SecExp.core.trade === 0 || !jsDef(V.SecExp.core.trade)) {
 		let init = jsRandom(20, 30);
diff --git a/src/Mods/SecExp/securityReport.tw b/src/Mods/SecExp/securityReport.tw
index cff4bc801b5..c3131f44fb8 100644
--- a/src/Mods/SecExp/securityReport.tw
+++ b/src/Mods/SecExp/securityReport.tw
@@ -363,24 +363,24 @@ Due to the deterioration of the old world countries, organized crime focuses mor
 		<</if>>
 		<<if $SecExp.edicts.defense.militia === 2>>
 			Your militia accepts only volunteering citizens, ready to defend their arcology.
-			<<set _recruitLimit = 0.02, _adjst = 0.0025>>
+			<<set _recruitLimit = App.SecExp.militiaCap(), _adjst = 0.0025>>
 			<<if $rep >= 10000>>
 				Many citizens volunteer just to fight for someone of your renown.
-				<<set _recruitLimit += 0.0025>>
+				<<set _recruitLimit += _adjst>>
 			<</if>>
 			<<if $SecExp.core.authority >= 10000>>
 				Many citizens feel it is their duty to fight for you, boosting volunteer enrollment.
-				<<set _recruitLimit += 0.0025>>
+				<<set _recruitLimit += _adjst>>
 			<</if>>
 		<<elseif $SecExp.edicts.defense.militia === 3>>
 			Adult citizens are required to join the militia for a period of time.
-			<<set _recruitLimit = 0.05, _adjst = 0.005>>
+			<<set _recruitLimit = App.SecExp.militiaCap(), _adjst = 0.005>>
 		<<elseif $SecExp.edicts.defense.militia === 4>>
 			Adult citizens are required to register and serve in the militia whenever necessary.
-			<<set _recruitLimit = 0.1, _adjst = 0.01>>
+			<<set _recruitLimit = App.SecExp.militiaCap(), _adjst = 0.01>>
 		<<elseif $SecExp.edicts.defense.militia === 5>>
 			Every citizen is required to train and participate in the military activities of the arcology.
-			<<set _recruitLimit = 0.2, _adjst = 0.02>>
+			<<set _recruitLimit = App.SecExp.militiaCap(), _adjst = 0.02>>
 		<</if>>
 		<<if $SecExp.edicts.defense.lowerRequirements == 1>>
 			Your lax physical requirements to enter the militia allows for a greater number of citizens to join.
-- 
GitLab