From 16ec42e7dc7d3fdea6fd20c4854123d6c579f640 Mon Sep 17 00:00:00 2001
From: DCoded <dicoded@email.com>
Date: Mon, 26 Apr 2021 23:50:28 -0400
Subject: [PATCH] Replaced between() with .between()

---
 devNotes/standaloneFunctions.md            |  3 ---
 devNotes/usefulJSFunctionDocumentation.txt |  5 -----
 js/utils.js                                | 18 ------------------
 src/Mods/SecExp/js/secExpBC.js             |  2 +-
 src/Mods/SpecialForce/SpecialForce.js      |  2 +-
 src/endWeek/saServeYourOtherSlaves.js      |  2 +-
 src/js/rulesAssistant.js                   |  5 +----
 src/js/slaveCostJS.js                      |  2 +-
 src/pregmod/eliteBreedingExam.js           |  2 +-
 9 files changed, 6 insertions(+), 35 deletions(-)

diff --git a/devNotes/standaloneFunctions.md b/devNotes/standaloneFunctions.md
index 778be13a60a..7526fe940f2 100644
--- a/devNotes/standaloneFunctions.md
+++ b/devNotes/standaloneFunctions.md
@@ -27,6 +27,3 @@ Collection of custom functions without dependencies on FC specific variables/dat
 
 * `jsDef(x)`:
     Returns whether x is undefined. A JS port of SugarCube's def.
-
-* `between(a, low, high)`:
-    Returns `true` if `a` is between `low` and `high`, otherwise `false`.
diff --git a/devNotes/usefulJSFunctionDocumentation.txt b/devNotes/usefulJSFunctionDocumentation.txt
index 4c85aa3bc1b..0108b253a8c 100644
--- a/devNotes/usefulJSFunctionDocumentation.txt
+++ b/devNotes/usefulJSFunctionDocumentation.txt
@@ -238,11 +238,6 @@ UtilJS [script]
 
 	weightedArray2HashMap()
 
-	between(a, low, high, mode = 'exclusive') - checks if the value is between low and high inputs. mode: defaults to exclusive but also supports 'inclusive'. e.g.
-		$trees === 1.
-		exclusive - between($trees, 1, 3) -> false
-		inclusive - between($trees, 1, 3) -> true
-
 	def() - Returns whether the input is defined, similar to SugarCube's def.
 
 Core Slave Functions:
diff --git a/js/utils.js b/js/utils.js
index 4f12699266a..cdc44b2d633 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -21,24 +21,6 @@ function isFloat(n) {
 	return Number.isFinite(n) && Math.floor(n) !== n;
 }
 
