From 44f2762c78aa8662cde9c142040d6e9ae2a347f2 Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Sun, 5 Jul 2020 17:58:36 -0400
Subject: [PATCH] Hair implant surgery

---
 js/003-data/policiesData.js               |  4 +-
 src/npc/databases/customSlavesDatabase.tw |  9 +--
 src/npc/surgery/organs.js                 | 70 ++++++++++++++++++++-
 src/uncategorized/surgeryDegradation.tw   | 75 +++++++++++++++++++++++
 4 files changed, 147 insertions(+), 11 deletions(-)

diff --git a/js/003-data/policiesData.js b/js/003-data/policiesData.js
index ffa62aeff21..fa3258f5bd3 100644
--- a/js/003-data/policiesData.js
+++ b/js/003-data/policiesData.js
@@ -712,7 +712,7 @@ App.Data.Policies.Selection = {
 				title: "Physical Retirement Age",
 				get text() {
 					const el = new DocumentFragment;
-					el.append(`you will set your arcology's standard retirement age for sex slaves once their bodies reach age `);
+					el.append(`you will replace your arcology's standard age-based retirement policy for one retiring sex slaves once their bodies reach age `);
 					el.append(
 						App.UI.DOM.makeElement(
 							"div",
@@ -729,7 +729,7 @@ App.Data.Policies.Selection = {
 					);
 					return el;
 				},
-				get activatedText() { return `you have set your arcology's standard retirement age for sex slaves at ${V.retirementAge}.`; },
+				get activatedText() { return `you have set your arcology's standard retirement age for sex slaves at physically ${V.retirementAge}. This policy completely supplants former age retirement policies.`; },
 				onRepeal: function() { V.retirementAge = 45; }
 			}
 		],
diff --git a/src/npc/databases/customSlavesDatabase.tw b/src/npc/databases/customSlavesDatabase.tw
index 4c0e74f2491..95a3e4a020d 100644
--- a/src/npc/databases/customSlavesDatabase.tw
+++ b/src/npc/databases/customSlavesDatabase.tw
@@ -1,11 +1,4 @@
 :: custom Slaves Database
 
-<<set $heroSlaves = []>>
 <<set _i = 1000000>>
-/*
-<<set _HS = App.Entity.SlaveState.makeSkeleton()>>
-<<set _HS.slaveName = "McChesterton", _HS.birthName = "Testy", _HS.origin = "$He is obsessed with testing new customizations of $his body.", _HS.ID = _i++, _HS.birthWeek = random(0,51), _HS.actualAge = 24, _HS.physicalAge = 24, _HS.visualAge = 24, _HS.ovaryAge = 24, setHealth(_HS, 20), _HS.devotion = 100, _HS.weight = 25, _HS.origHColor = "chestnut", _HS.pubicHColor = "chestnut", _HS.hLength = 30, _HS.hStyle = "shoulder-length and in a bun", _HS.boobs = 700, _HS.butt = 3, _HS.vagina = 1, _HS.vaginaLube = 1, _HS.anus = 1, _HS.ovaries = 1, _HS.skill.vaginal = 15, _HS.skill.oral = 15, _HS.skill.anal = 15, _HS.skill.entertainment = 1, _HS.clothes = "a nice maid outfit", _HS.intelligence = 20, _HS.intelligenceImplant = 30, _HS.attrXY = 40, _HS.fetish = "submissive", _HS.career = "a maid", _HS.eyewear = "corrective glasses">>
-<<run eyeSurgery(_HS, "both", "blur")>>
-<<set $heroSlaves.push(_HS)>>
-
-/*To add custom slaves, try to use the format of the above example. Add new slaves below this line. If you wish to add more slaves later, always add them at the bottom of the file. IDs are assigned automatically and in order, and you want your new slave to have a unique ID instead of someone else's*/
\ No newline at end of file
+<<set $heroSlaves = []>>
diff --git a/src/npc/surgery/organs.js b/src/npc/surgery/organs.js
index 7c000bcade7..4861d11cc80 100644
--- a/src/npc/surgery/organs.js
+++ b/src/npc/surgery/organs.js
@@ -4,7 +4,7 @@
  *
  * @type {string[]}
  */
-App.Medicine.OrganFarm.organDisplayOrder = ["penis", "testicles", "scrotum", "pigTesticles", "dogTesticles", "horseTesticles", "cowTesticles", "foreskin", "prostate", "ovaries", "asexualReproOvaries", "pigOvaries", "dogOvaries", "horseOvaries", "cowOvaries", "freshOvaries", "leftEye", "rightEye", "ears", "topEars", "cochleae", "voicebox", "mpreg", "mpregPig", "mpregDog", "mpregHorse", "mpregCow"];
+App.Medicine.OrganFarm.organDisplayOrder = ["penis", "testicles", "scrotum", "pigTesticles", "dogTesticles", "horseTesticles", "cowTesticles", "foreskin", "prostate", "ovaries", "asexualReproOvaries", "pigOvaries", "dogOvaries", "horseOvaries", "cowOvaries", "freshOvaries", "leftEye", "rightEye", "ears", "topEars", "cochleae", "voicebox", "hair", "mpreg", "mpregPig", "mpregDog", "mpregHorse", "mpregCow"];
 
 App.Medicine.OrganFarm.init = function() {
 	new App.Medicine.OrganFarm.Organ({
@@ -385,4 +385,72 @@ App.Medicine.OrganFarm.init = function() {
 			})
 		]
 	});
