diff --git a/src/js/surgery.js b/src/js/surgery.js index 7452584fb984b8c43262d206229f2c695fa466f8..2a558641919564e33730768f7965f1d75c85565e 100644 --- a/src/js/surgery.js +++ b/src/js/surgery.js @@ -583,6 +583,63 @@ window.eyeSurgery = function(slave, side, action) { } }; +/** + * To be used during slave generation or slave styling (auto salon) + * + * @param {App.Entity.SlaveState} slave + * @param {string} color to set eye to + * @param {string} [side] "left", "right", "both" + */ +window.setEyeColor = function setEyeColor(slave, color, side = "both") { + if (side === "both") { + setEyeColor(slave, color, "left"); + setEyeColor(slave, color, "right"); + return; + } + + if (side !== "left" && side !== "right") { return; } + + slave.eye[side].iris = color; + +}; + +/** + * Set genetic eye color + * + * @param {App.Entity.SlaveState} slave + * @param {string} color + * @param {boolean} heterochroma + */ +window.setGeneticEyeColor = function(slave, color, heterochroma = false) { + if (heterochroma) { + slave.geneticQuirks.heterochromia = color; + } else { + slave.eye.origColor = color; + } +}; + +/** + * Sets the eye color to the genetic color + * + * @param {App.Entity.SlaveState} slave + * @param {string} side + */ +window.resetEyeColor = function(slave, side) { + if (side === "both") { + resetEyeColor(slave, "left"); + resetEyeColor(slave, "right"); + return; + } + + if (side !== "left" && side !== "right") { return; } + + if (side === "left" && hasVisibleHeterochromia(slave)) { + slave.eye[side].iris = slave.geneticQuirks.heterochromia; + } else { + slave.eye[side].iris = slave.eye.origColor; + } +}; + /** * Allowed values for limb: * left arm, right arm, left leg, right leg, all