-/**
- * Determines if a is between low and high
- * @param {number} a
- * @param {number} low
- * @param {number} high
- * @param {"exclusive"|"inclusive"} [mode='exclusive'] defaults to 'exclusive' but also supports 'inclusive'.
- * @returns {boolean}
- */
-function between(a, low, high, mode = 'exclusive') {
-	if (low === null) { low = -Infinity; }
-	if (high === null) { high = Infinity; }
-	if (mode === 'exclusive') {
-		return a > low && a < high;
-	} else if (mode === 'inclusive') {
-		return a >= low && a <= high;
-	}
-}
-
 /**
  * @template {PropertyKey} T
  * @param {Object.<T, number>} obj
diff --git a/src/Mods/SecExp/js/secExpBC.js b/src/Mods/SecExp/js/secExpBC.js
index 7274b6d7b55..d7707ad7957 100644
--- a/src/Mods/SecExp/js/secExpBC.js
+++ b/src/Mods/SecExp/js/secExpBC.js
@@ -40,7 +40,7 @@ App.SecExp.generalBC = function() {
 	V.SecExp.edicts.SFSupportLevel = V.SecExp.edicts.SFSupportLevel || V.SFSupportLevel || 0;
 	V.SecExp.edicts.limitImmigration = V.SecExp.edicts.limitImmigration || V.limitImmigration || 0;
 	V.SecExp.edicts.openBorders = V.SecExp.edicts.openBorders || V.openBorders || 0;
-	V.SecExp.edicts.weaponsLaw = V.weaponsLaw || between(V.SecExp.edicts.weaponsLaw, 0, 3, 'inclusive') ? V.SecExp.edicts.weaponsLaw : 3;
+	V.SecExp.edicts.weaponsLaw = V.weaponsLaw || V.SecExp.edicts.weaponsLaw.between(0, 3, true) ? V.SecExp.edicts.weaponsLaw : 3;
 
 	V.SecExp.edicts.defense.soldierWages = V.SecExp.edicts.defense.soldierWages || V.soldierWages || 1;
 	V.SecExp.edicts.defense.slavesOfficers = V.SecExp.edicts.defense.slavesOfficers || V.slavesOfficers || 0;
diff --git a/src/Mods/SpecialForce/SpecialForce.js b/src/Mods/SpecialForce/SpecialForce.js
index 7eff80ab62e..bb73ec95b6b 100644
--- a/src/Mods/SpecialForce/SpecialForce.js
+++ b/src/Mods/SpecialForce/SpecialForce.js
@@ -1393,7 +1393,7 @@ App.SF.AAR = function(endWeekCall = 1) {
 			upkeep *= 0.75 + (V.SF.ArmySize/10000);
 		}
 
-		if (between(V.economy, 33, 100)) {
+		if (V.economy.between(33, 100)) {
 			let multiplier = (1.75 * Math.sqrt(Math.trunc(100000/V.economy-1000)/10)) + (0.2 * (Math.trunc(100000/V.economy-1000)/10));
 			income *= (1 + multiplier/100);
 		} else if (V.economy <= 33) { // There comes a point where a worse global economy no longer benefits your Special Forces.
diff --git a/src/endWeek/saServeYourOtherSlaves.js b/src/endWeek/saServeYourOtherSlaves.js
index a1c0b9f79df..e7bc6922dfd 100644
--- a/src/endWeek/saServeYourOtherSlaves.js
+++ b/src/endWeek/saServeYourOtherSlaves.js
@@ -1456,7 +1456,7 @@ App.SlaveAssignment.serveYourOtherSlaves = (function() {
 				if (slave.fetishStrength < 100) {
 					slave.fetishStrength++;
 				}
-			} else if (fetishChange > jsRandom(0, 100) && slave.fetish !== "masochist" && slave.fetish !== "submissive" && between(App.EndWeek.saVars.subSlaveRatio, 0, 0.8)) {
+			} else if (fetishChange > jsRandom(0, 100) && slave.fetish !== "masochist" && slave.fetish !== "submissive" && App.EndWeek.saVars.subSlaveRatio.between(0, 0.8)) {
 				r.push(`Being used as much as ${he} is starts to take a toll on ${him} sexuality; <span class="lightcoral">${he} begins to enjoy being your chattel's fucktoy.</span>`);
 				slave.fetish = "submissive";
 				slave.fetishStrength = 65;
diff --git a/src/js/rulesAssistant.js b/src/js/rulesAssistant.js
index 826982329b3..6e17200a3e2 100644
--- a/src/js/rulesAssistant.js
+++ b/src/js/rulesAssistant.js
@@ -142,10 +142,7 @@ globalThis.ruleAppliesP = function(rule, slave) {
 						slave
 					);
 			}
-			flag = between(
-				slaveAttribute,
-				cond.data.value[0],
-				cond.data.value[1]);
+			flag = slaveAttribute.between(cond.data.value[0], cond.data.value[1]);
 			if (cond.applyRuleOnce && flag) {
 				V.rulesToApplyOnce[rule.ID].push(slave.ID);
 			}
diff --git a/src/js/slaveCostJS.js b/src/js/slaveCostJS.js
index fcbb4a71a86..7a485682098 100644
--- a/src/js/slaveCostJS.js
+++ b/src/js/slaveCostJS.js
@@ -433,7 +433,7 @@ globalThis.BeautyArray = (function() {
 				adjustBeauty("Age: Youth Preferentialist", ((30 - slave.visualAge) / (30 - V.minimumSlaveAge) * ((arcology.FSYouthPreferentialist / 2) + (arcology.FSYouthPreferentialistLaw * 10)))); /* max 60 */
 			}
 		} else if (arcology.FSMaturityPreferentialist !== "unset") {
-			if (between(V.retirementAge, 30, 60, 'inclusive')) {
+			if (V.retirementAge.between(30, 60, true)) {
 				adjustBeauty("Age: Maturity Preferentialist", ((30 - slave.visualAge) / (30 - V.retirementAge) * ((arcology.FSMaturityPreferentialist / 2) + (arcology.FSMaturityPreferentialistLaw * 10)))); /* max 60, problems if retirementAge is 30 or under */
 			}
 		}
diff --git a/src/pregmod/eliteBreedingExam.js b/src/pregmod/eliteBreedingExam.js
index c5c2a3afa28..7ef0e520642 100644
--- a/src/pregmod/eliteBreedingExam.js
+++ b/src/pregmod/eliteBreedingExam.js
@@ -199,7 +199,7 @@ globalThis.eliteBreedingExam = function(slave = null) {
 			}
 			r.push(`Must not be overweight. ${result()}`);
 			if (slave) {
-				test = between(slave.muscles, musclesMin, musclesMax);
+				test = slave.muscles.between(musclesMin, musclesMax);
 				fixable = (slave.muscles <= musclesMin && slave.muscles > musclesMax - musclesMin) || (slave.muscles >= musclesMax && slave.muscles < musclesMin + 30);
 				if (fixable && passing === 0) {
 					passing = 2;
-- 
GitLab