+
+	new App.Medicine.OrganFarm.Organ({
+		type: "hair", name: "Hair Follicles", cost: 500, time: 2,
+		actions: [
+			new App.Medicine.OrganFarm.OrganImplantAction({
+				name: "Scalp", healthImpact: 10, surgeryType: "restoreHairHead",
+				canImplant: s => (s.bald),
+				implantError: () => "This slave already has hair.",
+				implant: s => {
+					s.bald = 0;
+					s.hLength = 1;
+					s.hair = "neat";
+					s.hColor = s.origHColor;
+				}
+			}),
+			/*
+			new App.Medicine.OrganFarm.OrganImplantAction({
+				name: "Ears", healthImpact: 5,
+				surgeryType: "addHairEarsH", autoImplant: false,
+				canImplant: s => (s.earShape !== "normal"),
+				implantError: s => getRightEyeVision(s) !== 0 ? "Slave has a working right eye." : "",
+				implant: s => {
+					s.earShape = "normal";
+				}
+			}),
+			new App.Medicine.OrganFarm.OrganImplantAction({
+				name: "Ears", healthImpact: 5,
+				surgeryType: "addHairEarsS", autoImplant: false,
+				canImplant: s => (s.earShape !== "normal"),
+				implantError: s => getRightEyeVision(s) !== 0 ? "Slave has a working right eye." : "",
+				implant: s => {
+					s.earShape = "normal";
+				}
+			}),
+			*/
+			new App.Medicine.OrganFarm.OrganImplantAction({
+				name: "Brow", healthImpact: 5,
+				surgeryType: "restoreHairBrow", autoImplant: false,
+				canImplant: s => (s.eyebrowHStyle === "bald"),
+				implantError: () => "This slave already has eyebrows.",
+				implant: s => {
+					s.eyebrowHStyle = "natural";
+					s.eyebrowFullness = "natural";
+					s.eyebrowHColor = s.origHColor;
+				}
+			}),
+			new App.Medicine.OrganFarm.OrganImplantAction({
+				name: "Axillary", healthImpact: 5,
+				surgeryType: "restoreHairPits", autoImplant: false,
+				canImplant: s => (s.underArmHStyle === "bald" || s.underArmHStyle === "hairless"),
+				implantError: () => "This slave already has underarm hair.",
+				implant: s => {
+					s.underArmHStyle = "bushy";
+					s.underArmHColor = s.origHColor;
+				}
+			}),
+			new App.Medicine.OrganFarm.OrganImplantAction({
+				name: "Pubic", healthImpact: 5,
+				surgeryType: "restoreHairPubes", autoImplant: false,
+				canImplant: s => (s.pubicHStyle === "bald" || s.pubicHStyle === "hairless"),
+				implantError: () => "This slave already has pubic hair.",
+				implant: s => {
+					s.pubicHStyle = "very bushy";
+					s.pubicHColor = s.origHColor;
+				}
+			})
+		]
+	});
 };
diff --git a/src/uncategorized/surgeryDegradation.tw b/src/uncategorized/surgeryDegradation.tw
index b05da6946cf..ea91b902be9 100644
--- a/src/uncategorized/surgeryDegradation.tw
+++ b/src/uncategorized/surgeryDegradation.tw
@@ -121,6 +121,8 @@ As the remote surgery's long recovery cycle completes,
 	your new Fuckdoll <<if (hasAnyLegs(getSlave($AS)))>>stumbles<<else>>is carried<</if>> out of the surgery room. The only <<if getSlave($AS).vagina > -1>>areas of skin visible are those around its vulva and anus<<else>>area of skin visible is that around its anus<</if>><<if getSlave($AS).lips > 95>>, though its lips are also visible as its facepussy makes the standard Fuckdoll mouth insert unnecessary<</if>>. You can see it starting to struggle against the constricting material of the Fuckdoll suit as the sedation wears off. Other than the tiny area of exposed skin and the slight movement, there's no indication that the sex doll in front of you is alive at all.
 <<elseif $surgeryType == "fuckdollExtraction">>
 	<<= getSlave($AS).slaveName>> <<if !hasAnyLegs(getSlave($AS))>>is carried<<elseif canWalk(getSlave($AS))>>walks<<else>>is escorted<</if>> out of the surgery room.
