From 7c2908e8d9a06b613c54eed9c96b339cf01691a4 Mon Sep 17 00:00:00 2001
From: klorpa <30924131+klorpa@users.noreply.github.com>
Date: Tue, 17 Sep 2019 15:31:18 -0500
Subject: [PATCH] EyeStuff

---
 slave variables documentation - Pregmod.txt | 16 ----
 src/js/slaveStatsChecker.js                 | 97 +++++++++++++++++++++
 src/npc/databases/dSlavesDatabase.tw        |  2 +-
 src/pregmod/widgets/pregmodWidgets.tw       |  4 +-
 4 files changed, 100 insertions(+), 19 deletions(-)

diff --git a/slave variables documentation - Pregmod.txt b/slave variables documentation - Pregmod.txt
index b737cf777b3..5110e3aacc9 100644
--- a/slave variables documentation - Pregmod.txt	
+++ b/slave variables documentation - Pregmod.txt	
@@ -3795,22 +3795,6 @@ are eyes missing?
 2 - yes, right
 3 - yes, both
 
-missingArms:
-
-are arms missing?
-0 - none
-1 - yes, left
-2 - yes, right
-3 - yes, both
-
-missingLegs:
-
-are legs missing?
-0 - none
-1 - yes, left
-2 - yes, right
-3 - yes, both
-
 geneMods:
 
 	NCS:
