diff --git a/src/js/generateGenetics.js b/src/js/generateGenetics.js index dd429417f44902f79494a973e8d90371d6283ac3..cc979783579901b24eb889397fc990a1d8e850c8 100644 --- a/src/js/generateGenetics.js +++ b/src/js/generateGenetics.js @@ -110,7 +110,7 @@ window.generateGenetics = (function() { // name function setName(x) { - return "ovum" + x; + return `ovum${x}`; } // motherID @@ -123,10 +123,10 @@ window.generateGenetics = (function() { let motherName; if (activeMother.ID === -1) { motherName = activeMother.name; - if (activeMother.surname !== 0 && activeMother.surname !== "") { motherName += " " + activeMother.surname; } + if (activeMother.surname !== 0 && activeMother.surname !== "") { motherName += ` ${activeMother.surname}`; } } else { motherName = activeMother.slaveName; - if (activeMother.slaveSurname !== 0 && activeMother.slaveSurname !== "") { motherName += " " + activeMother.slaveSurname; } + if (activeMother.slaveSurname !== 0 && activeMother.slaveSurname !== "") { motherName += ` ${activeMother.slaveSurname}`; } } return motherName; } @@ -142,13 +142,13 @@ window.generateGenetics = (function() { if (father !== 0) { if (father.ID === -1) { fatherName = activeFather.name; - if (activeFather.surname !== 0 && activeFather.surname !== "") { fatherName += " " + activeFather.surname; } + if (activeFather.surname !== 0 && activeFather.surname !== "") { fatherName += ` ${activeFather.surname}`; } } else { fatherName = activeFather.slaveName; - if (activeFather.slaveSurname !== 0 && activeFather.slaveSurname !== "") { fatherName += " " + activeFather.slaveSurname; } + if (activeFather.slaveSurname !== 0 && activeFather.slaveSurname !== "") { fatherName += ` ${activeFather.slaveSurname}`; } } } else { - switch(actor2) { + switch (actor2) { case -2: case -5: fatherName = "Citizen"; @@ -187,13 +187,13 @@ window.generateGenetics = (function() { let race; if (father !== 0) { race = (mother.origRace === father.origRace) ? mother.origRace - : (jsRandom(1,4)) === 4 ? jsEither([father.origRace, mother.origRace]) + : (jsRandom(1, 4)) === 4 ? jsEither([father.origRace, mother.origRace]) : "mixed race"; } else if (actor2 === -2 || actor2 === -5) { if (V.arcologies[0].FSSupremacist !== "unset") { race = jsEither([mother.origRace, V.arcologies[0].FSSupremacistRace, V.arcologies[0].FSSupremacistRace]); if (mother.origRace !== V.arcologies[0].FSSupremacistRace) { - if (jsRandom(1,100) > 50) { + if (jsRandom(1, 100) > 50) { race = "mixed race"; } } @@ -209,32 +209,32 @@ window.generateGenetics = (function() { //skin function setSkin(father, mother) { let skinToMelanin = { - 'pure black': 21, - ebony: 20, - black: 19, - 'dark brown': 18, - brown: 17, - 'light brown': 16, - dark: 15, - 'dark olive': 14, - bronze: 13, - tan: 11, - olive: 10, - 'light olive': 9, - light: 8, - white: 7, - fair: 6, - 'very fair': 5, - 'extremely fair': 4, - pale: 3, - 'extremely pale': 2, - 'pure white': 1 + "pure black": 21, + "ebony": 20, + "black": 19, + "dark brown": 18, + "brown": 17, + "light brown": 16, + "dark": 15, + "dark olive": 14, + "bronze": 13, + "tan": 11, + "olive": 10, + "light olive": 9, + "light": 8, + "white": 7, + "fair": 6, + "very fair": 5, + "extremely fair": 4, + "pale": 3, + "extremely pale": 2, + "pure white": 1 }; let momSkinIndex = mother ? (skinToMelanin[mother.origSkin] || 11) : 8; let dadSkinIndex = father !== 0 ? (skinToMelanin[father.origSkin] || 11) : 8; let skinIndex = Math.round(Math.random() * (dadSkinIndex - momSkinIndex) + momSkinIndex); - var prop = ''; + let prop = ""; for (prop in skinToMelanin) { if (!skinToMelanin.hasOwnProperty(prop)) continue; if (skinIndex >= skinToMelanin[prop]) return prop; @@ -253,13 +253,13 @@ window.generateGenetics = (function() { } else if (father.origEye === "red" || father.origEye === "pale red" || father.origEye === "light red" || father.origEye === "pale gray" || father.origEye === "milky white") { eyeColor = mother.origEye; } else if (mother.origEye === "blue") { - if (jsRandom(1,4) === 2) { + if (jsRandom(1, 4) === 2) { eyeColor = mother.origEye; } else { eyeColor = father.origEye; } } else if (father.origEye === "blue") { - if (jsRandom(1,4) === 2) { + if (jsRandom(1, 4) === 2) { eyeColor = father.origEye; } else { eyeColor = mother.origEye; @@ -328,9 +328,9 @@ window.generateGenetics = (function() { if (mother.origHColor === father.origHColor) { hairColor = mother.origHColor; } else if (mother.origHColor === "white") { - hairColor = jsRandom(1,100) === 69 ? mother.origHColor : father.origHColor; + hairColor = jsRandom(1, 100) === 69 ? mother.origHColor : father.origHColor; } else if (father.origHColor === "white") { - hairColor = jsRandom(1,100) === 69 ? father.origHColor : mother.origHColor; + hairColor = jsRandom(1, 100) === 69 ? father.origHColor : mother.origHColor; } else if (mother.origHColor === "black") { hairColor = jsEither([father.origHColor, mother.origHColor, mother.origHColor, mother.origHColor, mother.origHColor, mother.origHColor, mother.origHColor, mother.origHColor]); } else if (father.origHColor === "black") { @@ -357,12 +357,12 @@ window.generateGenetics = (function() { if (mother.underArmHStyle === "hairless" && father.underArmHStyle === "hairless") { hair = "hairless"; } else if (mother.underArmHStyle === "hairless" || father.underArmHStyle === "hairless") { - hair = (jsRandom(1,5) === 3) ? "hairless" : jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]); + hair = (jsRandom(1, 5) === 3) ? "hairless" : jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]); } else { hair = jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]); } } else if (mother.underArmHStyle === "hairless") { - hair = (jsRandom(1,5) === 3) ? "hairless" : jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]); + hair = (jsRandom(1, 5) === 3) ? "hairless" : jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]); } else { hair = jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]); } @@ -376,12 +376,12 @@ window.generateGenetics = (function() { if (mother.pubicHStyle === "hairless" && father.pubicHStyle === "hairless") { hair = "hairless"; } else if (mother.pubicHStyle === "hairless" || father.pubicHStyle === "hairless") { - hair = (jsRandom(1,5) === 3) ? "hairless" : jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]); + hair = (jsRandom(1, 5) === 3) ? "hairless" : jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]); } else { hair = jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]); } } else if (mother.pubicHStyle === "hairless") { - hair = (jsRandom(1,5) === 3) ? "hairless" : jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]); + hair = (jsRandom(1, 5) === 3) ? "hairless" : jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]); } else { hair = jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]); } @@ -391,7 +391,7 @@ window.generateGenetics = (function() { // markings function setMarkings(father, mother) { let markings; - if (jsRandom(1,8) === 1) { + if (jsRandom(1, 8) === 1) { markings = jsEither(["beauty mark", "birthmark"]); } else { markings = "none"; @@ -445,7 +445,7 @@ window.generateGenetics = (function() { let smarts; if (mother.ID === -1) { if (actor2 === -6) { - smarts = jsRandom(90,100); + smarts = jsRandom(90, 100); } else if (father !== 0) { if (father.intelligence < mother.intelligence) { smarts = jsRandom(father.intelligence, mother.intelligence); @@ -456,7 +456,7 @@ window.generateGenetics = (function() { smarts += 30; } } else { - smarts = jsRandom(50,100); + smarts = jsRandom(50, 100); } } else if (father !== 0) { if (father.intelligence < mother.intelligence) { @@ -465,7 +465,7 @@ window.generateGenetics = (function() { smarts = jsRandom(mother.intelligence, father.intelligence); } if (activeMother.breedingMark === 1 && smarts <= 50) { - smarts = jsRandom(60,100); + smarts = jsRandom(60, 100); } } else { smarts = mother.intelligence; @@ -473,17 +473,17 @@ window.generateGenetics = (function() { if (V.inbreeding === 1) { if (mother.ID !== -1) { if (father !== 0 && father.ID === -1 && activeMother.breedingMark !== 1) { - if (smarts >= -95 && jsRandom(1,100) < 40) { - smarts -= jsRandom(1,10); - if (smarts >= -95 && jsRandom(1,100) < 20) { - smarts -= jsRandom(1,5); + if (smarts >= -95 && jsRandom(1, 100) < 40) { + smarts -= jsRandom(1, 10); + if (smarts >= -95 && jsRandom(1, 100) < 20) { + smarts -= jsRandom(1, 5); } } } else { - if (smarts >= -95 && jsRandom(1,100) < 50) { - smarts -= jsRandom(1,15); - if (smarts >= -95 && jsRandom(1,100) < 30) { - smarts -= jsRandom(1,15); + if (smarts >= -95 && jsRandom(1, 100) < 50) { + smarts -= jsRandom(1, 15); + if (smarts >= -95 && jsRandom(1, 100) < 30) { + smarts -= jsRandom(1, 15); } } } @@ -503,7 +503,7 @@ window.generateGenetics = (function() { face = -100; } else if (mother.ID === -1) { if (actor2 === -6) { - face = jsRandom(90,100); + face = jsRandom(90, 100); } else if (father !== 0) { if (father.face < mother.face) { face = jsRandom(father.face, mother.face); @@ -511,10 +511,10 @@ window.generateGenetics = (function() { face = jsRandom(mother.face, father.face); } if (face <= 40) { - face += jsRandom(5,20); + face += jsRandom(5, 20); } } else { - face = jsRandom(20,100); + face = jsRandom(20, 100); } } else if (father !== 0) { if (father.face < mother.face) { @@ -523,7 +523,7 @@ window.generateGenetics = (function() { face = jsRandom(mother.face, father.face); } if (activeMother.breedingMark === 1 && face < 60) { - face = jsRandom(60,100); + face = jsRandom(60, 100); } } else { face = mother.face; @@ -531,14 +531,14 @@ window.generateGenetics = (function() { if (V.inbreeding === 1 && genes.pFace === 0 && genes.uFace === 0) { if (mother.ID !== -1) { if (father !== 0 && father.ID === -1 && activeMother.breedingMark !== 1) { - if (face > -100 && jsRandom(1,100) > 60) { - face -= jsRandom(2,20); + if (face > -100 && jsRandom(1, 100) > 60) { + face -= jsRandom(2, 20); } } else { - if (face > -100 && jsRandom(1,100) < 50) { - face -= jsRandom(1,15); - if (face >= -95 && jsRandom(1,100) < 30) { - face -= jsRandom(5,20); + if (face > -100 && jsRandom(1, 100) < 50) { + face -= jsRandom(1, 15); + if (face >= -95 && jsRandom(1, 100) < 30) { + face -= jsRandom(5, 20); } } } @@ -761,11 +761,9 @@ window.generateGenetics = (function() { } return generateGenetics; - })(); window.generateChild = function (mother, ova, destination) { - let V = State.variables; let genes = ova.genetics; //maybe just argument this? We'll see. let pregUpgrade = V.pregnancyMonitoringUpgrade; @@ -1032,9 +1030,7 @@ window.generateChild = function (mother, ova, destination) { child.nationality = "Ancient Chinese Revivalist"; } } - } else { - V.activeSlaveOneTimeMinAge = V.targetAge; V.activeSlaveOneTimeMaxAge = V.targetAge; V.one_time_age_overrides_pedo_mode = 1;