+<<elseif ["restoreHairHead", "restoreHairBrow", "restoreHairPits", "restoreHairPubes"].includes($surgeryType)>>
+	<<= getSlave($AS).slaveName>> begins to stir.
 <<else>>
 	<<= getSlave($AS).slaveName>> <<if !hasAnyLegs(getSlave($AS))>>is carried<<elseif canWalk(getSlave($AS))>>walks<<else>>is escorted<</if>> out of the surgery room<<if canSee(getSlave($AS))>> and catches sight of $himself in the floor-length mirror outside the door<<else>> and is detailed the modifications done to $his body, assuming $he hasn't already realized them<</if>>.
 <</if>>
@@ -2636,6 +2638,79 @@ As the remote surgery's long recovery cycle completes,
 	<</if>>
 	<br><br>As this was a non-invasive procedure, $his health was not affected.
 
+<<case "restoreHairHead" "restoreHairBrow" "restoreHairPits" "restoreHairPubes">>
+	$He awakens from surgery to an unfamiliar, rather irritating, itch
+	<<if $surgeryType == "restoreHairHead">>
+		coming from the top of $his head.
+	<<elseif $surgeryType == "restoreHairBrow">>
+		above $his eyes.
+	<<elseif $surgeryType == "restoreHairPits">>
+		<<if hasAnyArms(getSlave($AS))>>
+			under $his arm<<if hasBothArms(getSlave($AS))>>s<</if>>
+		<<else>>
+			below where $his arms used to be.
+		<</if>>
+	<<elseif $surgeryType == "restoreHairPubes">>
+		above $his crotch.
+	<</if>>
+	<<if hasAnyArms(getSlave($AS))>>
+		As $he reaches to scratch it, 
+	<<elseif canSee(getSlave($AS))>>
+		<<if $surgeryType != "restoreHairPubes">>
+			When $he investigates,
+		<<else>>
+			When $he looks in the mirror,
+		<</if>>
+	<<else>>
+		As $he struggles to rub it against something,
+	<</if>>
+	<<if $surgeryType == "restoreHairHead">>
+		<<if getSlave($AS).fetish != "mindbroken">>
+			$he is @@.hotpink;delighted@@ to find $he now has hair.
+			<<set getSlave($AS).devotion += 2>>
+		<<else>>
+			$he fails to realize $he now has a head of short hair.
+		<</if>>
+	<<elseif $surgeryType == "restoreHairBrow">>
+		<<if getSlave($AS).fetish != "mindbroken">>
+			$he is @@.hotpink;delighted@@ to find $he now has eyebrows.
+			<<set getSlave($AS).devotion += 2>>
+		<<else>>
+			$he fails to realize $he now has eyebrows.
+		<</if>>
+	<<elseif $surgeryType == "restoreHairPits">>
+		<<if getSlave($AS).fetish != "mindbroken">>
+			<<set _pubertyAge = Math.min(getSlave($AS).pubertyAgeXX, getSlave($AS).pubertyAgeXY)>>
+			<<if (getSlave($AS).physicalAge < _pubertyAge - 2)>>
+				$he finds nothing unusual; $his hair is still growing in.
+			<<elseif (getSlave($AS).physicalAge < _pubertyAge - 1)>>
+				$he is surprised to find a few new hairs.
+			<<elseif (getSlave($AS).physicalAge < _pubertyAge)>>
+				$he is surprised to find two patches of hair.
+			<<else>>
+				$he is shocked to find two dense patches of hair; a trip to the autosalon to manage it may be in order.
+			<</if>>
+		<<else>>
+			$he fails to realize $he now has underarm hair.
+		<</if>>
+	<<elseif $surgeryType == "restoreHairPubes">>
+		<<if getSlave($AS).fetish != "mindbroken">>
+			<<set _pubertyAge = Math.min(getSlave($AS).pubertyAgeXX, getSlave($AS).pubertyAgeXY)>>
+			<<if (getSlave($AS).physicalAge < _pubertyAge - 2)>>
+				$he finds nothing unusual; $his hair is still growing in.
+			<<elseif (getSlave($AS).physicalAge < _pubertyAge - 1)>>
+				$he is surprised to find a few new hairs.
+			<<elseif (getSlave($AS).physicalAge < _pubertyAge)>>
+				$he is surprised to find a patch of pubic hair.
+			<<else>>
+				$he is shocked to find a dense bush of hair trailing up to $his navel; a trip to the autosalon to style $his new pubes may be in order.
+			<</if>>
+		<<else>>
+			$he fails to realize $he now has pubic hair.
+		<</if>>
+	<</if>>
+	As with all surgery @@.red;$his health has been slightly affected.@@
+
 <<case "womb">>
 	It's not immediately apparent to $him what kind of surgery $he received, since all $he's left with is a terrible nonspecific ache in $his lower belly. As with all invasive surgery @@.red;$his health has been greatly affected.@@
 
-- 
GitLab