diff --git a/devTools/types/extensions.d.ts b/devTools/types/extensions.d.ts index b9b32455c007436a957ba03a8cf9afb982b2aeef..3b69613e15631488e2508f0b97dd86b14776765b 100644 --- a/devTools/types/extensions.d.ts +++ b/devTools/types/extensions.d.ts @@ -3,6 +3,16 @@ interface MousetrapStatic { record(callback: (this: MousetrapStatic, sequence: string[]) => void): void; } +interface Number { + /** + * Returns whether the value is between the given bounds, with optional inclusivity. + * @param min The minimum value to check against. + * @param max The maximum value to check against. + * @param inclusive Whether to include the bounds values. + */ + isBetween(min: number, max: number, inclusive?: boolean): boolean; +} + // d3-dtree declare namespace d3dTree { diff --git a/js/extensions/number.extension.js b/js/extensions/number.extension.js index 0e32bb8595ea16d40ec06091506ee072e281a015..4100d71828586408ac09ad1d87ade1bd922d709a 100644 --- a/js/extensions/number.extension.js +++ b/js/extensions/number.extension.js @@ -1,9 +1,3 @@ -/** - * Checks if the number is between two given values. - * @param {number} min The minimum value. - * @param {number} max The maximum value. - * @param {boolean} inclusive Whether or not to include the minimum and maximum values. - */ - Number.prototype.between = function(min, max, inclusive = false) { +Number.prototype.isBetween = function(min, max, inclusive = false) { return inclusive ? this >= min && this <= max : this > min && this < max; }; diff --git a/src/Mods/SecExp/js/secExpBC.js b/src/Mods/SecExp/js/secExpBC.js index d7707ad795708962d0cbaf50196f435df195a11a..cd64d30599ab68d3ab4f743296aa45562f9a6eea 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 || V.SecExp.edicts.weaponsLaw.between(0, 3, true) ? V.SecExp.edicts.weaponsLaw : 3; + V.SecExp.edicts.weaponsLaw = V.weaponsLaw || V.SecExp.edicts.weaponsLaw.isBetween(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 bb73ec95b6b1f3f3ae29a4f776d8f6860248afbd..e736864af8311eefd84f18295e113230bd948d9b 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 (V.economy.between(33, 100)) { + if (V.economy.isBetween(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 e7bc6922dfd575c133376d0400f92fcff8d90371..974f646cf6142796e82b4b9f88389aef4fed30a7 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" && App.EndWeek.saVars.subSlaveRatio.between(0, 0.8)) { + } else if (fetishChange > jsRandom(0, 100) && slave.fetish !== "masochist" && slave.fetish !== "submissive" && App.EndWeek.saVars.subSlaveRatio.isBetween(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 6e17200a3e2866b122551dba0174b2a11a1b4c30..594eb44f3d735b35ac6354a84229a5ae2794d132 100644 --- a/src/js/rulesAssistant.js +++ b/src/js/rulesAssistant.js @@ -142,7 +142,7 @@ globalThis.ruleAppliesP = function(rule, slave) { slave ); } - flag = slaveAttribute.between(cond.data.value[0], cond.data.value[1]); + flag = slaveAttribute.isBetween(cond.data.value[0], cond.data.value[1]); if (cond.applyRuleOnce && flag) { V.rulesToApplyOnce[rule.ID].push(slave.ID); } diff --git a/src/js/rulesAssistantOptions.js b/src/js/rulesAssistantOptions.js index fb71848936cabb24564abfbc82ecdb73414d3aab..0e3f68cc364adb912b79dd9aefdea6f4c2fac93f 100644 --- a/src/js/rulesAssistantOptions.js +++ b/src/js/rulesAssistantOptions.js @@ -1386,7 +1386,7 @@ App.RA.options = (function() { current_rule.condition.function = "custom"; current_rule.condition.data = ""; this.show_custom_editor(CustomEditor, current_rule.condition.data); - } else if (this.betweenP(value)) { + } else if (this.isBetweenP(value)) { current_rule.condition.function = "between"; current_rule.condition.data = {attribute: value, value: [null, null]}; this.show_custom_editor(RangeEditor, current_rule.condition.function, current_rule.condition.data); diff --git a/src/js/slaveCostJS.js b/src/js/slaveCostJS.js index 7a48568209890b4756e79d694830581629493585..778d7f550bdff8e9eb1c1fd130d985616c0da4d1 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 (V.retirementAge.between(30, 60, true)) { + if (V.retirementAge.isBetween(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 7ef0e5206425db390bd0c17eaceda92ec10e2068..bc5ebdf955f4c8cca87f01984512433cd14e6839 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 = slave.muscles.between(musclesMin, musclesMax); + test = slave.muscles.isBetween(musclesMin, musclesMax); fixable = (slave.muscles <= musclesMin && slave.muscles > musclesMax - musclesMin) || (slave.muscles >= musclesMax && slave.muscles < musclesMin + 30); if (fixable && passing === 0) { passing = 2;