diff --git a/src/interaction/main/mainLinks.js b/src/interaction/main/mainLinks.js index 32554adc37994a6deaa31ccc97d459cfcf05f850..7bcbe2eeec6bd4dd22ba79964a972a88ec12328a 100644 --- a/src/interaction/main/mainLinks.js +++ b/src/interaction/main/mainLinks.js @@ -1,10 +1,8 @@ /* OPEN MAIN */ -App.UI.View.MainLinks = function() { +App.UI.View.MainLinks = function () { "use strict"; const V = State.variables; - const PA = Array.isArray(V.personalAttention) ? V.personalAttention.map(function(x) { - return getSlave(x.ID); - }) : []; + const PA = Array.isArray(V.personalAttention) ? V.personalAttention.map(x => getSlave(x.ID)) : []; let r = ''; if (V.PCWounded === 1) { @@ -122,12 +120,10 @@ App.UI.View.MainLinks = function() { return (typeof organ === 'object' && getSlave(organ.ID) !== undefined); }); /* cycle through slaves, for each slave cycle through completed organs and track how many are of the interrogated slave (and if organs have a slaves to be implanted on) */ + let slaveOrgans; for (let i = 0; i < V.slaves.length; i++) { - let slaveOrgans = 0; - V.completedOrgans.forEach(organ => { - if (organ.ID === V.slaves[i].ID) - slaveOrgans++; - }); + slaveOrgans = 0; + V.completedOrgans.forEach(organ => { if (organ.ID === V.slaves[i].ID) { slaveOrgans++; } }); /* if the interrogated slave has one or more organs ready: */ if (slaveOrgans > 0) { r += '<br><span class="yellow">The fabricator has completed '; @@ -148,9 +144,10 @@ App.UI.View.MainLinks = function() { } if (V.adjustProstheticsCompleted > 0) { + let i; for (let j = 0; j < V.adjustProsthetics.length; j++) { if (getSlave(V.adjustProsthetics[j].slaveID) !== undefined) { - let i = V.slaveIndices[V.adjustProsthetics[j].slaveID]; + i = V.slaveIndices[V.adjustProsthetics[j].slaveID]; if (V.adjustProsthetics[j].workLeft <= 0) { r += `<br><span class="yellow">The lab has completed <<= addA(setup.prosthetics[$adjustProsthetics[${j}].id].name)>> for</span> <span id="name"><<= "[[SlaveFullName($slaves[${i}])|Slave Interact][$activeSlave = $slaves[${i}]]]">>,</span> <span class="yellow"> which is ready to be attached.</span>`; } diff --git a/src/js/assayJS.js b/src/js/assayJS.js index 60dd55bb852828526948a502c6dc460c09451682..8ce6ec6e4f73cccf851c5e60f609359a53656a8e 100644 --- a/src/js/assayJS.js +++ b/src/js/assayJS.js @@ -311,19 +311,19 @@ window.removeSlave = function removeSlave(index) { State.variables.slaveIndices = slaves2indices(); return ret; }; + window.removeChild = function removeChild(index) { - const ret = State.variables.cribs.deleteAt(index); - return ret; + return State.variables.cribs.deleteAt(index); }; /** * @param {App.Entity.SlaveState[]} [slaves] * @returns {Object.<number, number>} */ -window.slaves2indices = function slaves2indices(slaves) { - slaves = slaves || State.variables.slaves; +window.slaves2indices = function slaves2indices(slaves = State.variables.slaves) { return slaves.reduce((acc, slave, i) => { acc[slave.ID] = i; return acc; }, {}); }; + /** * @param {number} ID * @returns {App.Entity.SlaveState} @@ -332,9 +332,9 @@ window.getSlave = function getSlave(ID) { const index = State.variables.slaveIndices[ID]; return index === undefined ? undefined : State.variables.slaves[index]; }; + window.getChild = function getChild(ID) { - const V = State.variables; - return V.cribs.find(function(s) {return s.ID === ID;}); + return State.variables.cribs.find(function(s) {return s.ID === ID;}); }; App.Utils.Pronouns = class { diff --git a/src/js/datatypeCleanupJS.js b/src/js/datatypeCleanupJS.js index 0a425fdf3ccc4b7917d63c5ae41e6dc46fba65aa..d7d1b74d67f429823356121aa301a261aec4bdce 100644 --- a/src/js/datatypeCleanupJS.js +++ b/src/js/datatypeCleanupJS.js @@ -201,12 +201,13 @@ window.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() { /** * @param {App.Entity.SlaveState} slave - * @param {number} isIncubatorSlave + * @param {boolean} isIncubatorSlave */ - function SlaveDatatypeCleanup(slave, isIncubatorSlave) { + function SlaveDatatypeCleanup(slave, isIncubatorSlave = false) { V = State.variables; - if (isIncubatorSlave !== true) + if (!isIncubatorSlave) { slaveAgeDatatypeCleanup(slave); + } slavePhysicalDatatypeCleanup(slave); slaveFaceDatatypeCleanup(slave); slaveHairDatatypeCleanup(slave); @@ -1671,9 +1672,7 @@ window.FacilityDatatypeCleanup = (function() { if (!Array.isArray(facilityIDArray)) { facilityIDArray = []; } else if (typeof facilityIDArray[0] === "object") { - facilityIDArray = facilityIDArray.map(function(a) { - return a.ID; - }); + facilityIDArray = facilityIDArray.map(a => a.ID); } } helperFunction(V.BrothiIDs); diff --git a/src/js/economyJS.js b/src/js/economyJS.js index ce667235c7ff3bb19fb6db825c75a5926135dff9..8455f0aa5a6364d35657d3396c149622d9567716 100644 --- a/src/js/economyJS.js +++ b/src/js/economyJS.js @@ -1399,8 +1399,7 @@ window.getSlaveStatisticData = function(s, facility) { return data; }; -window.initFacilityStatistics = function(facility) { - facility = facility || {}; +window.initFacilityStatistics = function(facility = {}) { facility.adsIncome = 0; facility.maintenance = 0; facility.totalIncome = 0; diff --git a/src/js/pregJS.js b/src/js/pregJS.js index 641ef7329c818484e4baec887d273b81f071fc89..853e4d66669c5c5c5cfc03816ebe5b13a1af97d4 100644 --- a/src/js/pregJS.js +++ b/src/js/pregJS.js @@ -22,7 +22,6 @@ window.getPregBellySize = function(s) { * @returns {string} */ window.bellyAdjective = function(slave) { - slave = slave || State.variables.activeSlave; if (slave.belly >= 1500) { if (slave.belly >= 1000000) { if (slave.preg > slave.pregData.normalBirth/4) { diff --git a/src/js/slaveGenerationJS.js b/src/js/slaveGenerationJS.js index a5e7d3fdb7924f14125c5000f6fa841b5feead62..e05b2e9cb99d73328b7e34e0c12d72bcd9efe28b 100644 --- a/src/js/slaveGenerationJS.js +++ b/src/js/slaveGenerationJS.js @@ -27,10 +27,9 @@ window.raceToNationality = function raceToNationality(slave) { * @param {string | Object} nationality * @param {string | Object} race * @param {boolean} male - * @param {undefined} [filter] + * @param {undefined} [filter] Default: allow all */ -window.generateName = function generateName(nationality, race, male, filter) { - filter = filter || _.stubTrue; /* default: allow all */ +window.generateName = function generateName(nationality, race, male, filter = _.stubTrue) { const lookup = (male ? setup.malenamePoolSelector : setup.namePoolSelector); const result = jsEither( (lookup[`${nationality}.${race}`] || lookup[nationality] || @@ -46,10 +45,9 @@ window.generateName = function generateName(nationality, race, male, filter) { * @param {string | number} nationality * @param {any} race * @param {any} male - * @param {() => true} filter + * @param {() => true} [filter] Default: allow all */ -window.generateSurname = function generateSurname(nationality, race, male, filter) { - filter = filter || _.stubTrue; /* default: allow all */ +window.generateSurname = function generateSurname(nationality, race, male, filter = _.stubTrue) { const result = jsEither( (setup.surnamePoolSelector[`${nationality}.${race}`] || setup.surnamePoolSelector[nationality] || diff --git a/src/js/slaveStatsChecker.js b/src/js/slaveStatsChecker.js index 3a225da8e2683093a5d319d4e5d2c07c571675f0..7387c92fcb6c743782c8ceb3cd8f67fdea3714ab 100644 --- a/src/js/slaveStatsChecker.js +++ b/src/js/slaveStatsChecker.js @@ -653,8 +653,7 @@ window.tooBigButt = function(slave) { * @param {App.Entity.SlaveState} slave * @returns {boolean} */ -window.isVegetable = function(slave) { - slave = slave || State.variables.activeSlave; +window.isVegetable = function(slave = State.variables.activeSlave) { if (!slave) { return false; } diff --git a/src/js/storyJS.js b/src/js/storyJS.js index 67b99d1ddffdc6fa9f47556ac4b07af6f275ec76..220445a952954c6116f98fb381e0a4161a2b8a92 100644 --- a/src/js/storyJS.js +++ b/src/js/storyJS.js @@ -363,12 +363,10 @@ window.lispReplace = function(text) { /** * @param {App.Entity.SlaveState} slave - * @param {Object} arcology // I think + * @param {Object} arcology * @returns {number} */ window.repGainSacrifice = function(slave, arcology) { - slave = slave || State.variables.activeSlave; - arcology = arcology || State.variables.arcologies[0]; if (!slave || !arcology || arcology.FSAztecRevivalist === "unset" || arcology.FSAztecRevivalist <= 0) { return 0; } @@ -432,11 +430,10 @@ window.toJson = function(obj) { }; /** - * @param {App.Entity.SlaveState} slave + * @param {App.Entity.SlaveState} [slave] * @returns {string} */ -window.nippleColor = function(slave) { - slave = slave || State.variables.activeSlave; +window.nippleColor = function(slave = State.variables.activeSlave) { if (skinToneLevel(slave.skin) < 8) { if (slave.preg > slave.pregData.normalBirth / 4 || (slave.counter.birthsTotal > 0 && slave.lactation > 0)) { return "brown"; diff --git a/src/societies/aztec/slaveSacrifice.tw b/src/societies/aztec/slaveSacrifice.tw index 34347e97a1f70bb6ea4dd6f5b46c19652d7bcadd..2de0d8319a3b09b09d6712dbb3fd872a8e103e73 100644 --- a/src/societies/aztec/slaveSacrifice.tw +++ b/src/societies/aztec/slaveSacrifice.tw @@ -4,7 +4,7 @@ <<setLocalPronouns $activeSlave >> <<run Enunciate($activeSlave)>> -<<set _activeSlaveRepSacrifice = repGainSacrifice()>> +<<set _activeSlaveRepSacrifice = repGainSacrifice($activeSlave, $arcologies[0])>> <<if $sacrificeType == "penance">> You inform $activeSlave.slaveName that $he's been chosen to take part in a ritual sacrifice to Xochiquetzal, the goddess of carnal love, excess, and sexual release. diff --git a/src/uncategorized/slaveInteract.tw b/src/uncategorized/slaveInteract.tw index 21a3df46373c57c6fbbde157d38b909fd34cc32a..49996fcea8270776ae969e577625788cc12e007a 100644 --- a/src/uncategorized/slaveInteract.tw +++ b/src/uncategorized/slaveInteract.tw @@ -391,7 +391,7 @@ <</if>> <</if>> <</if>> -<<set _activeSlaveRepSacrifice = repGainSacrifice()>> +<<set _activeSlaveRepSacrifice = repGainSacrifice($activeSlave, $arcologies[0])>> <<if _activeSlaveRepSacrifice > 0 && $arcologies[0].FSPaternalist == "unset" && ($activeSlave.breedingMark == 0 || $propOutcome == 0)>> | <<link "Sacrifice $him on the altar" "Aztec Slave Sacrifice">><<set $sacrificeType = "life">><</link>>//This will kill $him and gain you _activeSlaveRepSacrifice reputation// <</if>>