diff --git a/src/npc/generate/generateGenetics.js b/src/npc/generate/generateGenetics.js index 77907e6ff5edfddda6a1e69b24dd488cd18afe24..7a6ded3d5355d025464542a303c3f7ddebab5b76 100644 --- a/src/npc/generate/generateGenetics.js +++ b/src/npc/generate/generateGenetics.js @@ -323,6 +323,23 @@ globalThis.generateGenetics = (function() { return prop; // skinIndex can be zero - now false? } + /** Make sure a given eye color is a valid genetic eye color and not the result of some modification. + * @param {string} eyeColor + * @returns {string} + */ + function validGeneticEyeColor(eyeColor) { + switch (eyeColor) { + case "blind blue": + eyeColor = "deep blue"; + break; + case "milky white": + case "implant": + eyeColor = jsEither(["blue", "brown", "dark blue", "dark green", "green", "hazel", "light blue", "light green"]); + break; + } + return eyeColor; + } + // eyeColor function setEyeColor(father, mother, actor2) { let eyeColor; @@ -393,17 +410,7 @@ globalThis.generateGenetics = (function() { eyeColor = mother.eye.origColor; } } - // just in case something wrong gets through - switch (eyeColor) { - case "blind blue": - eyeColor = "deep blue"; - break; - case "milky white": - case "implant": - eyeColor = jsEither(["blue", "brown", "dark blue", "dark green", "green", "hazel", "light blue", "light green"]); - break; - } - return eyeColor; + return validGeneticEyeColor(eyeColor); } function setHeterochromaticEyeColor(father, mother, actor2) { @@ -431,18 +438,7 @@ globalThis.generateGenetics = (function() { if (mother.geneticQuirks.heterochromia !== 0 && mother.geneticQuirks.heterochromia !== 1) { eyeColorArray.push(mother.geneticQuirks.heterochromia); } - let hEyeColor = jsEither(eyeColorArray); - // just in case something wrong gets through - switch (hEyeColor) { - case "blind blue": - hEyeColor = "deep blue"; - break; - case "milky white": - case "implant": - hEyeColor = jsEither(["blue", "brown", "dark blue", "dark green", "green", "hazel", "light blue", "light green"]); - break; - } - return hEyeColor; + return validGeneticEyeColor(jsEither(eyeColorArray)); } // hColor