diff --git a/devNotes/standaloneFunctions.md b/devNotes/standaloneFunctions.md index 778be13a60a117c38f8936adb09a37cfc8febb04..7526fe940f275543534d33b0508f7be921ff8991 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 4c85aa3bc1b94c90092265880080414451b19365..0108b253a8c74b72104c2048239bafb36f69aab1 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 4f12699266a5d314939830e8f09c1789c1327649..cdc44b2d63320a887407a5f6b1146f12a35fca4f 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 7274b6d7b5525b789415e5db991cce632a7fdf59..d7707ad795708962d0cbaf50196f435df195a11a 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 7eff80ab62eeba5ea720eaf19d516e035add653a..bb73ec95b6b1f3f3ae29a4f776d8f6860248afbd 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 a1c0b9f79dfb472c9924c2868cee4f50380f3598..e7bc6922dfd575c133376d0400f92fcff8d90371 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 826982329b3340ddb665ddd08e6ede3ea2ef486c..6e17200a3e2866b122551dba0174b2a11a1b4c30 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 fcbb4a71a861ce6cad4e6a41a41be5bc9b5c1838..7a48568209890b4756e79d694830581629493585 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 c5c2a3afa28cbc58ec241e1336e7fad06e41d6aa..7ef0e5206425db390bd0c17eaceda92ec10e2068 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;