diff --git a/src/js/utilJS.js b/src/js/utilJS.js index 52f617f58e0ca5f48b91bf50207b73abe104ce91..c982c37540715160597d85ab232e440b3d2e0833 100644 --- a/src/js/utilJS.js +++ b/src/js/utilJS.js @@ -55,26 +55,26 @@ window.Height = (function() { 'use strict'; // Global configuration (for different game modes/options/types) - var minMult = -3.0; - var maxMult = 3.0; - var skew = 0.0; - var spread = 0.05; - var minHeight = 0; - var maxHeight = 999; + let minMult = -3.0; + let maxMult = 3.0; + let skew = 0.0; + let spread = 0.05; + let minHeight = 0; + let maxHeight = 999; // Configuration method for the above values const _config = function(conf) { - if(_.isUndefined(conf)) { + if (_.isUndefined(conf)) { return {limitMult: [minMult, maxMult], limitHeight: [minHeight, maxHeight], skew: skew, spread: spread}; } - if(_.isFinite(conf.skew)) { skew = Math.clamp(conf.skew, -1000, 1000); } - if(_.isFinite(conf.spread)) { spread = Math.clamp(conf.spread, 0.001, 0.5); } - if(_.isArray(conf.limitMult) && conf.limitMult.length === 2 && conf.limitMult[0] !== conf.limitMult[1] && + if (_.isFinite(conf.skew)) { skew = Math.clamp(conf.skew, -1000, 1000); } + if (_.isFinite(conf.spread)) { spread = Math.clamp(conf.spread, 0.001, 0.5); } + if (_.isArray(conf.limitMult) && conf.limitMult.length === 2 && conf.limitMult[0] !== conf.limitMult[1] && _.isFinite(conf.limitMult[0]) && _.isFinite(conf.limitMult[1])) { minMult = Math.min(conf.limitMult[0], conf.limitMult[1]); maxMult = Math.max(conf.limitMult[0], conf.limitMult[1]); } - if(_.isArray(conf.limitHeight) && conf.limitHeight.length === 2 && conf.limitHeight[0] !== conf.limitHeight[1] && + if (_.isArray(conf.limitHeight) && conf.limitHeight.length === 2 && conf.limitHeight[0] !== conf.limitHeight[1] && _.isFinite(conf.limitHeight[0]) && _.isFinite(conf.limitHeight[1])) { minHeight = Math.min(conf.limitHeight[0], conf.limitHeight[1]); maxHeight = Math.max(conf.limitHeight[0], conf.limitHeight[1]); @@ -108,7 +108,7 @@ window.Height = (function() { "Tajik": 157.33, "Tanzanian": 156.6, "Thai": 157.87, "Tibetan": 158.75, "Togolese": 158.30, "Tongan": 165.52, "Trinidadian": 160.64, "Tunisian": 160.35, "Turkish": 160.50, "Turkmen": 161.73, "Tuvaluan": 158.10, "Ugandan": 156.72, "Ukrainian": 166.34, "Uruguayan": 162.13, "Uzbek": 157.82, "Vatican": 162.5, "Venezuelan": 157.44, "Vietnamese": 153.59, "Vincentian": 160.70, "Yemeni": 153.97, "Zairian": 155.25, "Zambian": 155.82, "Zimbabwean": 158.22, - "": 159.65 // default + "": 159.65, // default }; const xyMeanHeight = { "Afghan": 165.26, "Albanian": 173.39, "Algerian": 170.07, "American.asian": 172.5, "American.black": 177.4, "American.latina": 172.5, "American.white": 178.2, "American": 177.13, @@ -134,7 +134,7 @@ window.Height = (function() { "Swedish": 179.74, "Swiss": 178.42, "Syrian": 170.43, "Taiwanese": 174.52, "Tajik": 171.26, "Tanzanian": 164.80, "Thai": 169.16, "Tibetan": 168.91, "Togolese": 168.33, "Tongan": 176.76, "Trinidadian": 173.74, "Tunisian": 173.95, "Turkish": 174.21, "Turkmen": 171.97, "Tuvaluan": 169.64, "Ugandan": 165.62, "Ukrainian": 178.46, "Uruguayan": 173.43, "Uzbek": 169.38, "Vatican": 176.5, "Venezuelan": 171.59, "Vietnamese": 164.45, "Vincentian": 172.78, "Yemeni": 159.89, "Zairian": 166.80, "Zambian": 166.52, "Zimbabwean": 168.59, - "": 171.42 // defaults + "": 171.42, // defaults }; // Helper method - table lookup for nationality/race combinations @@ -146,7 +146,7 @@ window.Height = (function() { // Reference: http://azzalini.stat.unipd.it/SN/faq-r.html const skewedGaussian = function(s) { let randoms = gaussianPair(); - if(s === 0) { + if (s === 0) { // Don't bother, return an unskewed normal distribution return randoms[0]; } @@ -158,7 +158,7 @@ window.Height = (function() { // Height multiplier generator; skewed gaussian according to global parameters const multGenerator = function() { let result = skewedGaussian(skew); - while(result < minMult || result > maxMult) { + while (result < minMult || result > maxMult) { result = skewedGaussian(skew); } return result; @@ -167,7 +167,7 @@ window.Height = (function() { // Helper method: Generate a height based on the mean one and limited according to config. const heightGenerator = function(mean) { let result = mean * (1 + multGenerator() * spread); - while(result < minHeight || result > maxHeight) { + while (result < minHeight || result > maxHeight) { result = mean * (1 + multGenerator() * spread); } return result; @@ -175,11 +175,11 @@ window.Height = (function() { // Helper method - apply age and genes to the adult height const applyAge = function(height, age, genes) { - if(!_.isFinite(age) || age < 2 || age >= 20) { + if (!_.isFinite(age) || age < 2 || age >= 20) { return height; } - let minHeight = 0, midHeight = 0, midAge = 15; - switch(genes) { + let minHeight = 0; let midHeight = 0; let midAge = 15; + switch (genes) { case 'XX': // female case 'XXX': // Triple X syndrome female minHeight = 85; @@ -204,7 +204,7 @@ window.Height = (function() { midAge = 14; break; } - if(age > midAge) { + if (age > midAge) { // end of puberty to 20 return interpolate(midAge, midHeight, 20, height, age); } else { @@ -214,12 +214,12 @@ window.Height = (function() { }; const _meanHeight = function(nationality, race, genes, age) { - if(_.isObject(nationality)) { + if (_.isObject(nationality)) { // We got called with a single slave as the argument return _meanHeight(nationality.nationality, nationality.race, nationality.genes, nationality.physicalAge + nationality.birthWeek / 52.0); } let result = 0; - switch(genes) { + switch (genes) { case 'XX': // female result = nationalityMeanHeight(xxMeanHeight, nationality, race); break; @@ -254,7 +254,7 @@ window.Height = (function() { const mean = _meanHeight(nationality, race, genes, age); // If we got called with a slave object and options, temporarily modify // our configuration. - if(_.isObject(nationality) && _.isObject(race)) { + if (_.isObject(nationality) && _.isObject(race)) { const currentConfig = _config(); _config(race); const result = heightGenerator(mean); @@ -265,7 +265,7 @@ window.Height = (function() { }; const _forAge = function(height, age, genes) { - if(_.isObject(age)) { + if (_.isObject(age)) { // We got called with a slave as a second argument return applyAge(height, age.physicalAge + age.birthWeek / 52.0, age.genes); } else { @@ -316,31 +316,31 @@ window.Intelligence = (function() { 'use strict'; // Global configuration (for different game modes/options/types) - var mean = 0; - var minMult = -3.0; - var maxMult = 3.0; - var skew = 0.0; - var spread = 45; - var minIntelligence = -101; - var maxIntelligence = 100; + let mean = 0; + let minMult = -3.0; + let maxMult = 3.0; + let skew = 0.0; + let spread = 45; + let minIntelligence = -101; + let maxIntelligence = 100; // Configuration method for the above values const _config = function(conf) { - if(_.isUndefined(conf)) { + if (_.isUndefined(conf)) { return {mean: mean, limitMult: [minMult, maxMult], limitIntelligence: [minIntelligence, maxIntelligence], skew: skew, spread: spread}; } - if(_.isFinite(conf.mean)) { mean = Math.clamp(conf.mean, -100, 100); } - if(_.isFinite(conf.skew)) { skew = Math.clamp(conf.skew, -1000, 1000); } - if(_.isFinite(conf.spread)) { spread = Math.clamp(conf.spread, 0.1, 100); } - if(_.isArray(conf.limitMult) && conf.limitMult.length === 2 && conf.limitMult[0] !== conf.limitMult[1] && + if (_.isFinite(conf.mean)) { mean = Math.clamp(conf.mean, -100, 100); } + if (_.isFinite(conf.skew)) { skew = Math.clamp(conf.skew, -1000, 1000); } + if (_.isFinite(conf.spread)) { spread = Math.clamp(conf.spread, 0.1, 100); } + if (_.isArray(conf.limitMult) && conf.limitMult.length === 2 && conf.limitMult[0] !== conf.limitMult[1] && _.isFinite(conf.limitMult[0]) && _.isFinite(conf.limitMult[1])) { minMult = Math.min(conf.limitMult[0], conf.limitMult[1]); maxMult = Math.max(conf.limitMult[0], conf.limitMult[1]); } - if(_.isArray(conf.limitIntelligence) && conf.limitIntelligence.length === 2 && conf.limitIntelligence[0] !== conf.limitIntelligence[1] && + if (_.isArray(conf.limitIntelligence) && conf.limitIntelligence.length === 2 && conf.limitIntelligence[0] !== conf.limitIntelligence[1] && _.isFinite(conf.limitIntelligence[0]) && _.isFinite(conf.limitIntelligence[1])) { - minIntelligence = Math.clamp(Math.min(conf.limitIntelligence[0], conf.limitIntelligence[1]),-101,100); - maxIntelligence = Math.clamp(Math.max(conf.limitIntelligence[0], conf.limitIntelligence[1]),-101,100); + minIntelligence = Math.clamp(Math.min(conf.limitIntelligence[0], conf.limitIntelligence[1]), -101, 100); + maxIntelligence = Math.clamp(Math.max(conf.limitIntelligence[0], conf.limitIntelligence[1]), -101, 100); } return {limitMult: [minMult, maxMult], limitIntelligence: [minIntelligence, maxIntelligence], skew: skew, spread: spread}; }; @@ -349,7 +349,7 @@ window.Intelligence = (function() { // Reference: http://azzalini.stat.unipd.it/SN/faq-r.html const skewedGaussian = function(s) { let randoms = gaussianPair(); - if(s === 0) { + if (s === 0) { // Don't bother, return an unskewed normal distribution return randoms[0]; } @@ -361,7 +361,7 @@ window.Intelligence = (function() { // Intelligence multiplier generator; skewed gaussian according to global parameters const multGenerator = function() { let result = skewedGaussian(skew); - while(result < minMult || result > maxMult) { + while (result < minMult || result > maxMult) { result = skewedGaussian(skew); } return result; @@ -370,21 +370,21 @@ window.Intelligence = (function() { // Helper method: Transform the values from multGenerator to have the appropriate mean and standard deviation. const intelligenceGenerator = function() { let result = multGenerator() * spread + mean; - while(result < minIntelligence || result > maxIntelligence) { + while (result < minIntelligence || result > maxIntelligence) { result = multGenerator() * spread + mean; } return Math.ceil(result); }; const _randomIntelligence = function(settings) { - if (settings) { - const currentConfig = _config(); - _config(settings); - const result = intelligenceGenerator(); - _config(currentConfig); - return result; - } - return intelligenceGenerator(); + if (settings) { + const currentConfig = _config(); + _config(settings); + const result = intelligenceGenerator(); + _config(currentConfig); + return result; + } + return intelligenceGenerator(); }; return { @@ -400,7 +400,7 @@ window.gaussianPair = function() { return [r * Math.cos(sigma), r * Math.sin(sigma)]; }; -if(!Array.prototype.findIndex) { +if (!Array.prototype.findIndex) { Array.prototype.findIndex = function(predicate) { if (this == null) { throw new TypeError('Array.prototype.find called on null or undefined'); @@ -408,12 +408,12 @@ if(!Array.prototype.findIndex) { if (typeof predicate !== 'function') { throw new TypeError('predicate must be a function'); } - var list = Object(this); - var length = list.length >>> 0; - var thisArg = arguments[1]; - var value; + let list = Object(this); + let length = list.length >>> 0; + let thisArg = arguments[1]; + let value; - for (var i = 0; i < length; i++) { + for (let i = 0; i < length; i++) { value = list[i]; if (predicate.call(thisArg, value, i, list)) { return i; @@ -463,24 +463,24 @@ window.Categorizer = function() { .sort(function(a, b) { return b[0] - a[0]; /* reverse sort */ }); }; window.Categorizer.prototype.cat = function(val, def) { - var result = def; - if(typeof val === 'number' && !isNaN(val)) { - var foundCat = this.cats.find(function(e) { return val >= e[0]; }); - if(foundCat) { + let result = def; + if (typeof val === 'number' && !isNaN(val)) { + let foundCat = this.cats.find(function(e) { return val >= e[0]; }); + if (foundCat) { result = foundCat[1]; } } // Record the value for the result's getter, if it is an object // and doesn't have the property yet - if(result === Object(result)) { + if (result === Object(result)) { result.value = val; } return result; }; window.commaNum = function(s) { - if(!s) { return 0; } - if(State.variables.formatNumbers !== 1) { return s; } + if (!s) { return 0; } + if (State.variables.formatNumbers !== 1) { return s; } return s.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }; @@ -491,8 +491,8 @@ window.cashFormat = function(s) { window.repFormat = function(s) { const V = State.variables; - /*if (!s) { s = 0; }*/ - if (V.cheatMode == 1 || V.debugMode == 1) { + /* if (!s) { s = 0; }*/ + if (V.cheatMode === 1 || V.debugMode === 1) { if (s > 0) { return `@@.green;${ commaNum(Math.round(s * 100) / 100) } rep@@`; } else if (s < 0) { @@ -502,7 +502,7 @@ window.repFormat = function(s) { } } else { /* In order to calculate just how much any one category matters so we can show a "fuzzy" symbolic value to the player, we need to know how "busy" reputation was this week. To calculate this, I ADD income to expenses. Why? 100 - 100 and 10000 - 10000 BOTH are 0, but a +50 event matters a lot more in the first case than the second. I exclude overflow from the calculation because it's not a "real" expense for our purposes, and divide by half just to make percentages a bit easier. */ - var weight = s/(((V.lastWeeksRepIncome.Total - V.lastWeeksRepExpenses.Total) + V.lastWeeksRepExpenses.overflow)/2); + let weight = s/(((V.lastWeeksRepIncome.Total - V.lastWeeksRepExpenses.Total) + V.lastWeeksRepExpenses.overflow)/2); if (weight > 0.60) { return `@@.green;+++++ rep@@`; } else if (weight > 0.45) { @@ -513,7 +513,7 @@ window.repFormat = function(s) { return `@@.green;++ rep@@`; } else if (weight > 0.0) { return `@@.green;+ rep@@`; - } else if (weight == 0) { + } else if (weight === 0) { return `0 rep`; } else if (weight < -0.60) { return `@@.red;----- rep@@`; @@ -526,20 +526,20 @@ window.repFormat = function(s) { } else if (weight < 0) { return `@@.red;- rep@@`; } - /*return weight;*/ + /* return weight;*/ } }; window.budgetLine = function(category, title) { - var income; - var expenses; - var profits; + let income; + let expenses; + let profits; if (passage() === "Rep Budget") { income = "$lastWeeksRepIncome"; expenses = "$lastWeeksRepExpenses"; profits = "$lastWeeksRepProfits"; - return`<<if ${income}.${category} || ${expenses}.${category}>><tr>\ + return `<<if ${income}.${category} || ${expenses}.${category}>><tr>\ <td>${title}</td>\ <td><<print repFormat(${income}.${category})>></td>\ <td><<print repFormat(${expenses}.${category})>></td>\ @@ -551,7 +551,7 @@ window.budgetLine = function(category, title) { expenses = "$lastWeeksCashExpenses"; profits = "$lastWeeksCashProfits"; - return`<<if ${income}.${category} || ${expenses}.${category}>><tr>\ + return `<<if ${income}.${category} || ${expenses}.${category}>><tr>\ <td>${title}</td>\ <td>\ <<if (${income}.${category}) > 0>>\ @@ -579,20 +579,19 @@ window.budgetLine = function(category, title) { </td>\ </tr><</if>>`; } - }; window.massFormat = function(s) { - if(!s) { s = 0; } - if(s >= 1000) { + if (!s) { s = 0; } + if (s >= 1000) { s = commaNum(Math.trunc(s / 1000)); - if(s !== 1) { + if (s !== 1) { return `${s} tons`; } else { return `${s} ton`; } } else { - return `${commaNum(s)} kg`; + return `${commaNum(s)} kg`; } }; @@ -608,7 +607,7 @@ window.numberWithCommas = function(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }; -window.numberToWords = function (x) { +window.numberToWords = function(x) { const V = State.variables; let max = V.showNumbersMax; @@ -617,19 +616,19 @@ window.numberToWords = function (x) { return "zero"; } - var ONE_TO_NINETEEN = [ + let ONE_TO_NINETEEN = [ "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", - "sixteen", "seventeen", "eighteen", "nineteen" + "sixteen", "seventeen", "eighteen", "nineteen", ]; - var TENS = [ + let TENS = [ "ten", "twenty", "thirty", "forty", "fifty", - "sixty", "seventy", "eighty", "ninety" + "sixty", "seventy", "eighty", "ninety", ]; - var SCALES = ["thousand", "million", "billion", "trillion"]; + let SCALES = ["thousand", "million", "billion", "trillion"]; // helper function for use with Array.filter function isTruthy(item) { @@ -638,7 +637,7 @@ window.numberToWords = function (x) { // convert a number into "chunks" of 0-999 function chunk(number) { - var thousands = []; + let thousands = []; while (number > 0) { thousands.push(number % 1000); @@ -650,7 +649,7 @@ window.numberToWords = function (x) { // translate a number from 1-999 into English function inEnglish(number) { - var thousands, hundreds, tens, ones, words = []; + let hundreds; let tens; let ones; let words = []; if (number < 20) { return ONE_TO_NINETEEN[number - 1]; // may be undefined @@ -676,7 +675,7 @@ window.numberToWords = function (x) { // append the word for a scale. Made for use with Array.map function appendScale(chunk, exp) { - var scale; + let scale; if (!chunk) { return null; } @@ -684,7 +683,7 @@ window.numberToWords = function (x) { return [chunk, scale].filter(isTruthy).join(" "); } - var string = chunk(x) + let string = chunk(x) .map(inEnglish) .map(appendScale) .filter(isTruthy) @@ -713,23 +712,23 @@ window.numberToWords = function (x) { } }; -window.jsRandom = function(min,max) { +window.jsRandom = function(min, max) { return Math.floor(Math.random()*(max-min+1)+min); }; -window.jsRandomMany = function (arr, count) { - var result = []; - var _tmp = arr.slice(); - for (var i = 0; i < count; i++) { - var index = Math.ceil(Math.random() * 10) % _tmp.length; +window.jsRandomMany = function(arr, count) { + let result = []; + let _tmp = arr.slice(); + for (let i = 0; i < count; i++) { + let index = Math.ceil(Math.random() * 10) % _tmp.length; result.push(_tmp.splice(index, 1)[0]); } return result; }; -//This function wants an array - which explains why it works like array.random(). Give it one or you'll face a NaN +// This function wants an array - which explains why it works like array.random(). Give it one or you'll face a NaN window.jsEither = function(choices) { - var index = Math.floor(Math.random() * choices.length); + let index = Math.floor(Math.random() * choices.length); return choices[index]; }; @@ -750,7 +749,7 @@ jQuery(document).trigger('categorizer.ready'); window.hashChoice = function hashChoice(obj) { let randint = Math.floor(Math.random()*hashSum(obj)); let ret; - Object.keys(obj).some(key => { + Object.keys(obj).some((key) => { if (randint < obj[key]) { ret = key; return true; @@ -764,18 +763,18 @@ window.hashChoice = function hashChoice(obj) { window.hashSum = function hashSum(obj) { let sum = 0; - Object.keys(obj).forEach(key => { sum += obj[key]; }); + Object.keys(obj).forEach((key) => { sum += obj[key]; }); return sum; }; window.arr2obj = function arr2obj(arr) { const obj = {}; - arr.forEach(item => { obj[item] = 1; }); + arr.forEach((item) => { obj[item] = 1; }); return obj; }; window.hashPush = function hashPush(obj, ...rest) { - rest.forEach(item => { + rest.forEach((item) => { if (obj[item] === undefined) obj[item] = 1; else obj[item] += 1; }); @@ -783,7 +782,7 @@ window.hashPush = function hashPush(obj, ...rest) { window.weightedArray2HashMap = function weightedArray2HashMap(arr) { const obj = {}; - arr.forEach(item => { + arr.forEach((item) => { if (obj[item] === undefined) obj[item] = 1; else obj[item] += 1; }); @@ -799,7 +798,7 @@ window.between = function between(a, low, high) { // generate a random, almost unique ID that is compliant (possibly) with RFC 4122 window.generateNewID = function generateNewID() { - let date = Date.now(); //high-precision timer + let date = Date.now(); // high-precision timer let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { let r = (date + Math.random()*16)%16 | 0; date = Math.floor(date/16); @@ -816,7 +815,7 @@ window.arraySwap = function arraySwap(array, a, b) { // circumvents sugarcube, allowing a plain HTML5 UI within it window.html5passage = function html5passage(passage_function) { - $(document).one(':passagedisplay', ev => { + $(document).one(':passagedisplay', (ev) => { const element = document.createElement("div"); element.classList.add("passage"); document.getElementById("passages").appendChild(element); @@ -825,7 +824,7 @@ window.html5passage = function html5passage(passage_function) { }); }; -//If you want to include a SugarCube passage in a JS function use this. The result must be printed using the <<print>> macro. passageTitle must be a string. +// If you want to include a SugarCube passage in a JS function use this. The result must be printed using the <<print>> macro. passageTitle must be a string. window.jsInclude = function(passageTitle) { if (Story.has(passageTitle)) return Story.get(passageTitle).processText(); @@ -837,7 +836,7 @@ window.capFirstChar = function capFirstChar(string) { return string.charAt(0).toUpperCase() + string.substr(1); }; -window.getSlaveDevotionClass = /** @param {App.Entity.SlaveState} slave */ function (slave) { +window.getSlaveDevotionClass = /** @param {App.Entity.SlaveState} slave */ function(slave) { if ((!slave) || (!State)) return undefined; if ('mindbroken' === slave.fetish) @@ -858,7 +857,7 @@ window.getSlaveDevotionClass = /** @param {App.Entity.SlaveState} slave */ funct return 'worshipful'; }; -window.getSlaveTrustClass = /** @param {App.Entity.SlaveState} slave */ function (slave) { +window.getSlaveTrustClass = /** @param {App.Entity.SlaveState} slave */ function(slave) { if ((!slave) || (!State)) return undefined; @@ -885,41 +884,41 @@ window.getSlaveTrustClass = /** @param {App.Entity.SlaveState} slave */ function } }; -//takes an integer e.g. $activeSlave.hLength, returns a string in the format 10 inches +// takes an integer e.g. $activeSlave.hLength, returns a string in the format 10 inches window.cmToInchString = function(s) { return Math.round(s/2.54) + (Math.round(s/2.54) === 1?" inch":" inches"); }; -//takes an integer e.g. $activeSlave.height, returns a string in the format 6'5" +// takes an integer e.g. $activeSlave.height, returns a string in the format 6'5" window.cmToFootInchString = function(s) { if (Math.round(s/2.54) < 12) return cmToInchString(s); return `${Math.trunc(Math.round(s/2.54)/12) }'${ Math.round(s/2.54)%12 }"`; }; -//takes a dick value e.g. $activeSlave.dick, returns a string in the format 6 inches +// takes a dick value e.g. $activeSlave.dick, returns a string in the format 6 inches window.dickToInchString = function(s) { return cmToInchString(dickToCM(s)); }; -//takes a dick value e.g. $activeSlave.dick, returns an int of the dick length in cm +// takes a dick value e.g. $activeSlave.dick, returns an int of the dick length in cm window.dickToCM = function(s) { return (s<9?s*5:(s===9?50:s*6)); }; -//takes a ball value e.g. $activeSlave.balls, returns a string in the format 3 inches +// takes a ball value e.g. $activeSlave.balls, returns a string in the format 3 inches window.ballsToInchString = function(s) { return cmToInchString(ballsToCM(s)); }; -//takes a ball value e.g. $activeSlave.balls, returns an int of the ball size in cm +// takes a ball value e.g. $activeSlave.balls, returns an int of the ball size in cm window.ballsToCM = function(s) { if (s < 2) return 0; return (s<10?(s-1)*2:s*2); }; -//takes a dick value e.g. $activeSlave.dick, returns a string in the format of either `20cm (8 inches)`, `8 inches`, or `20cm` +// takes a dick value e.g. $activeSlave.dick, returns a string in the format of either `20cm (8 inches)`, `8 inches`, or `20cm` window.dickToEitherUnit = function(s) { if (State.variables.showInches === 1) return `${dickToCM(s) }cm (${ dickToInchString(s) })`; @@ -928,7 +927,7 @@ window.dickToEitherUnit = function(s) { return `${dickToCM(s) }cm`; }; -//takes a ball value e.g. $activeSlave.balls, returns a string in the format of either `20cm (8 inches)`, `8 inches`, or `20cm` +// takes a ball value e.g. $activeSlave.balls, returns a string in the format of either `20cm (8 inches)`, `8 inches`, or `20cm` window.ballsToEitherUnit = function(s) { if (State.variables.showInches === 1) return `${ballsToCM(s) }cm (${ ballsToInchString(s) })`; @@ -937,7 +936,7 @@ window.ballsToEitherUnit = function(s) { return `${ballsToCM(s) }cm`; }; -//takes an int in centimeters e.g. $activeSlave.height, returns a string in the format of either `200cm (6'7")`, `6'7"`, or `200cm` +// takes an int in centimeters e.g. $activeSlave.height, returns a string in the format of either `200cm (6'7")`, `6'7"`, or `200cm` window.heightToEitherUnit = function(s) { if (State.variables.showInches === 1) return `${s }cm (${ cmToFootInchString(s) })`; @@ -946,7 +945,7 @@ window.heightToEitherUnit = function(s) { return `${s }cm`; }; -//takes an int in centimeters e.g. $activeSlave.hLength, returns a string in the format of either `30cm (12 inches)`, `12 inches`, or `30cm` +// takes an int in centimeters e.g. $activeSlave.hLength, returns a string in the format of either `30cm (12 inches)`, `12 inches`, or `30cm` window.lengthToEitherUnit = function(s) { if (State.variables.showInches === 1) return `${s }cm (${ cmToInchString(s) })`; @@ -960,7 +959,7 @@ window.ValidateFacilityDecoration = function ValidateFacilityDecoration(decorati const V = State.variables; switch (V[decoration]) { case "standard": - /*nothing to do */ + /* nothing to do */ break; case "Supremacist": if (!Number.isFinite(V.arcologies[0].FSSupremacist)) { @@ -1091,7 +1090,7 @@ window.FSChange = function FSChange(FS, magnitude, bonus_multiplier) { case "Supremacist": if (Number.isFinite(V.arcologies[0].FSSupremacist)) { if (magnitude < 0) { - repX(magnitude * V.FSSingleSlaveRep * (V.arcologies[0].FSSupremacist / V.FSLockinLevel) / 3, "futureSocieties"); //Reducing the reputation impact of slaves that are not adhering to societal ideals properly + repX(magnitude * V.FSSingleSlaveRep * (V.arcologies[0].FSSupremacist / V.FSLockinLevel) / 3, "futureSocieties"); // Reducing the reputation impact of slaves that are not adhering to societal ideals properly } else { repX(magnitude * V.FSSingleSlaveRep * (V.arcologies[0].FSSupremacist / V.FSLockinLevel), "futureSocieties"); } @@ -1339,8 +1338,8 @@ window.FSChangePorn = function FSChangePorn(FS, magnitude) { }; window.ordinalSuffix = function ordinalSuffix(i) { - var j = i % 10, - k = i % 100; + let j = i % 10; + let k = i % 100; if (j === 1 && k !== 11) { return `${i }st`; } @@ -1362,7 +1361,7 @@ window.induceLactation = /** @param {App.Entity.SlaveState} slave */ function in let His = capFirstChar(pronouns.possessive); let r = ``; if (slave.induceLactation >= 10) { - if (jsRandom(1,100) < slave.induceLactation) { + if (jsRandom(1, 100) < slave.induceLactation) { r += `${His} breasts have been stimulated often enough to @@.lime;induce lactation.@@`; slave.induceLactation = 0; slave.lactationDuration = 2; @@ -1391,7 +1390,7 @@ window.ResearchLabStockPile = function() { Electrolarynx: $stockpile.electrolarynx`; }; -window.originPronounReplace = /** @param {App.Entity.SlaveState} slave */ function (slave) { +window.originPronounReplace = /** @param {App.Entity.SlaveState} slave */ function(slave) { let r = slave.origin; switch (r) { case "She was the result of unprotected sex with a client. Her mother tracked you down years after her birth to force her upon you.": @@ -1485,9 +1484,9 @@ window.HSM = function() { }; window.opentab = function(evt, tabName) { - var i, tabcontent, tablinks; + let i; let tabcontent; let tablinks; const V = State.variables; - /*var passage = passage().trim().replace(/ /g,"+");*/ + /* var passage = passage().trim().replace(/ /g,"+");*/ tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; @@ -1496,7 +1495,7 @@ window.opentab = function(evt, tabName) { for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } - V.tabChoice[passage().trim().replace(/ |'/g,"")] = tabName; /*The regex strips spaces and " ' " from passage names, making "Servants' Quarters" into "ServantsQuarters" and allowing it to be used as a label in this object. */ + V.tabChoice[passage().trim().replace(/ |'/g, "")] = tabName; /* The regex strips spaces and " ' " from passage names, making "Servants' Quarters" into "ServantsQuarters" and allowing it to be used as a label in this object. */ document.getElementById(tabName).style.display = "block"; evt.currentTarget.className += " active"; }; @@ -1517,7 +1516,7 @@ window.opentab = function(evt, tabName) { * // equal to [[Go to town|Town]] * App.UI.passageLink("Go to town", "Town") */ -App.UI.passageLink = function (linkText, passage, setter, elementType) { +App.UI.passageLink = function(linkText, passage, setter, elementType) { if (!elementType) elementType = 'a'; let res = `<${elementType} data-passage="${passage}"`;