diff --git a/src/js/slaveStatsChecker.js b/src/js/slaveStatsChecker.js
index 06f253d191d..713c427c770 100644
--- a/src/js/slaveStatsChecker.js
+++ b/src/js/slaveStatsChecker.js
@@ -1266,3 +1266,100 @@ window.armsAndLegs = function(slave, arms = "arms", arm = "arm", legs = "legs",
 window.isProstheticAvailable = function(slave, prosthetic) {
 	return slave.readyProsthetics.findIndex(function(p) { return p.id === prosthetic; }) !== -1;
 };
+
+/**
+ * True if slave has at least one eye
+ *
+ * @param {App.Entity.SlaveState} slave
+ * @returns {boolean}
+ */
+window.hasAnyEyes = function(slave) {
+	return !!slave.eye.right || !!slave.eye.left;
+};
+
+/**
+ * True if slave has at least one eye that is natural
+ *
+ * @param {App.Entity.SlaveState} slave
+ * @returns {boolean}
+ */
+window.hasAnyNaturalEyes = function(slave) {
+	return getLeftEyeID(slave) === 1 || getRightEyeID(slave) === 1;
+};
+
+/**
+ * True if slave has at least one eye that is prosthetic
+ *
+ * @param {App.Entity.SlaveState} slave
+ * @returns {boolean}
+ */
+window.hasAnyProstheticEyes = function(slave) {
+	return getLeftEyeID(slave) > 1 || getRightEyeID(slave) > 1;
+};
+
+/**
+ * True if slave has both eyes
+ *
+ * @param {App.Entity.SlaveState} slave
+ * @returns {boolean}
+ */
+window.hasBothEyes = function(slave) {
+	return !!slave.eye.right && !!slave.eye.left;
+};
+
+/**
+ * True if slave has both eyes and they are natural
+ *
+ * @param {App.Entity.SlaveState} slave
+ * @returns {boolean}
+ */
+window.hasBothNaturalEyes = function(slave) {
+	return getLeftEyeID(slave) === 1  && getRightEyeID(slave) === 1;
+};
+
+/**
+ * True if slave has left eye
+ *
+ * @param {App.Entity.SlaveState} slave
+ * @returns {boolean}
+ */
+window.hasLeftEye = function(slave) {
+	return !!slave.eye.left;
+};
+/**
+ * True if slave has right eye
+ *
+ * @param {App.Entity.SlaveState} slave
+ * @returns {boolean}
+ */
+window.hasRightEye = function(slave) {
+	return !!slave.eye.right;
+};
+
+/**
+ * Returns limb ID of the left eye. Uses new IDs.
+ *
+ * @param {App.Entity.SlaveState} slave
+ * @returns {number}
+ */
+window.getLeftEyeID = function(slave) {
+	if (hasLeftEye(slave)) {
+		return slave.eye.left.type;
+	} else {
+		return 0;
+	}
+};
+
+/**
+ * Returns limb ID of the right eye. Uses new IDs.
+ *
+ * @param {App.Entity.SlaveState} slave
+ * @returns {number}
+ */
+window.getRightEyeID = function(slave) {
+	if (hasRightEye(slave)) {
+		return slave.eye.right.type;
+	} else {
+		return 0;
+	}
+};
\ No newline at end of file
diff --git a/src/npc/databases/dSlavesDatabase.tw b/src/npc/databases/dSlavesDatabase.tw
index 8e0f675647d..079b4820d36 100644
--- a/src/npc/databases/dSlavesDatabase.tw
+++ b/src/npc/databases/dSlavesDatabase.tw
@@ -213,7 +213,7 @@
 /*Added combat skill, increased health, added origin -BoneyM*/
 
 <<set _HS = App.Entity.SlaveState.makeSkeleton()>>
-<<set _HS.slaveName = "Vivienne", _HS.birthName = "Vivienne", _HS.origin = "$He is a former soldier who was sold into slavery after losing $his leg to an IED.", _HS.ID = _i++, _HS.birthWeek = random(0,51), _HS.actualAge = 39, _HS.physicalAge = 39, _HS.visualAge = 39, _HS.ovaryAge = 39, _HS.health = 20, _HS.devotion = 90, _HS.race = "white", _HS.eyeColor = "green", _HS.hColor = "red", _HS.pubicHColor = "red", _HS.skin = "white", _HS.hStyle = "long", _HS.boobs = 400, _HS.butt = 3, _HS.vagina = 1, _HS.vaginaLube = 1, _HS.anus = 1, _HS.skill.vaginal = 15, _HS.skill.oral = 15, _HS.skill.anal = 15, _HS.skill.combat = 1, _HS.intelligence = 25, _HS.intelligenceImplant = 30, _HS.attrXY = 1, _HS.fetishKnown = 1, _HS.backTat = "$He has a military tattoo on $his back.", _HS.custom.desc = "$His left leg is artificial, and $he has a number of scars on $his thigh and shoulder and a burn near $his temple.", _HS.career = "a soldier">>
+<<set _HS.slaveName = "Vivienne", _HS.birthName = "Vivienne", _HS.origin = "$He is a former soldier who was sold into slavery after losing $his leg to an IED.", _HS.ID = _i++, _HS.birthWeek = random(0,51), _HS.actualAge = 39, _HS.physicalAge = 39, _HS.visualAge = 39, _HS.ovaryAge = 39, _HS.health = 20, _HS.devotion = 90, _HS.race = "white", _HS.eyeColor = "green", _HS.hColor = "red", _HS.pubicHColor = "red", _HS.skin = "white", _HS.hStyle = "long", _HS.boobs = 400, _HS.butt = 3, _HS.vagina = 1, _HS.vaginaLube = 1, _HS.anus = 1, _HS.skill.vaginal = 15, _HS.skill.oral = 15, _HS.skill.anal = 15, _HS.skill.combat = 1, _HS.intelligence = 25, _HS.intelligenceImplant = 30, _HS.attrXY = 1, _HS.fetishKnown = 1, _HS.backTat = "$He has a military tattoo on $his back.", _HS.custom.desc = "$His left leg is artificial, and $he has a number of scars on $his thigh and shoulder and a burn near $his temple.", _HS.career = "a soldier", _HS.leg.left.type = 2>>
 <<set $heroSlaves.push(_HS)>>
 /*missing left leg, burn scar, low sex drive, fighter*/
 /*Added customdesc, fixed tattoo syntax, added combat skill, eye color and origin -BoneyM*/
diff --git a/src/pregmod/widgets/pregmodWidgets.tw b/src/pregmod/widgets/pregmodWidgets.tw
index 4d112836bd7..fcc2350921c 100644
--- a/src/pregmod/widgets/pregmodWidgets.tw
+++ b/src/pregmod/widgets/pregmodWidgets.tw
@@ -537,7 +537,7 @@
 		<<set $args[0].arm = {left: null, right: null}>>
 		<<set $args[0].leg = {left: null, right: null}>>
 	<<else>>
-		<<set _newID = ($args[0].amp * -1) +1>>
+		<<set _newID = ($args[0].amp * -1) + 1>>
 		<<set $args[0].arm = {
 			left: new App.Entity.LimbState(),
 			right: new App.Entity.LimbState()
@@ -547,7 +547,7 @@
 			right: new App.Entity.LimbState()
 		}>>
 		<<set $args[0].arm.left.type = _newID, $args[0].arm.right.type = _newID, $args[0].leg.left.type = _newID, $args[0].leg.right.type = _newID>>
-		/* no need to check partial amputation, since it is not possible to create proir to this */
+		/* no need to check partial amputation, since it is not possible to create prior to this */
 	<</if>>
 	<<run delete $args[0].amp>>
 	<<run delete $args[0].missingLegs>>
-- 
GitLab