diff --git a/src/js/utilJS.js b/src/js/utilJS.js index 94932dfa7c52b781b92d72ce10fe6ff42a3d822c..5023d1952385d9337d8e258056c970fd538f0821 100644 --- a/src/js/utilJS.js +++ b/src/js/utilJS.js @@ -1,4 +1,3 @@ -/* eslint-disable no-unused-vars */ /* eslint-disable no-console */ /* eslint-disable no-undef */ /* @@ -479,21 +478,21 @@ window.Categorizer.prototype.cat = function(val, def) { window.num = function(x) { const V = State.variables; - let max = V.showNumbersMax; + const max = V.showNumbersMax; - var ONE_TO_NINETEEN = [ + const ONE_TO_NINETEEN = [ 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', ]; - var TENS = [ + const TENS = [ 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety', ]; - var SCALES = ['thousand', 'million', 'billion', 'trillion']; + const SCALES = ['thousand', 'million', 'billion', 'trillion']; // helper function for use with Array.filter function isTruthy(item) { @@ -502,7 +501,7 @@ window.num = function(x) { // convert a number into "chunks" of 0-999 function chunk(number) { - let thousands = []; + const thousands = []; while (number > 0) { thousands.push(number % 1000); @@ -517,7 +516,7 @@ window.num = function(x) { let hundreds; let tens; let ones; - let words = []; + const words = []; if (number < 20) { return ONE_TO_NINETEEN[number - 1]; // may be undefined @@ -601,7 +600,7 @@ window.cashFormat = function(s) { s = 0; } else { s = Math.trunc(s); - } + } if (s > 0) { return `¤${ num(s)}`; } else { @@ -667,7 +666,6 @@ window.massFormat = function (s) { }; window.budgetLine = function(category, title) { - const V = State.variables; // TODO: convert budgetLine references to JS let income; let expenses; let profits; @@ -913,7 +911,7 @@ window.cmToInchString = function(s) { } else { inches = 'less than an inch'; } - } else if (inches === 1){ + } else if (inches === 1) { inches += ' inch'; } else { inches += ' inches'; @@ -1156,15 +1154,14 @@ window.HackingSkillMultiplier = function() { }; window.opentab = function(evt, tabName) { - let i; let tabcontent; let tablinks; const V = State.variables; /* var passage = passage().trim().replace(/ /g,"+");*/ - tabcontent = document.getElementsByClassName('tabcontent'); - for (i = 0; i < tabcontent.length; i++) { + const tabcontent = document.getElementsByClassName('tabcontent'); + for (let i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = 'none'; } - tablinks = document.getElementsByClassName('tablinks'); - for (i = 0; i < tablinks.length; i++) { + const tablinks = document.getElementsByClassName('tablinks'); + for (let 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. */ @@ -1465,7 +1462,7 @@ window.randomCareer = function(slave) { } else { return setup.uneducatedCareers.random(); } -} +}; window.resyncSlaveToAge = function(slave) { slave.height = Height.random(slave); @@ -1506,7 +1503,7 @@ window.resyncSlaveToAge = function(slave) { } } slave.career = randomCareer(slave); -} +}; window.IncreasePCSkills = function(input, increase) { "use strict"; const player = State.variables.PC, oldSkill = player[input]; @@ -1531,37 +1528,26 @@ window.IncreasePCSkills = function(input, increase) { } }; -window.randomRaceSkin = function(raceName) -{ +window.randomRaceSkin = function(raceName) { let skin; switch (raceName) { case "asian": skin = jsEither(["dark olive", "light olive", "light"]); break; case "amerindian": + case "indo-aryan": + case "malay": + case "pacific islander": skin = jsEither(["dark", "light"]); break; case "black": skin = jsEither(["black", "brown", "dark brown"]); break; - case "indo-aryan": - skin = jsEither(["dark", "light"]); - break; case "latina": skin = jsEither(["brown", "dark brown", "dark olive", "light olive", "tanned"]); break; - case "malay": - skin = jsEither(["dark", "light"]); - break; case "middle eastern": - skin = jsEither(["fair", "light olive", "light", "tanned"]); - break; - case "pacific islander": - skin = jsEither(["dark", "light"]); - break; case "semitic": - skin = jsEither(["fair", "light olive", "light", "tanned"]); - break; case "southern european": skin = jsEither(["fair", "light olive", "light", "tanned"]); break; @@ -1575,40 +1561,23 @@ window.randomRaceSkin = function(raceName) return skin; }; -window.randomRaceEye = function(raceName) -{ +window.randomRaceEye = function(raceName) { let eye; switch (raceName) { case "asian": - eye = jsEither(["brown"]); - break; - case "amerindian": - eye = jsEither(["brown", "green"]); - break; case "black": - eye = jsEither(["brown",]); - break; case "indo-aryan": - eye = jsEither(["brown"]); - break; - case "latina": - eye = jsEither(["brown", "green"]); - break; - case "malay": - eye = jsEither(["blue", "brown", "green"]); - break; case "middle eastern": - eye = jsEither(["brown"]); - break; case "pacific islander": eye = jsEither(["brown"]); break; + case "amerindian": + case "latina": case "semitic": - eye = jsEither(["brown", "green"]); - break; case "southern european": eye = jsEither(["brown", "green"]); break; + case "malay": case "white": eye = jsEither(["blue", "brown", "green"]); break; @@ -1619,40 +1588,23 @@ window.randomRaceEye = function(raceName) return eye; }; -window.randomRaceHair = function(raceName) -{ +window.randomRaceHair = function(raceName) { let hair; switch (raceName) { case "asian": - hair = jsEither(["black"]); - break; case "amerindian": - hair = jsEither(["black"]); - break; - case "black": - hair = jsEither(["black", "black", "black", "brown"]); - break; case "indo-aryan": - hair = jsEither(["black"]); - break; - case "latina": - hair = jsEither(["black", "black", "brown", "brown"]); - break; case "malay": - hair = jsEither(["black"]); - break; case "middle eastern": - hair = jsEither(["black"]); - break; case "pacific islander": - hair = jsEither(["black"]); - break; case "semitic": - hair = jsEither(["black"]); - break; case "southern european": hair = jsEither(["black"]); break; + case "black": + case "latina": + hair = jsEither(["black", "black", "brown", "brown"]); + break; case "white": hair = jsEither(["black", "blonde", "brown", "red"]); break; @@ -1661,4 +1613,4 @@ window.randomRaceHair = function(raceName) break; } return hair; -}; \ No newline at end of file +};