diff --git a/src/js/generateGenetics.js b/src/js/generateGenetics.js index 76ac32a5af613a8973055103f930db24936ddc98..98ab81f15c7f4c6123432e818ac86feb9061cba4 100644 --- a/src/js/generateGenetics.js +++ b/src/js/generateGenetics.js @@ -225,31 +225,13 @@ window.generateGenetics = (function() { 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); - return [ - 'pure white', - 'pure white', - 'extremely pale', - 'pale', - 'extremely fair', - 'very fair', - 'fair', - 'white', - 'light', - 'light olive', - 'olive', - 'natural', - 'tan', - 'tan', - 'bronze', - 'dark olive', - 'dark', - 'light brown', - 'brown', - 'dark brown', - 'ebony', - 'black', - 'pure black' - ][skinIndex]; + + var prop = ''; + for (prop in skinToMelanin) { + if (!skinToMelanin.hasOwnProperty(prop)) continue; + if (skinIndex >= skinToMelanin[prop]) return prop; + } + return prop; // skinIndex can be zero } // eyeColor