diff --git a/src/js/DefaultRules.js b/src/js/DefaultRules.js index e2b4b18a0027d248e598cf1b9cd17c27663d2bc4..e1a2f3a5e68f94d43fea3ea91f11274726336455 100644 --- a/src/js/DefaultRules.js +++ b/src/js/DefaultRules.js @@ -2909,7 +2909,6 @@ window.DefaultRules = (function() { * @param {App.RA.RuleSetters} rule */ function ProcessLabel(slave, rule) { - //mass removal of old tags, variant from '*' mask. if (rule.removeLabel !== null && rule.removeLabel !== '' && rule.removeLabel == '*') { slave.custom.label = slave.custom.label.replace(/(?:\[.+\])+/, ""); @@ -2924,8 +2923,9 @@ window.DefaultRules = (function() { //removing tags selected for removal. let tags = [], i; - if (rule.removeLabel != null && rule.removeLabel !== '') + if (rule.removeLabel != null && rule.removeLabel !== '') { tags = rule.removeLabel.split("|"); + } for (i in tags) { if (tags[i] !== null && tags[i] !== '' && slave.custom.label.includes(`[${tags[i]}]`)) { @@ -2936,8 +2936,9 @@ window.DefaultRules = (function() { //finally adding new tags. tags = []; - if (rule.label != null && rule.label !== '') + if (rule.label != null && rule.label !== '') { tags = rule.label.split("|"); + } for (i in tags) { if (tags[i] != null && tags[i] !== '' && !slave.custom.label.includes(`[${tags[i]}]`)) { @@ -2945,7 +2946,6 @@ window.DefaultRules = (function() { r += `<br>${slave.slaveName} has been tagged as ${tags[i]}`; } } - } return DefaultRules; diff --git a/src/js/ageAdjustYoungRelative.js b/src/js/ageAdjustYoungRelative.js index 5993a4c67a8ae20cfe14dd7d18061f0b592ef196..90ec07b756932691e78aec9dcaca889e23e2f1ba 100644 --- a/src/js/ageAdjustYoungRelative.js +++ b/src/js/ageAdjustYoungRelative.js @@ -3,7 +3,7 @@ * Generally these adjustments should match the age limiters found in generateNewSlave.js. */ - window.AgeAdjustYoungRelative = function(slave) { +window.AgeAdjustYoungRelative = function(slave) { /* breast size */ const origBoobs = slave.boobs; if (slave.physicalAge <= 10) { diff --git a/src/js/assayJS.js b/src/js/assayJS.js index 0e92c0bb7e8c755208c1cba51ea1424fd2ecbae1..8287fa231b816b8bb5969f5fafe9ba4c39a977fa 100644 --- a/src/js/assayJS.js +++ b/src/js/assayJS.js @@ -72,7 +72,6 @@ window.isLeaderP = function isLeaderP(slave) { * @param {App.Entity.SlaveState} slave */ window.newSlave = function newSlave(slave) { - if (slave.override_Eye_Color !== 1) { switch (slave.eyeColor) { case "blind blue": diff --git a/src/js/assignJS.js b/src/js/assignJS.js index 45afe62b3427b592b1df7d09a6254f7aed1b2c93..abde43fb31e2b44169aaefdbd53d9649cfe6fede 100644 --- a/src/js/assignJS.js +++ b/src/js/assignJS.js @@ -756,7 +756,7 @@ App.currentAgent = function() { * @param {App.Entity.Facilities.Facility} facility * @param {string} [managerAssignment="rest"] new assignment for the facility manager * @param {string} [workerAssignment="rest"] new assignment for the facility workers -*/ + */ App.Utils.moveFacilityWorkers = function(facility, managerAssignment = "rest", workerAssignment = "rest") { if (facility.manager && facility.manager.currentEmployee) { assignJob(facility.manager.currentEmployee, managerAssignment); @@ -791,9 +791,9 @@ App.Utils.jobForAssignment = function() { } /** - * @param {string} assignment - * @returns {App.Entity.Facilities.Job} - */ + * @param {string} assignment + * @returns {App.Entity.Facilities.Job} + */ function getJob(assignment) { if (map.size === 0) { fillMap(); diff --git a/src/js/customizeSlaveTrade.js b/src/js/customizeSlaveTrade.js index aefddb4a0158700ff44bd6849d90e05270efaa44..f7e0e59d22eb946bd59d550013c6aa1e1a32b3d9 100644 --- a/src/js/customizeSlaveTrade.js +++ b/src/js/customizeSlaveTrade.js @@ -1,11 +1,11 @@ window.App.CustomSlaveTrade = { - export: function () { + export: function() { let textArea = document.createElement("textarea"); textArea.value = JSON.stringify(State.variables.nationalities); $("#importExportArea").html(textArea); }, - import: function () { + import: function() { let textArea = document.createElement("textarea"); let button = document.createElement("button"); button.name = "Load"; @@ -16,6 +16,5 @@ window.App.CustomSlaveTrade = { }; $("#importExportArea").html("").append(textArea).append(button); - } -}; \ No newline at end of file +}; diff --git a/src/js/datatypeCleanupJS.js b/src/js/datatypeCleanupJS.js index bae5e274a381dd5536ad338bff24c7418630eb9c..5a0079a59db2eece210eba507a3d917e754d1c55 100644 --- a/src/js/datatypeCleanupJS.js +++ b/src/js/datatypeCleanupJS.js @@ -266,11 +266,11 @@ App.Entity.Utils.SlaveDataSchemeCleanup = (function() { */ function migrateScars(slave) { if (!slave.hasOwnProperty("scar")) { - slave.scar = {}; // switching to singular to match .brand and someday others. + slave.scar = {}; // switching to singular to match .brand and someday others. } if (slave.hasOwnProperty("scars")) { // even if it's 0 if (slave.scars === 5) { - App.Medicine.Modification.addScar(slave, "left cheek", "menacing"); // old location was not defined, but surgery described it as facial. Putting it on left cheek for a default. + App.Medicine.Modification.addScar(slave, "left cheek", "menacing"); // old location was not defined, but surgery described it as facial. Putting it on left cheek for a default. } else if (slave.scars === 6) { App.Medicine.Modification.addScar(slave, "left cheek", "exotic"); } else if (slave.scars) { // not 0 @@ -316,7 +316,7 @@ App.Entity.Utils.SlaveDataSchemeCleanup = (function() { */ window.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() { "use strict"; - + return SlaveDatatypeCleanup; /** @@ -1039,7 +1039,6 @@ window.ChildDatatypeCleanup = function ChildDatatypeCleanup(child) { }; window.childAgeDatatypeCleanup = function childAgeDatatypeCleanup(child) { - child.birthWeek = Math.clamp(+child.birthWeek, 0, 51) || 0; if (child.age > 0) { child.actualAge = Math.clamp(+child.actualAge, V.minimumChildAge, Infinity) || child.age; /* if undefined, this sets to child.age */ @@ -1616,7 +1615,6 @@ window.PCDatatypeCleanup = function PCDatatypeCleanup() { }; window.EconomyDatatypeCleanup = function EconomyDatatypeCleanup() { - V.ACitizens = Math.max(+V.ACitizens, 0) || 0; V.ASlaves = Math.max(+V.ASlaves, 0) || 0; V.shelterAbuse = Math.max(+V.shelterAbuse, 0) || 0; @@ -1694,7 +1692,6 @@ window.EconomyDatatypeCleanup = function EconomyDatatypeCleanup() { }; window.ArcologyDatatypeCleanup = function ArcologyDatatypeCleanup() { - V.arcologies[0].prosperity = Math.clamp(+V.arcologies[0].prosperity, 1, 300) || 1; V.AProsperityCap = Math.max(+V.AProsperityCap, 0) || 0; V.arcologies[0].ownership = Math.clamp(+V.arcologies[0].ownership, 0, 100) || 0; @@ -1749,7 +1746,7 @@ window.ArcologyDatatypeCleanup = function ArcologyDatatypeCleanup() { window.FacilityDatatypeCleanup = (function() { "use strict"; - + return FacilityDatatypeCleanup; function FacilityDatatypeCleanup() { diff --git a/src/js/descriptionWidgets.js b/src/js/descriptionWidgets.js index 394625a92b1d6570b3c41296b557240c021db4ec..32cd88f5c7beabaf8485b82936eb8c6e2874333f 100644 --- a/src/js/descriptionWidgets.js +++ b/src/js/descriptionWidgets.js @@ -1012,11 +1012,11 @@ App.Desc.expandScarString = function(slave, surface) { // scars can sometimes be } } else if (surface === "belly" ) { r += "scars from "; - if (scar > 1) { - r += "a crazy network of scars, as though a hack had tried internal surgery"; - } else { - r += "some faint scarring as though from internal surgery"; - } + if (scar > 1) { + r += "a crazy network of scars, as though a hack had tried internal surgery"; + } else { + r += "some faint scarring as though from internal surgery"; + } } else { r += "a "; if (scar > 1) { diff --git a/src/js/economyJS.js b/src/js/economyJS.js index 431470e0903190179356ce8f5da9a0874d3e770c..5752692576adf7a5dd764dc15460a93b48818a2e 100644 --- a/src/js/economyJS.js +++ b/src/js/economyJS.js @@ -1133,7 +1133,7 @@ window.slaveJobValues = function() { } else { let canA = canDoAnal(s); let canV = canDoVaginal(s); - let skilltarget = (100 + ((s.skill.anal - 100)*canA*(1.5 - .5*canV) + (s.skill.vaginal - 100)*canV*(1.5 - .5*canA) + (s.skill.oral - 100)*(3 - 1.5*canA - 1.5*canV + canA*canV))*3/10); + let skilltarget = (100 + ((s.skill.anal - 100)*canA*(1.5 - 0.5*canV) + (s.skill.vaginal - 100)*canV*(1.5 - 0.5*canA) + (s.skill.oral - 100)*(3 - 1.5*canA - 1.5*canV + canA*canV))*3/10); // Complicated, I know - but it should automatically account for what acts are possible to scale the injury risk smoothly between 90% when totally unskilled // and 0% when perfectly skilled in the relevant method or methods. @@ -1290,7 +1290,6 @@ The third category, the "slave slot" is completely optional. Sometimes you just */ window.cashX = function(cost, what, who) { - if (!Number.isFinite(cost)) { V.lastWeeksCashErrors += `Expected a finite number for ${what}, but got ${cost}<br>`; return 0; @@ -1337,7 +1336,6 @@ window.cashX = function(cost, what, who) { }; window.repX = function(rep, what, who) { - if (!Number.isFinite(rep)) { V.lastWeeksRepErrors += `Expected a finite number for ${what}, but got ${rep}<br>`; return 0; diff --git a/src/js/eventSelectionJS.js b/src/js/eventSelectionJS.js index 2f9237478f7458a05a947ae75c19c4ce3fb267b4..e2af6370ccbcb4d5c69deaeb017f4c3dc27537f9 100644 --- a/src/js/eventSelectionJS.js +++ b/src/js/eventSelectionJS.js @@ -874,7 +874,7 @@ window.generateRandomEventPoolStandard = function(eventSlave) { if (eventSlave.pubertyXX === 0) { if (eventSlave.preg === 0) { if (eventSlave.physicalAge + eventSlave.birthWeek / 52 >= eventSlave.pubertyAgeXX - 0.5) { - State.variables.RESSevent.push(...Array.from({length:10}, i=>"first period")); + State.variables.RESSevent.push(...Array.from({length: 10}, i=>"first period")); } } } @@ -883,7 +883,7 @@ window.generateRandomEventPoolStandard = function(eventSlave) { if (eventSlave.balls > 0) { if (eventSlave.pubertyXY === 0) { if (eventSlave.physicalAge + eventSlave.birthWeek / 52 >= eventSlave.pubertyAgeXY - 0.5) { - State.variables.RESSevent.push(...Array.from({length:10}, i=>"wet dreams")); + State.variables.RESSevent.push(...Array.from({length: 10}, i=>"wet dreams")); } } } diff --git a/src/js/generateGenetics.js b/src/js/generateGenetics.js index 2a208ea424b1aaad120bd91838d164cc82244363..258f127dd617aaf1bb51510ce2b53196908a76fe 100644 --- a/src/js/generateGenetics.js +++ b/src/js/generateGenetics.js @@ -7,7 +7,7 @@ window.generateGenetics = (function() { let activeMother; let father; let activeFather; - + // intelligence and face parameters are the same so we can use the same distribution for both values // clamping makes edge values (-100, 100) more likely; this is expected behavior diff --git a/src/js/generateNewSlaveJS.js b/src/js/generateNewSlaveJS.js index 6ace878e32ad0d2cf7425815a7ecde1bec5ac16a..4d77c5a1f4b42106154f90e5f58226cdcf7974f5 100644 --- a/src/js/generateNewSlaveJS.js +++ b/src/js/generateNewSlaveJS.js @@ -1,7 +1,7 @@ /* eslint-disable camelcase */ window.GenerateNewSlave = (function() { "use strict"; - + let chance; /** * @type {App.Entity.SlaveState} */ diff --git a/src/js/itemAvailability.js b/src/js/itemAvailability.js index 0f74318a91c3ee05229740fe59ab73d17fd1e894..d4332d322db45f927c5555cb6493f2e923a2b72b 100644 --- a/src/js/itemAvailability.js +++ b/src/js/itemAvailability.js @@ -6,7 +6,6 @@ * @returns {boolean} */ window.isItemAccessible = function(string) { - if (V.cheatMode === 1) { return true; } diff --git a/src/js/modification.js b/src/js/modification.js index 994c0094cbbf40209384196492a8c3d5095c68a4..8386465b2e4cc6c53f5d63e38e5d6c8614423c54 100644 --- a/src/js/modification.js +++ b/src/js/modification.js @@ -1,10 +1,11 @@ App.Medicine.Modification = {}; + /** * Basic application of scar * @param {App.Entity.SlaveState} slave * @param {string} scar - * @param {string} design - * @param {string} weight + * @param {string} design + * @param {string} weight */ App.Medicine.Modification.addScar = function(slave, scar, design, weight) { /* @@ -38,8 +39,8 @@ App.Medicine.Modification.removeScar = function(slave, scar, design) { slave.health -= 10; //dangerous to uncomment this as sometimes many scars are applied at once. cashX(forceNeg(surgery.costs), "slaveSurgery", slave); slave.health -= (V.PC.medicine >= 100) ? Math.round(surgery.healthCosts / 2) : surgery.healthCosts;*/ - if (slave.scar.hasOwnProperty(scar)) { // if scar object exists for this body part - if (slave.scar[scar].hasOwnProperty(design)) { // if object has this kind of scar (might be custom) + if (slave.scar.hasOwnProperty(scar)) { // if scar object exists for this body part + if (slave.scar[scar].hasOwnProperty(design)) { // if object has this kind of scar (might be custom) if (["generic", "whip", "chain", "burn", "menacing", "exotic", "surgical", "c-section", "cutting"].includes(design)) { slave.scar[scar][design] = 0; } else { @@ -62,7 +63,7 @@ App.Medicine.Modification.removeScar = function(slave, scar, design) { /** * Slave is whipped over the entire body, and strains in manacles so much that the wrists and ankles scar if present. * @param {App.Entity.SlaveState} slave - * @param {string} weight + * @param {string} weight */ App.Medicine.Modification.addScourged = function(slave, weight) { let scarArray = ["left breast", "right breast", "back", "lower back", "left buttock", "right buttock"]; diff --git a/src/js/playerJS.js b/src/js/playerJS.js index ff30ba42e573fbd812f5453b68fb600f27af04a9..1568d7af2842ef93f52b3d0236f10c3cd389ed8b 100644 --- a/src/js/playerJS.js +++ b/src/js/playerJS.js @@ -597,7 +597,7 @@ window.PCTitle = function PCTitle() { } else if (V.slaves.length > 10) { titles.push("owner of slaves"); } - const corpValue = App.Corporate.value; + const corpValue = App.Corporate.value; if (corpValue > 500000) { titles.push("Corporate Titan"); } else if (corpValue > 250000) { diff --git a/src/js/rulesAssistant.js b/src/js/rulesAssistant.js index abab9a1e041d4230795d43013b000c6654eafe8e..a10b2367642d63a911edf29acb5fc964fa9ce593 100644 --- a/src/js/rulesAssistant.js +++ b/src/js/rulesAssistant.js @@ -594,12 +594,14 @@ App.RA.ruleDeepAssign = function deepAssign(target, source) { target[key] = {}; } deepAssign(target[key], source[key]); - } else if (key == "label" || key == "removeLabel") { - if (source[key] != null) - if (target[key] != null) - target[key] += "|" + source[key]; - else - target[key] = source[key]; + } else if (key === "label" || key === "removeLabel") { + if (source[key] != null) { + if (target[key] != null) { + target[key] += "|" + source[key]; + } else { + target[key] = source[key]; + } + } } else { // A rule overrides any preceding ones if, // * there are no preceding ones, @@ -614,6 +616,5 @@ App.RA.ruleDeepAssign = function deepAssign(target, source) { } } } - return target; }; diff --git a/src/js/rulesAutosurgery.js b/src/js/rulesAutosurgery.js index 42b7d81a2addf0d0b6a389cc7c9c3c64e6d690db..b098012ef04ad048fc9490b98817625ce0b294ba 100644 --- a/src/js/rulesAutosurgery.js +++ b/src/js/rulesAutosurgery.js @@ -1,7 +1,7 @@ /* eslint-disable camelcase */ window.rulesAutosurgery = (function() { "use strict"; - + let r; return rulesAutoSurgery; @@ -434,7 +434,7 @@ window.rulesAutosurgery = (function() { V.surgeryType = "bellyOut"; } } - if(slave.health > 20 && surgeries.length < 3) { + if (slave.health > 20 && surgeries.length < 3) { if (slave.horn !== "none" && thisSurgery.horn === 1) { commitProcedure(`surgery to remove ${his} implanted horns`, s => { s.horn = "none"; }); } else if (slave.horn !== "curved succubus horns" && thisSurgery.horn === 2) { @@ -451,7 +451,7 @@ window.rulesAutosurgery = (function() { commitProcedure(`surgery to implant ${his} with small horns`, s => { s.horn = "small horns"; s.hornColor = "white"; }); } } - if(slave.health > 20 && surgeries.length < 3) { + if (slave.health > 20 && surgeries.length < 3) { if (slave.earShape !== "normal" && thisSurgery.earShape === 1) { commitProcedure(`surgery to restore ${his} modified ears`, s => { s.earShape = "normal"; }); } else if (slave.earShape !== "pointy" && thisSurgery.earShape === 2) { diff --git a/src/js/slaveCostJS.js b/src/js/slaveCostJS.js index 92b008e286139182c2361d63f94ff140544fd317..ddeb790ec9c9b6aca9381a04ee71b619bc1aef70 100644 --- a/src/js/slaveCostJS.js +++ b/src/js/slaveCostJS.js @@ -1,6 +1,6 @@ window.Beauty = (function() { "use strict"; - + let arcology; let beauty; @@ -1516,7 +1516,7 @@ window.FResult = (function() { // we can't initialize our global variables on load, because SugarCube.State isn't initialized // instead, declare them and initialize on run time // eslint-disable-next-line camelcase - + let result; let incestBonus; /** @@ -1967,7 +1967,7 @@ window.FResult = (function() { window.slaveCost = (function() { "use strict"; - + let arcology; let multiplier; let cost; diff --git a/src/js/slaveListing.js b/src/js/slaveListing.js index 4a6e684e00ed800d221b5e3b211ed62842cccc4b..98c4333ebc809575cb22a58e6a2d2cc140d1808a 100644 --- a/src/js/slaveListing.js +++ b/src/js/slaveListing.js @@ -14,16 +14,16 @@ App.UI.SlaveList = {}; * @returns {string} */ - /** - * @callback slaveToElement - * @param {App.Entity.SlaveState} slave - * @param {number} index - * @returns {HTMLElement|DocumentFragment} - */ +/** + * @callback slaveToElement + * @param {App.Entity.SlaveState} slave + * @param {number} index + * @returns {HTMLElement|DocumentFragment} + */ App.UI.SlaveList.render = function() { 'use strict'; - + /** @type {string} */ let passageName; /** @type {App.Entity.SlaveState[]} */ @@ -499,7 +499,6 @@ App.UI.SlaveList.SlaveInteract.personalAttention = (slave) => * @param {number} id slave id */ App.UI.selectSlaveForPersonalAttention = function(id) { - if (!Array.isArray(V.personalAttention)) { /* first PA target */ V.personalAttention = [{ @@ -670,7 +669,7 @@ App.UI.SlaveList.listNGPSlaves = function() { App.UI.SlaveList.makeNameDecorator(["emphasizedSlave", "pink"]), (s, i) => App.UI.DOM.passageLink('Remove from import list', thisPassage, () => { variables().slavesToImport -= 1; removeJob(variables().slaves[i], NGPassignment); } - ))); + ))); } else { r += App.UI.tabbar.makeTab("remove", `<em>No slaves will go with you to the new game</em>`); } @@ -682,7 +681,7 @@ App.UI.SlaveList.listNGPSlaves = function() { App.UI.SlaveList.makeNameDecorator(["emphasizedSlave", "pink"]), (s, i) => App.UI.DOM.passageLink('Add to import list', thisPassage, () => { variables().slavesToImport += 1; assignJob(variables().slaves[i], NGPassignment); } - ))); + ))); } else { r += App.UI.tabbar.makeTab("assign", `<strong>Slave import limit reached</strong>`); } @@ -1132,8 +1131,8 @@ App.UI.SlaveList.slaveSelectionList = function() { const listPostNote = options.expCheck ? (options.postNote ? (s, i) => options.expCheck(s) ? App.UI.DOM.combineNodes( - App.UI.DOM.makeSpan("Has applicable career experience.", "lime"), - document.createElement("br"), + App.UI.DOM.makeSpan("Has applicable career experience.", "lime"), + document.createElement("br"), options.postNote(s, i) ) : options.postNote(s, i) : (s) => options.expCheck(s) ? App.UI.DOM.makeSpan("Has applicable career experience.", "lime") : null) : diff --git a/src/js/slaveStatsChecker.js b/src/js/slaveStatsChecker.js index 59279bf31bcae83384bd99667fb46ec17f8455ee..6f3229a1d0c9c8fbe41c20c517bdf53bba62f284 100644 --- a/src/js/slaveStatsChecker.js +++ b/src/js/slaveStatsChecker.js @@ -374,7 +374,7 @@ window.bimboScore = function(slave) { if (slave.lips > 70) { degree++; } - if ((slave.lipsImplant / slave.lips) >= .60) { + if ((slave.lipsImplant / slave.lips) >= 0.60) { degree++; } if (slave.boobs >= 2000) { @@ -383,7 +383,7 @@ window.bimboScore = function(slave) { degree++; } } - if ((slave.boobsImplant / slave.boobs) >= .60) { + if ((slave.boobsImplant / slave.boobs) >= 0.60) { degree++; } if (slave.butt > 4) { @@ -392,7 +392,7 @@ window.bimboScore = function(slave) { degree++; } } - if ((slave.buttImplant / slave.butt) >= .60) { + if ((slave.buttImplant / slave.butt) >= 0.60) { degree++; } if (slave.belly >= 1500) { diff --git a/src/js/slaveSummaryWidgets.js b/src/js/slaveSummaryWidgets.js index 53290e8a5a4cf8d5002dae2975c8113d905b1d3d..4dab64ef9682eb7afec5873dcbf7d0cba51a7c39 100644 --- a/src/js/slaveSummaryWidgets.js +++ b/src/js/slaveSummaryWidgets.js @@ -29,7 +29,7 @@ window.SlaveSummary = function SlaveSummary(slave) { window.SlaveSummaryUncached = (function() { "use strict"; - + /** @type {DocumentFragment} */ let res; @@ -721,7 +721,7 @@ window.SlaveSummaryUncached = (function() { makeSpan(c, "H", ["green", "strong"], true, slave.health); } if (passage() === "Clinic" && V.clinicUpgradeScanner) { - if(slave.chem > 15) { + if (slave.chem > 15) { makeSpan(c, `C${Math.ceil(slave.chem/10)}`, ["cyan", "strong"]); } else if (slave.chem <= 15 && slave.assignment === "get treatment in the clinic") { makeSpan(c, `CSafe`, ["green", "strong"]); @@ -751,7 +751,7 @@ window.SlaveSummaryUncached = (function() { makeSpan(c, "Unnaturally healthy", "green", true, slave.health); } if (passage() === "Clinic" && V.clinicUpgradeScanner) { - if(slave.chem > 15) { + if (slave.chem > 15) { makeSpan(c, `Carcinogen buildup: ${Math.ceil(slave.chem/10)}.`, "cyan"); } else if (slave.chem <= 15 && slave.assignment === "get treatment in the clinic") { makeSpan(c, `Safe chem levels.`, "green"); @@ -899,7 +899,7 @@ window.SlaveSummaryUncached = (function() { } else if (slave.hormones > 0) { makeSpan(c, "Ho:F", styles); } else if (slave.hormones < -1) { - makeSpan(c, "Ho:M+", styles, ); + makeSpan(c, "Ho:M+", styles); } else if (slave.hormones < 0) { makeSpan(c, "Ho:M", styles); } diff --git a/src/js/surgery.js b/src/js/surgery.js index ce32040e35bcaf10ab43d1faec236b0082b6144e..8c7bff3f518258d5a954dfc31d8f936bc28850fe 100644 --- a/src/js/surgery.js +++ b/src/js/surgery.js @@ -731,7 +731,7 @@ window.upgradeLimbs = function(slave, newId) { * @param {App.Entity.SlaveState} slave * @param {string} limb * @param {number} id - * @param {boolean} clean if the slave should be cleaned of all existing + * @param {boolean} clean if the slave should be cleaned of all existing */ window.configureLimbs = function(slave, limb, id, clean = false) { if (limb === "all") { diff --git a/src/js/utilJS.js b/src/js/utilJS.js index f634c97780d76d9acbe892a29ff87a68c94a8f4d..4a814174e5b9bc20b160683e89b9503c3dae0f28 100644 --- a/src/js/utilJS.js +++ b/src/js/utilJS.js @@ -1063,95 +1063,69 @@ window.num = function(x) { return `negative ${numberAsString}`; } } - }; -window.asPlural = function(single, plural) -{ - if(typeof single !== 'string') - { - let asObj = single; - single = asObj.single; - plural = asObj.plural; - } - if(plural == null) - { - plural = single + "s"; - } - return plural; -}; -window.asSingular = function(single) -{ - if(typeof single !== 'string') - { - let asObj = single; - single = asObj.single; - } - return single; +window.asPlural = function(single, plural) { + if (typeof single !== 'string') { + let asObj = single; + single = asObj.single; + plural = asObj.plural; + } + if (plural == null) { + plural = single + "s"; + } + return plural; +}; +window.asSingular = function(single) { + if (typeof single !== 'string') { + let asObj = single; + single = asObj.single; + } + return single; }; //When 1, shows "a (slave)" -window.numberWithPlural = function (number, single, plural) -{ - if(number == 0) - { - return "no " + asPlural(single, plural); - } - else if(number == 1) - { - return addA(asSingular(single)); - } - else if(number > 0 && number < 1) - { - return "less than one " + asSingular(single); - } - else - { - return number + " " + asPlural(single, plural); - } -} +window.numberWithPlural = function(number, single, plural) { + if (number === 0) { + return "no " + asPlural(single, plural); + } else if (number === 1) { + return addA(asSingular(single)); + } else if (number > 0 && number < 1) { + return "less than one " + asSingular(single); + } else { + return number + " " + asPlural(single, plural); + } +}; + //when 1, shows "one (slave)" -window.numberWithPluralOne = function (number, single, plural) -{ - if(number == 0) - { - return "no " + asPlural(single, plural); - } - else if(number == 1) - { - return "one " + asSingular(single); - } - else if(number > 0 && number < 1) - { - return "less than one " + asSingular(single); - } - else - { - return number + " " + asPlural(single, plural); - } -} +window.numberWithPluralOne = function(number, single, plural) { + if (number === 0) { + return "no " + asPlural(single, plural); + } else if (number === 1) { + return "one " + asSingular(single); + } else if (number > 0 && number < 1) { + return "less than one " + asSingular(single); + } else { + return number + " " + asPlural(single, plural); + } +}; //shows "less than one (slave)" instead of "no (slaves)" when number is 0. -window.numberWithPluralNonZero = function (number, single, plural) -{ - if(number == 0) number = 0.1; - return numberWithPlural(number, single, plural); -} -window.onlyPlural = function(number, single, plural) -{ - if(number > 0 && number <= 1) - { - return asSingular(single); - } - return asPlural(single, plural); -} -window.Seperator = function(seperatorObject) -{ - if(seperatorObject.need) - { - return seperatorObject.text; - } - seperatorObject.need = true; - return ""; -} +window.numberWithPluralNonZero = function(number, single, plural) { + if (number === 0) { number = 0.1; } + return numberWithPlural(number, single, plural); +}; +window.onlyPlural = function(number, single, plural) { + if (number > 0 && number <= 1) { + return asSingular(single); + } + return asPlural(single, plural); +}; +window.Seperator = function(seperatorObject) { + if (seperatorObject.need) { + return seperatorObject.text; + } + seperatorObject.need = true; + return ""; +}; /** * Returns numbers with comma, e.g. 10000 as "10,000", according to the player's settings * @param {number} s @@ -1214,20 +1188,17 @@ window.years = function(weeks) { return r; }; -window.asDate = function(weeks, bonusDay = 0) -{ - if(weeks == null) - { - weeks = State.variables.week; - } - let d = new Date(2037, 0, 12); - d.setDate(d.getDate() + weeks * 7 + bonusDay); - return d; -} -window.asDateString = function(weeks, bonusDay = 0) -{ - return asDate(weeks, bonusDay).toLocaleString(undefined, {year:'numeric', month:'long', day:'numeric'}); -} +window.asDate = function(weeks, bonusDay = 0) { + if (weeks == null) { + weeks = State.variables.week; + } + let d = new Date(2037, 0, 12); + d.setDate(d.getDate() + weeks * 7 + bonusDay); + return d; +}; +window.asDateString = function(weeks, bonusDay = 0) { + return asDate(weeks, bonusDay).toLocaleString(undefined, {year: 'numeric', month: 'long', day: 'numeric'}); +}; /** * Returns whether x is undefined * @param {any} x @@ -1249,12 +1220,11 @@ window.cashFormat = function(s) { return `¤${commaNum(s)}`; }; window.cashFormatColor = function(s, invert = false) { - //Display red if the value is negative, unless invert is true - if((s > 0) == invert) - { - return `<span class='red'>${cashFormat(s)}</span>`; - } - return `<span class='yellowgreen'>${cashFormat(s)}</span>`; + //Display red if the value is negative, unless invert is true + if ((s > 0) === invert) { + return `<span class='red'>${cashFormat(s)}</span>`; + } + return `<span class='yellowgreen'>${cashFormat(s)}</span>`; }; /** @@ -1742,11 +1712,10 @@ window.ordinalSuffix = function ordinalSuffix(i) { }; window.ordinalSuffixWords = function(i) { const text = ["zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth"]; - if(i < text.length) - { - return text[i]; - } - return ordinalSuffix(i); + if (i < text.length) { + return text[i]; + } + return ordinalSuffix(i); }; /** @@ -2449,16 +2418,15 @@ App.Utils.escapeHtml = function(text) { * @param {*} originalList The original list the index refers into. * @param {*} newList The new list which we want an index for * @returns {number} The new index into newList -*/ -App.Utils.mapIndexBetweenLists = function(index, originalList, newList) -{ - if(index == 0) return 0; - if(index == originalList.length - 1) return newList.length - 1; - index--; - const originalLimitedLength = originalList.length - 2; - const newLimitedLength = newList.length - 2; - return Math.round((index / originalLimitedLength) * newLimitedLength) + 1; -} + */ +App.Utils.mapIndexBetweenLists = function(index, originalList, newList) { + if (index === 0) { return 0; } + if (index === originalList.length - 1) { return newList.length - 1; } + index--; + const originalLimitedLength = originalList.length - 2; + const newLimitedLength = newList.length - 2; + return Math.round((index / originalLimitedLength) * newLimitedLength) + 1; +}; /** * Creates a HTML element with custom SugarCube attributes which works as a passage link * @@ -3269,12 +3237,10 @@ window.moreNational = function(nation) { }; //Creates an object where the items are accessible via their ids. -window.mapIdList = function(list) -{ - let mappedList = {}; - for(const item of list) - { - mappedList[item.id] = item; - } - return mappedList; -} +window.mapIdList = function(list) { + let mappedList = {}; + for (const item of list) { + mappedList[item.id] = item; + } + return mappedList; +}; diff --git a/src/js/utilsDOM.js b/src/js/utilsDOM.js index 3c679257ddcbbd061927a72d4a1a83db68e3028e..168c1b8f8c1a6fdf0125241fe63fded1519e9284 100644 --- a/src/js/utilsDOM.js +++ b/src/js/utilsDOM.js @@ -123,9 +123,9 @@ App.UI.DOM.disabledLink = function(link, reasons) { }; /** -* @param {string} text -* @param {string|string[]} [classNames] -*/ + * @param {string} text + * @param {string|string[]} [classNames] + */ App.UI.DOM.makeSpan = function makeSpan(text, classNames) { let r = document.createElement("span"); if (classNames !== undefined) { @@ -141,7 +141,7 @@ App.UI.DOM.makeSpan = function makeSpan(text, classNames) { /** * @param {string} passage - * @return {Element} + * @returns {Element} */ App.Utils.passageElement = function(passage) { return document.querySelector(`tw-passagedata[name="${passage}"]`);