code:
App.StartingGirls = {};

/** Generate a new slave for the starting girls passage
 * @returns {App.Entity.SlaveState}
 */
App.StartingGirls.generate = function(params) {
	let slave = GenerateNewSlave(null, params);
	setHealth(slave, 0);
	slave.devotion = 0;
	slave.trust = 0;
	slave.sexualQuirk = "none";
	slave.behavioralQuirk = "none";
	slave.fetishKnown = 1;
	slave.canRecruit = 0;
	slave.weekAcquired = 0;

	return slave;
};

/** Make sure user-entered values aren't crazy for starting girls
 * @param {App.Entity.SlaveState} slave
 */
App.StartingGirls.cleanup = function(slave) {
	slave.actualAge = Math.clamp(slave.actualAge, V.minimumSlaveAge, V.retirementAge-1) || 18;
	slave.physicalAge = slave.actualAge;
	slave.visualAge = slave.actualAge;
	slave.ovaryAge = slave.actualAge;
	slave.birthWeek = Math.clamp(slave.birthWeek, 0, 51) || 0;

	slave.devotion = Math.clamp(slave.devotion, -100, 100) || 0;
	slave.trust = Math.clamp(slave.trust, -100, 100) || 0;
	if (slave.indenture >= 0) {
		slave.indenture = Math.clamp(slave.indenture, 26, 208) || 26;
	}

	slave.height = Math.clamp(slave.height, 85, 274) || 140;
	slave.boobs = Math.clamp(Math.trunc(slave.boobs/50)*50, 0, 50000) || 200;
	slave.hLength = Math.clamp(slave.hLength, 0, 500) || 40;

	resetEyeColor(slave, "both");
	slave.origRace = slave.race;
	slave.skin = slave.origSkin;
	slave.hColor = slave.origHColor;
	slave.eyebrowHColor = slave.hColor;
	slave.pubicHColor = slave.hColor;
	slave.underArmHColor = slave.hColor;

	if (slave.balls === 0) {
		slave.scrotum = 0;
	}
	if (slave.vagina === -1) {
		slave.vaginaLube = 0;
	}
	if (slave.preg > 0) {
		if (slave.pregSource !== -1) {
			slave.pregSource = 0;
		}
	}
	if (slave.ovaries === 0) {
		slave.preg = 0;
		slave.pregType = 0;
		slave.pregSource = 0;
		slave.pregWeek = 0;
		slave.pregKnown = 0;
		slave.belly = 0;
		slave.bellyPreg = 0;
	}
	if (slave.analArea < slave.anus) {
		slave.analArea = slave.anus;
	}

	slave.father = Number(slave.father) || 0;
	slave.mother = Number(slave.mother) || 0;

	if (slave.counter.birthsTotal > 0) {
		if (slave.pubertyXX < 1) {
			slave.counter.birthsTotal = 0;
		}
		slave.counter.birthsTotal = Math.clamp(slave.counter.birthsTotal, 0, ((slave.actualAge-slave.pubertyAgeXX)*50));
	}
	if (slave.slaveName === "") {
		slave.slaveName = "Nameless";
	}
	if (slave.slaveSurname === "") {
		slave.slaveSurname = 0;
	}

	if ((slave.anus > 2 && slave.skill.anal <= 10) || (slave.anus === 0 && slave.skill.anal > 30)) {
		slave.skill.anal = 15;
	}
	if (slave.vagina < 0) {
		slave.skill.vaginal = 0;
	} else if ((slave.vagina > 2 && slave.skill.vaginal <= 10) || (slave.vagina === 0 && slave.skill.vaginal > 30)) {
		slave.skill.vaginal = 15;
	}
};

/** Apply starting girl PC career bonus
 * @param {App.Entity.SlaveState} slave
 */
App.StartingGirls.applyCareerBonus = function(slave) {
	function applySexSkillBonus() {
		let _seed = 2;
		if (slave.skill.oral < 60) {
			slave.skill.oral += 20;
			_seed--;
		}
		if ((slave.skill.anal < 60) && ((slave.anus > 0) || (slave.skill.anal <= 10))) {
			slave.skill.anal += 20;
			_seed--;
		}
		if ((_seed > 0) && (slave.skill.vaginal < 60) && (slave.vagina > -1) && ((slave.vagina > 0) || (slave.skill.vaginal <= 10))) {
			slave.skill.vaginal += 20;
		}
	}

	if (V.applyCareerBonus) {
		if (V.PC.career === "capitalist") {
			if (slave.skill.whoring < 60) {
				slave.skill.whoring += 20;
			}
		} else if (V.PC.career === "mercenary") {
			slave.trust += 10;
		} else if (V.PC.career === "slaver") {
			slave.devotion += 10;
		} else if (V.PC.career === "medicine") {
			slave.boobs += 600;
			slave.boobsImplant += 600;
			slave.boobsImplantType = "normal";
			slave.butt += 2;
			slave.buttImplant += 2;
			slave.buttImplantType = "normal";
			slave.lips += 10;
			slave.lipsImplant += 10;
			slave.waist = -55;
		} else if (V.PC.career === "celebrity") {
			if (slave.skill.entertainment < 60) {
				slave.skill.entertainment += 20;
			}
		} else if (V.PC.career === "servant") {
			slave.trust += 10;
			slave.devotion += 10;
		} else if (V.PC.career === "gang") {
			improveCondition(slave, 5);
			if (slave.skill.combat < 1) {
				slave.skill.combat += 1;
			}
		} else if (V.PC.career === "BlackHat") {
			slave.intelligence += 40;
			if (slave.intelligence > 100) {
				slave.intelligence = 100;
			}
		} else if (V.PC.career === "escort") {
			if (slave.skill.entertainment < 60) {
				slave.skill.entertainment += 20;
			}
			if (slave.skill.whoring < 60) {
				slave.skill.whoring += 20;
			}
			applySexSkillBonus();
		} else if (V.PC.career === "wealth") {
			applySexSkillBonus();
		} else {
			slave.devotion += 10;
			if (slave.skill.whoring < 60) {
				slave.skill.whoring += 20;
			}
			if (slave.skill.entertainment < 60) {
				slave.skill.entertainment += 20;
			}
			applySexSkillBonus();
		}
	}
};

/** Randomize things the player doesn't know about the slave
 * @param {App.Entity.SlaveState} slave
 */
App.StartingGirls.randomizeUnknowns = function(slave) {
	if (slave.attrKnown === 0) {
		slave.attrXX = random(0, 100);
		slave.attrXY = random(0, 100);
		slave.energy = random(1, 90);
	}
	if (slave.fetish !== "mindbroken" && slave.fetishKnown === 0) {
		slave.fetishStrength = random(0, 90);
		slave.fetish = either("boobs", "buttslut", "cumslut", "dom", "humiliation", "masochist", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "pregnancy", "sadist", "submissive");
	}
};

/** Generate a pipe-separated list of slaves with a given mother or father
 * @param {string} parent - "mother" or "father"
 * @param {number} id - parent's slave ID
 * @returns {string}
 */
App.StartingGirls.listOfSlavesWithParent = function(parent, id) {
	if (id === 0) {
		return "";
	}
	let slaveNames = [];
	if (V.PC[parent] === id) {
		slaveNames.push("You");
	}
	const slavesWithParent = V.slaves.filter((s) => s[parent] === id);
	slaveNames = slaveNames.concat(slavesWithParent.map((s) => s.slaveName));
	return slaveNames.join(" | ");
};

/** Render the family tree with an uncommitted slave
 * @param {App.Entity.SlaveState} slave
 */
App.StartingGirls.uncommittedFamilyTree = function(slave) {
	let tSlaves = V.slaves.concat([slave]); // returns a new array
	renderFamilyTree(tSlaves, slave.ID);
};

App.StartingGirls.career = function(slave) {
	let el = new DocumentFragment();
	let text;
	let pullDown;

	if (V.AgePenalty === 1) {
		if (slave.actualAge < 16) {
			text = "Very young careers: ";
			pullDown = render(setup.veryYoungCareers);
		} else if (slave.actualAge <= 24) {
			text = "Young careers: ";
			pullDown = render(setup.youngCareers);
		} else if (slave.intelligenceImplant >= 15) {
			text = "Educated careers: ";
			pullDown = render(setup.educatedCareers);
		} else {
			text = "Uneducated careers: ";
			pullDown = render(setup.uneducatedCareers);
		}
	} else {
		if (slave.actualAge < 16) {
			text = "Very young careers: ";
			pullDown = render(setup.veryYoungCareers);
		} else if (slave.intelligenceImplant >= 15) {
			text = "Educated careers: ";
			pullDown = render(setup.educatedCareers);
		} else if (slave.actualAge <= 24) {
			text = "Young careers: ";
			pullDown = render(setup.youngCareers);
		} else {
			text = "Uneducated careers: ";
			pullDown = render(setup.uneducatedCareers);
		}
	}
	function render(options) {
		let select = document.createElement("SELECT");
		select.classList.add("rajs-list");

		for(let i = 0; i < options.length; i++) {
			let opt = options[i];
			let el = document.createElement("option");
			el.textContent = capFirstChar(opt);
			el.value = opt;
			if (slave.career === opt) {
				el.selected = true;
			}
			select.appendChild(el);
		}
		select.onchange = () => {
			slave.career = select.options[select.selectedIndex].value;
			jQuery("#careerTextbox").empty().append(
				App.UI.DOM.makeTextBox(
					slave.career,
					v => {
						slave.career = v;
					},
					false,
				)
			);
		};

		return select;
	}
	el.append(text);
	el.append(pullDown);
	return el;
};


code:
:: Starting Girls [nobr]

	<<if $slaves.length == 0>>
		You're no stranger to the Free Cities, which means you're no stranger to slavery. If you wish, you can bring slaves from your past life with you to your arcology. You can spend your cash reserves on slaves here, or bring it with you to start the game. Slaves created here will be much cheaper than if they were purchased on the market.
		<<if ($PC.dick != 0) && ($PC.vagina != -1) && ($seeDicks != 0 || $makeDicks == 1)>>
			Since you have both a penis and a vagina yourself, you've obviously had access to a source of advanced surgery and organ farming. @@.springgreen;Slaves get a smaller cost increase here for having both penises and vaginas, and for having both testicles and ovaries.@@
		<</if>>
		<<if $PC.career == "slaver">>
			Since you personally saw to the capture, breaking and or training of these slaves, @@.springgreen;they cost half of what they normally would have here.@@
		<</if>>
	<</if>>

Current cash reserves can be found on the far left sidebar.
	<<if $slaves.length == 1>>

One slave is already committed.
	<<elseif $slaves.length > 1>>

$slaves.length slaves already committed.
	<</if>>

			<<link "Refresh" "Starting Girls">>	<</link>>

		| <<link "Randomize career" "Starting Girls">>
			<<set $activeSlave.career = randomCareer($activeSlave)>>
		<</link>>

		| <<link "Randomize name" "Starting Girls">>
			<<run nationalityToName($activeSlave)>>
			<<set $activeSlave.slaveName = $activeSlave.birthName>>
		<</link>>

		| <<link "Start over with a random slave" "Starting Girls">>
			<<set $activeSlave = App.StartingGirls.generate()>>
		<</link>>

		| <<link "Start over by selecting an archetype">>
			<<replace "#headerLinks">>

					Convenient combinations of slave attributes

					<<link "Irish Rose" "Starting Girls">>
						<<set $activeSlave = App.StartingGirls.generate({ nationality: "Irish", race: "white" })>>
						<<set $activeSlave.eye.origColor = "green", $activeSlave.origSkin = "fair", $activeSlave.origHColor = "red", $activeSlave.markings = "heavily freckled">>
					<</link>>

						A beautiful flower from the Emerald Isle

					<<link "Cali Girl" "Starting Girls">>
						<<set $activeSlave = App.StartingGirls.generate({ nationality: "American" })>>
						<<set $activeSlave.eye.origColor = "blue", $activeSlave.skin = "sun tanned", $activeSlave.override_Skin = 1, $activeSlave.origHColor = "blonde", $activeSlave.markings = "none", $activeSlave.face = 95, $activeSlave.muscles = 20, $activeSlave.weight = -20, $activeSlave.height = Math.round(Height.forAge(190, $activeSlave))>>
					<</link>>

						Tall, taut, and tan

					<<link "Novice" "Starting Girls">>
						<<set $activeSlave = App.StartingGirls.generate()>>
						<<set $activeSlave.skill.anal = 0, $activeSlave.skill.oral = 0, $activeSlave.skill.vaginal = 0, $activeSlave.skill.whoring = 0, $activeSlave.skill.entertainment = 0, $activeSlave.skill.combat = 0, $activeSlave.actualAge = 18, $activeSlave.visualAge = 18, $activeSlave.physicalAge = 18, $activeSlave.fetishKnown = 0, $activeSlave.attrKnown = 0>>
					<</link>>

						Train your own and save

					<<link "Head Girl Prospect" "Starting Girls">>
						<<set $activeSlave = App.StartingGirls.generate({ minAge: 36, maxAge: 44 })>>
						<<set $activeSlave.career = setup.HGCareers.random(), $activeSlave.intelligence = 70, $activeSlave.intelligenceImplant = 0>>
					<</link>>

						Inexpensive potential to become a great right hand woman

				<<if $seeExtreme != 0>>

						<<link "Wellspring" "Starting Girls">>
							<<set $activeSlave = App.StartingGirls.generate({ minAge: 18, maxAge: 18 })>>
							<<set $activeSlave.skill.anal = 0, $activeSlave.skill.oral = 0, $activeSlave.skill.vaginal = 0, $activeSlave.skill.whoring = 0, $activeSlave.skill.entertainment = 0, $activeSlave.skill.combat = 0, $activeSlave.fetishKnown = 0, $activeSlave.attrKnown = 0, $activeSlave.health.condition = 10, $activeSlave.intelligence = -100, $activeSlave.intelligenceImplant = 0, $activeSlave.vagina = 3, $activeSlave.anus = 3, $activeSlave.ovaries = 1, $activeSlave.dick = 5, $activeSlave.balls = 5, $activeSlave.prostate = 1, $activeSlave.lactation = 2, $activeSlave.lactationDuration = 2, $activeSlave.nipples = "huge", $activeSlave.boobs = 10000>>
						<</link>>

							Capable of producing all kinds of useful fluids

						<<link "Onahole" "Starting Girls">>
							<<set $activeSlave = App.StartingGirls.generate()>>
							<<set $activeSlave.skill.anal = 0, $activeSlave.skill.oral = 0, $activeSlave.skill.vaginal = 0, $activeSlave.skill.whoring = 0, $activeSlave.skill.entertainment = 0, $activeSlave.skill.combat = 0, $activeSlave.fetish = "mindbroken", $activeSlave.voice = 0, $activeSlave.hears = 0>>
							<<run removeLimbs($activeSlave, "all"), eyeSurgery($activeSlave, "both", "normal")>>
						<</link>>

							A living cocksleeve

				<</if>>

					<<link "Back" "Starting Girls">>	<</link>>

			<</replace>>
		<</link>>

		<<if !$showSGNationalities>>
			| <<link "Start over by selecting a nationality" "Starting Girls">>
				<<set $showSGNationalities = 1>>
			<</link>>
		<</if>>

		| [[Take control of your arcology|Acquisition]]

<<if $showSGNationalities>>

Start over by selecting a nationality:

			<<for _sg = 0; _sg < setup.baseNationalities.length; _sg++>>
				<<set _nation = setup.baseNationalities[_sg]>>
				<<capture _nation>>
				<<link _nation "Starting Girls">>
					<<set $activeSlave = App.StartingGirls.generate({ nationality: _nation })>>
				<</link>>
				<</capture>>
				<<if _sg < setup.baseNationalities.length-1>>
					|
				<</if>>
			<</for>>

			<<link "Hide" "Starting Girls">><<set $showSGNationalities = 0>><</link>>

<</if>>

<<run App.UI.tabbar.handlePreSelectedTab($tabChoice.startingGirls)>>

<<if !$activeSlave>>
	<<set $activeSlave = App.StartingGirls.generate()>>
<</if>>

<<run App.StartingGirls.cleanup($activeSlave)>>
<<set _slaveCost = startingSlaveCost($activeSlave)>>
<<set $saleDescription = 1>>

<<if $activeSlave.father == -1>>
	<<if $PC.dick == 0>>
		<<set $activeSlave.father = 0>>
	<<elseif ($PC.actualAge - $activeSlave.actualAge) < $minimumSlaveAge || (($PC.actualAge - $activeSlave.actualAge) < $potencyAge)>>
		<<set $activeSlave.father = 0>>
	<</if>>
	<<if $saveImported == 1>>
		<<set $activeSlave.father = 0>>
	<</if>>
<</if>>
<<if $activeSlave.mother == -1>>
	<<if $PC.vagina == -1>>
		<<set $activeSlave.mother = 0>>
	<<elseif (($PC.actualAge - $activeSlave.actualAge) < $minimumSlaveAge) || (($PC.actualAge - $activeSlave.actualAge) < $fertilityAge)>>
		<<set $activeSlave.mother = 0>>
	<</if>>
	<<if $saveImported == 1>>
		<<set $activeSlave.mother = 0>>
	<</if>>
<</if>>
/* this block makes starting girls actually apply the slave origins, mostly since it just hates you and everything you do */
<<if $originOveride == 0>>
	<<if $PC.career == "capitalist">>
		<<if $activeSlave.mother == -1 && $activeSlave.father == -1>>
			<<set $activeSlave.origin = "To solidify an investment in hermaphrodite self-fertility, you took part in a test successful test trial. Nine months later your $daughter was born.">>
			<<set $activeSlave.custom.tattoo = "$He has a famous corporate logo tattooed on the nape of $his neck.">>
		<<elseif $activeSlave.mother == -1>>
			<<set $activeSlave.origin = "Sometimes it pays off to use your body in business deals, and other times you end up burdened with child. $He is the result of the latter.">>
			<<set $activeSlave.custom.tattoo = "$He has a famous corporate logo tattooed on the nape of $his neck.">>
		<<elseif $activeSlave.father == -1>>
			<<set $activeSlave.origin = "To seal a business deal, a client asked you to knock her up. $He is the end result of that fling.">>
			<<set $activeSlave.custom.tattoo = "$He has a famous corporate logo tattooed on the nape of $his neck.">>
		<<else>>
			<<set $activeSlave.origin = "You acquired $him in the last stages of your career as a successful venture capitalist.">>
			<<set $activeSlave.custom.tattoo = "$He has a famous corporate logo tattooed on the nape of $his neck.">>
		<</if>>
	<<elseif $PC.career == "mercenary">>
		<<if $activeSlave.mother == -1 && $activeSlave.father == -1>>
			<<set $activeSlave.origin = "Drugs and alcohol can be a potent mix; the night that followed it can sometimes be hard to remember. Needless to say, once your belly began swelling with $him, you had to temporarily switch to a desk job for your mercenary group.">>
			<<set $activeSlave.custom.tattoo = "$He has a small tattoo of a private military company's coat of arms on the nape of $his neck.">>
		<<elseif $activeSlave.mother == -1>>
			<<set $activeSlave.origin = "Drugs and alcohol can be a potent mix; the night that followed it can sometimes be hard to remember. Needless to say, once your belly began swelling with $him, you had to temporarily switch to a desk job for your mercenary group.">>
			<<set $activeSlave.custom.tattoo = "$He has a small tattoo of a private military company's coat of arms on the nape of $his neck.">>
		<<elseif $activeSlave.father == -1>>
			<<set $activeSlave.origin = "A trip to a brothel after a mission resulted in an unexpected surprise years later.">>
			<<set $activeSlave.custom.tattoo = "$He has a small tattoo of a private military company's coat of arms on the nape of $his neck.">>
		<<else>>
			<<set $activeSlave.origin = "You acquired $him in the last stages of your career as a noted private military contractor.">>
			<<set $activeSlave.custom.tattoo = "$He has a small tattoo of a private military company's coat of arms on the nape of $his neck.">>
		<</if>>
	<<elseif $PC.career == "slaver">>
		<<if $activeSlave.mother == -1 && $activeSlave.father == -1>>
			<<set $activeSlave.origin = "You never thought you would be capable of impregnating yourself, but years of pleasuring yourself with yourself after missions managed to create $him.">>
			<<set $activeSlave.custom.tattoo = "$He has a small tattoo of a private military company's coat of arms on the nape of $his neck.">>
		<<elseif $activeSlave.mother == -1>>
			<<set $activeSlave.origin = "A fresh capture once overpowered you and had his way with you. You kept $him as a painful reminder to never lower your guard again.">>
			<<set $activeSlave.custom.tattoo = "$He has your tiny slaving emblem tattooed behind $his left ear.">>
		<<elseif $activeSlave.father == -1>>
			<<set $activeSlave.origin = "Your slaving troop kept several girls as fucktoys; you sired $him in your favorite.">>
			<<set $activeSlave.custom.tattoo = "$He has your tiny slaving emblem tattooed behind $his left ear.">>
		<<else>>
			<<set $activeSlave.origin = "You enslaved $him personally during the last stages of your slaving career.">>
			<<set $activeSlave.custom.tattoo = "$He has your tiny slaving emblem tattooed behind $his left ear.">>
		<</if>>
	<<elseif $PC.career == "engineer">>
		<<if $activeSlave.mother == -1 && $activeSlave.father == -1>>
			<<set $activeSlave.origin = "You sired $him in yourself after an arcology owner, impressed by your work, rewarded you with a night you'll never forget.">>
			<<set $activeSlave.custom.tattoo = "$He has the geometric symbol of your old arcology engineering firm laser tattooed into the nape of $his neck.">>
		<<elseif $activeSlave.mother == -1>>
			<<set $activeSlave.origin = "You conceived $him after a male arcology owner, impressed by your work, rewarded you with a night you'll never forget.">>
			<<set $activeSlave.custom.tattoo = "$He has the geometric symbol of your old arcology engineering firm laser tattooed into the nape of $his neck.">>
		<<elseif $activeSlave.father == -1>>
			<<set $activeSlave.origin = "You sired $him after a female arcology owner, impressed by your work, rewarded you with a night you'll never forget.">>
			<<set $activeSlave.custom.tattoo = "$He has the geometric symbol of your old arcology engineering firm laser tattooed into the nape of $his neck.">>
		<<else>>
			<<set $activeSlave.origin = "You received $him as a gift from an arcology owner impressed by your work.">>
			<<set $activeSlave.custom.tattoo = "$He has the geometric symbol of your old arcology engineering firm laser tattooed into the nape of $his neck.">>
		<</if>>
	<<elseif $PC.career == "escort">>
		<<if $activeSlave.mother == -1 && $activeSlave.father == -1>>
			<<set $activeSlave.origin = "A client paid you a large sum of credits to prove you could literally fuck yourself. $He is the result of that lucrative night.">>
			<<set $activeSlave.custom.tattoo = "$He has your custom emblem tattooed on $his left breast.">>
		<<elseif $activeSlave.mother == -1>>
			<<set $activeSlave.origin = "$He was the result of unprotected sex with a client. He paid you quite well to enjoy your body as you grew heavy with his child.">>
			<<set $activeSlave.custom.tattoo = "$He has the number of times $his father came in you while you were pregnant with $him tattooed down $his back.">>
		<<elseif $activeSlave.father == -1>>
			<<set $activeSlave.origin = "$He was the result of unprotected sex with a client. $His mother tracked you down years after $his birth to force $him upon you.">>
			<<set $activeSlave.custom.tattoo = "$He has your name angrily tattooed on $his right shoulder.">>
		<<else>>
			<<set $activeSlave.origin = "$He was a fellow escort you were popular with.">>
			<<set $activeSlave.custom.tattoo = "$He has your custom emblem tattooed on $his left breast. $He got the tattoo after starring in a porno with you.">>
		<</if>>
		<<if $activeSlave.preg > 0>>
			<<if $activeSlave.pregSource != -1>>
				<<set $activeSlave.pregSource = -5>>
			<</if>>
		<</if>>
	<<elseif $PC.career == "gang">>
		<<if $activeSlave.mother == -1 && $activeSlave.father == -1>>
			<<set $activeSlave.origin = "$He was the result of a night of hard drugs and unprotected sex after a big score. It took quite a bit of alcohol to come to terms with drunkenly knocking yourself up.">>
			<<set $activeSlave.custom.tattoo = "$He has your former gang's sign tattooed on $his neck.">>
		<<elseif $activeSlave.mother == -1>>
			<<set $activeSlave.origin = "$He was the result of a night of hard drugs and unprotected sex after a big score.">>
			<<set $activeSlave.custom.tattoo = "$He has your former gang's sign tattooed on $his neck.">>
		<<elseif $activeSlave.father == -1>>
			<<set $activeSlave.origin = "$He was born from one of your sex toys you knocked up.">>
			<<set $activeSlave.custom.tattoo = "$He has your former gang's sign tattooed on $his neck.">>
		<<else>>
			<<set $activeSlave.origin = "You captured $him during your transition to the arcology">>
			<<set $activeSlave.custom.tattoo = "$He has your former gang's sign tattooed on $his neck.">>
		<</if>>
	<<elseif $PC.career == "servant">>
		<<if $activeSlave.mother == -1 && $activeSlave.father == -1>>
			<<set $activeSlave.origin = "Your late Master took pleasure in using his servants in creative ways. He inseminated you with your own sperm, and nine months later, your $daughter was born.">>
			<<set $activeSlave.custom.tattoo = "$He has your Master's brand on $his left breast.">>
		<<elseif $activeSlave.mother == -1>>
			<<set $activeSlave.origin = "$He was another of your late Master's servants. $He spent nine months in your womb, courtesy of your Master.">>
			<<set $activeSlave.custom.tattoo = "$He has your Master's brand on $his left breast.">>
		<<elseif $activeSlave.father == -1>>
			<<set $activeSlave.origin = "$He was another of your late Master's servants. Your Master permitted you to knock up $his mother.">>
			<<set $activeSlave.custom.tattoo = "$He has your Master's brand on $his left breast.">>
		<<elseif $PC.vagina != -1>>
			<<set $activeSlave.origin = "$He was another of your late Master's servants. $He helped you give birth to his child.">>
			<<set $activeSlave.custom.tattoo = "$He has your Master's brand on $his left breast.">>
		<<else>>
			<<set $activeSlave.origin = "$He was another of your late Master's servants.">>
			<<set $activeSlave.custom.tattoo = "$He has your Master's brand on $his left breast.">>
		<</if>>
		<<if $activeSlave.preg > 0>>
			<<if $activeSlave.pregSource != -1>>
				<<set $activeSlave.pregSource = -3>>
			<</if>>
		<</if>>
	<<elseif $PC.career == "medicine">>
		<<if $activeSlave.mother == -1 && $activeSlave.father == -1>>
			<<set $activeSlave.origin = "$He was conceived after a successful experiment in hermaphrodite self-reproduction.">>
			<<set $activeSlave.custom.tattoo = "$He has your personal symbol tattooed on the back of $his neck: it's invisible to the naked eye, but shows up starkly on medical imaging.">>
		<<elseif $activeSlave.mother == -1>>
			<<set $activeSlave.origin = "$He was conceived after a botched birth control experiment early in your career.">>
			<<set $activeSlave.custom.tattoo = "$He has your personal symbol tattooed on the back of $his neck: it's invisible to the naked eye, but shows up starkly on medical imaging.">>
		<<elseif $activeSlave.father == -1>>
			<<set $activeSlave.origin = "$He is the product of an affair with a cute nurse who assisted you in more ways than one.">>
			<<set $activeSlave.custom.tattoo = "$He has your personal symbol tattooed on the back of $his neck: it's invisible to the naked eye, but shows up starkly on medical imaging.">>
		<<else>>
			<<set $activeSlave.origin = "You kept $him after $his owner failed to pay your bill for performing surgery on $him.">>
			<<set $activeSlave.custom.tattoo = "$He has your personal symbol tattooed on the back of $his neck: it's invisible to the naked eye, but shows up starkly on medical imaging.">>
		<</if>>
	<<elseif $PC.career == "celebrity">>
		<<if $activeSlave.mother == -1 && $activeSlave.father == -1>>
			<<set $activeSlave.origin = "$He was conceived after a night of partying and a drunken bet. $He nearly killed your career.">>
			<<set $activeSlave.custom.tattoo = "$He has your signature, surrounded by hearts, tattooed on the back of $his neck.">>
		<<elseif $activeSlave.mother == -1>>
			<<set $activeSlave.origin = "$He was conceived after a night of partying and a torn condom. $He nearly killed your career.">>
			<<set $activeSlave.custom.tattoo = "$He has your signature, surrounded by hearts, tattooed on the back of $his neck.">>
		<<elseif $activeSlave.father == -1>>
			<<set $activeSlave.origin = "$He was conceived after a night of partying and a torn condom.">>
			<<set $activeSlave.custom.tattoo = "$He has your signature, surrounded by hearts, tattooed on the back of $his neck.">>
		<<else>>
			<<set $activeSlave.origin = "$He was one of your groupies during your celebrity career.">>
			<<set $activeSlave.custom.tattoo = "$He has your signature, surrounded by hearts, tattooed on the back of $his neck. $He got the tattoo when $he was still free.">>
		<</if>>
	<<elseif $PC.career == "wealth">>
		<<if $activeSlave.mother == -1 && $activeSlave.father == -1>>
			<<set $activeSlave.origin = "You bet your body on a sure hand, only to lose. It turns out you could fuck yourself, and not only that, get yourself pregnant.">>
			<<set $activeSlave.custom.tattoo = "$He has a small tattoo of a losing hand of cards on the nape of $his neck.">>
		<<elseif $activeSlave.mother == -1>>
			<<set $activeSlave.origin = "You bet your body on a sure hand, only to lose. Nine months later, your $daughter was born.">>
			<<set $activeSlave.custom.tattoo = "$He has a small tattoo of a losing hand of cards on the nape of $his neck.">>
		<<elseif $activeSlave.father == -1>>
			<<set $activeSlave.origin = "You won a sexual fling with $his mother after winning at cards, a gamble that ultimately burdened you.">>
			<<set $activeSlave.custom.tattoo = "$He has a small tattoo of a poor hand of cards on the nape of $his neck.">>
		<<else>>
			<<set $activeSlave.origin = "You won $him at cards, a memento from your life as one of the idle rich before you became an arcology owner.">>
			<<set $activeSlave.custom.tattoo = "$He has a small tattoo of a winning hand of cards on the nape of $his neck.">>
		<</if>>
	<<elseif $PC.career == "BlackHat">>
		<<if $activeSlave.mother == -1 && $activeSlave.father == -1>>
			<<set $activeSlave.origin = "$He was the result of a night of hard celebration after a big score under the glow of monitors and the calming hum of 750 RPM fans. It took quite a bit of alcohol to come to terms with drunkenly knocking yourself up.">>
			<<set $activeSlave.custom.tattoo = "$He has your former digital calling card tattooed on $his neck.">>
		<<elseif $activeSlave.mother == -1>>
			<<set $activeSlave.origin = "$He was the result of an intruder brute forcing your firewall, overloading your pleasure sensors, and allowing a corrupted packet to slip by. With a quick wipe of your RAM and cache with some powerful liquor, you have no idea who planted $him in your womb.">>
			<<set $activeSlave.custom.tattoo = "$He has your former digital calling card tattooed on $his neck.">>
		<<elseif $activeSlave.father == -1>>
			<<set $activeSlave.origin = "$He was born out of a trade for secure data access. Nine months later, your $daughter was born.">>
			<<set $activeSlave.custom.tattoo = "$He has your former digital calling card tattooed on $his neck.">>
		<<else>>
			<<set $activeSlave.origin = "$He was a case officer you captured after going dark.">>
			<<set $activeSlave.custom.tattoo = "$He has your former digital calling card tattooed on $his neck.">>
		<</if>>
	<<else>>
		<<set $activeSlave.origin = "You won $him at cards, a memento from your life as one of the idle rich before you became an arcology owner.">>
		<<set $activeSlave.custom.tattoo = "$He has the silhouette of an arcology tattooed on the nape of $his neck.">>
	<</if>>
	<<if $activeSlave.fetish == "mindbroken">>
		<<if !isAmputee($activeSlave)>>
			<<set $activeSlave.origin = "You brought $him into the arcology mindbroken, little more than a walking collection of fuckable holes.">>
		<<else>>
			<<set $activeSlave.origin = "You brought $him into the arcology mindbroken, little more than a human onahole.">>
		<</if>>
	<</if>>
<</if>>

You are customizing this slave:
 <<include "Long Slave Description">>

	<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'Overview')" id="tab Overview">Overview</button>
	<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'Physical')" id="tab Physical">Physical</button>
	<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'Mental')" id="tab Mental">Mental</button>
	<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'Skills')" id="tab Skills">Skills</button>
	<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'Family', App.StartingGirls.uncommittedFamilyTree(V.activeSlave))" id="tab Family">Family</button>
	<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'Customization')" id="tab Customization">Customization</button>
	<<if $cash >= _slaveCost>>
		<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'assignRemove')" id="tab assignRemove">Finalize</button>
	<<else>>
		<button class="tablinks, show-warning" onclick="App.UI.tabbar.openTab(event, 'assignRemove')" id="tab assignRemove">Finalize</button>
	<</if>>

<<setLocalPronouns $activeSlave>>

	<<set _options = new App.UI.OptionsGroup()>>

	<<set _option = _options.addOption("Devotion", "devotion", $activeSlave).showTextBox()
	.addRange(-100, -95, "<", "Utterly hateful")
	.addRange(-70, -50, "<", "Hateful")
	.addRange(-35, -20, "<", "Resistant")
	.addRange(0, 20, "<", "Ambivalent")
	.addRange(35, 50, "<", "Accepting")
	.addRange(70, 95, "<", "Devoted")
	.addRange(100, 95, ">=", "Worshipful")>>
	<<if $activeSlave.devotion > 20>>
		<<set _comment = "Starting slaves incur">>
		<<if $activeSlave.devotion > 50>>
			<<run _comment += " severe cost penalty at very high">>
		<<else>>
			<<run _comment += " an additional cost penalty at high">>
		<</if>>
		<<run _comment += " levels of devotion. This slave's">>
		<<if $activeSlave.actualAge >= 25>>
			<<if $activeSlave.actualAge > 35>>advanced	<</if>>
			<<run _comment += " age decreases the penalty.">>
		<<else>>
			<<run _comment += " young age requires paying the full penalty.">>
		<</if>>
		<<run _option.addComment(`<span class=warning>${_comment}</span>`)>>
	<</if>>

	<<run _options.addOption("Trust", "trust", $activeSlave).showTextBox()
	.addRange(-100, -95, "<", "Abjectly terrified")
	.addRange(-70, -50, "<", "Terrified")
	.addRange(-35, -20, "<", "Frightened")
	.addRange(0, 20, "<", "Fearful")
	.addRange(35, 50, "<", "Careful")
	.addRange(70, 95, "<", "Trusting")
	.addRange(100, 95, ">=", "Absolute trust")>>

	<<run _options.addOption("Legal status", "indenture", $activeSlave)
	.addValue("Slave", -1, () => V.activeSlave.indentureRestrictions = 0)
	.addRange(52, 0, ">=", "Indentured Servant")>>
	<<if $activeSlave.indenture > -1>>
		<<run _options.addOption("Remaining weeeks", "indenture", $activeSlave).showTextBox()>>

		<<run _options.addOption("Indenture restrictions", "indentureRestrictions", $activeSlave)
		.addValueList([["None", 0], ["Protective", 1], ["Restrictive", 2]])>>
	<</if>>

	<<run _options.addOption("Age", "actualAge", $activeSlave).showTextBox()
	.customButton("Resync characteristics to age", () => resyncSlaveToAge(V.activeSlave))
	.customButton("Resync only height to age", () => V.activeSlave.height = Height.random(V.activeSlave))
	.addComment("It is recommended to resync if you change age significantly")>>

	<<run _options.addOption("Birth week", "birthWeek", $activeSlave).showTextBox()>>

	<<run _options.addOption("Genes", "genes", $activeSlave)
	.addValue("XX (Female)", "XX", () => {
		V.activeSlave.dick = 0;
		V.activeSlave.balls = 0;
		V.activeSlave.clit = 0;
		V.activeSlave.pubertyXY = 0;
		V.activeSlave.pubertyAgeXY = V.potencyAge;
		V.activeSlave.pubertyXX = (V.activeSlave.pubertyAgeXX < V.activeSlave.actualAge ? 1 : 0);
		V.activeSlave.vagina = Math.max(0, V.activeSlave.vagina);
		V.activeSlave.boobs = Math.max(500, V.activeSlave.boobs);
		V.activeSlave.balls = 0;
		V.activeSlave.scrotum = 0;
		V.activeSlave.prostate = 0;
		V.activeSlave.shoulders = either(-2,-1,0);
		V.activeSlave.hips = either(-2,-1,0);
	}).addValue("XY (Male)", "XY", () => {
		V.activeSlave.dick = 3;
		V.activeSlave.vagina = -1;
		WombFlush(V.activeSlave);
		V.activeSlave.belly = 0;
		V.activeSlave.bellyPreg = 0;
		V.activeSlave.pubertyXY = (V.activeSlave.pubertyAgeXY < V.activeSlave.actualAge ? 1 : 0);
		V.activeSlave.pubertyXX = 0;
		V.activeSlave.pubertyAgeXX = V.fertilityAge;
		V.activeSlave.ovaries = 0;
		V.activeSlave.boobs = 0;
		V.activeSlave.balls = 3;
		V.activeSlave.scrotum = 3;
		V.activeSlave.prostate = 1;
		V.activeSlave.shoulders = either(0,1,2);
		V.activeSlave.hips = either(0,1,2);
	})>>

	<<run _options.addOption("Condition", "condition", $activeSlave.health)
	.addValueList([["Unhealthy", -40], ["Healthy", 0], ["Very healthy", 40], ["Extremely healthy", 80]])>>

	<<set _option = _options.addOption("Prestige", "prestige", $activeSlave)
	.addValueList([["None", 0], ["Locally known", 1], ["Regionally famous", 2], ["World renowned", 3]])>>
	<<if $activeSlave.prestige > 0>>
		<<set _comment = "Starting slaves incur an extreme cost penalty for prestige. This slave's">>
		<<if $activeSlave.actualAge >= 25>>
			<<if $activeSlave.actualAge > 35>>
				<<set _comment += " advanced">>
			<</if>>
			<<set _comment += " age decreases the penalty.">>
		<<else>>
			<<set _comment += " young age requires paying the full penalty.">>
		<</if>>
		<<run _option.addComment(`<span class=warning>${_comment}</span>`)>>
	<</if>>

	<<run _options.addOption("$His nationality is", "nationality", $activeSlave).showTextBox()>>

	<<if $seeRace == 1>>
		<<run _options.addOption("$His ethnicity is", "race", $activeSlave).showTextBox()
		.addValueList([["White", "white"], ["Asian", "asian"], ["Latina", "latina"], ["Middle Eastern", "middle eastern"],
			["Black", "black"], ["Semetic", "semetic"], ["Southern European", "southern european"], ["Indo-Aryan", "indo-aryan"],
			["Amerindian", "amerindian"], ["Pacific Islander", "pacific islander"], ["Malay", "malay"], ["Mixed Race", "mixed race"]])>>
	<</if>>

	<<run _options.addOption("$His skin color is", "origSkin", $activeSlave).showTextBox()
	.addValueList([["Pure White", "pure white"], ["Ivory", "ivory"], ["White", "white"], ["Extremely Pale", "extremely pale"],
			["Very Pale", "very pale"], ["Pale", "pale"], ["Extremely Fair", "extremely fair"], ["Very Fair", "very fair"],
			["Fair", "fair"], ["Light", "light"], ["Light Olive", "light olive"], ["Tan", "tan"], ["Olive", "olive"], ["Bronze", "bronze"],
			["Dark Olive", "dark olive"], ["Dark", "dark"], ["Light Beige", "light beige"], ["Beige", "beige"],
			["Dark Beige", "dark beige"], ["Light Brown", "light brown"], ["Brown", "brown"], ["Dark Brown", "dark brown"],
			["Black", "black"], ["Ebony", "ebony"], ["Pure Black", "pure black"]])>>

	<<run _options.addOption("Intelligence", "intelligence", $activeSlave)
	.addValueList([["Moronic", -100], ["Very stupid", -60], ["Stupid", -30], ["Average", 0], ["Smart", 30], ["Very smart", 60], ["Brilliant", 100]])>>

	<<run _options.addOption("Education", "intelligenceImplant", $activeSlave)
	.addValueList([["Uneducated", 0], ["Educated", 15], ["Well educated", 30]])>>

	<<includeDOM _options.render()>>

	<<set _options = new App.UI.OptionsGroup()>>

	<<run _options.addOption("Height: <<= heightToEitherUnit($activeSlave.height)>>", "height", $activeSlave).showTextBox("cm")
	.addRange(145, 150, "<", "Petite")
	.addRange(155, 160, "<", "Short")
	.addRange(165, 170, "<", "Average")
	.addRange(180, 185, "<", "Tall")
	.addRange(190, 185, ">=", "Very tall")>>
	<<set _option = _options.addOption(`Average height for a ${$activeSlave.actualAge} year old """is ${heightToEitherUnit(Math.round(Height.mean(V.activeSlave)))}"""`)
	.customButton("Make average", () => resyncSlaveHight($activeSlave))>>
	<<if $cheatMode === 1>>
		<<run _option.customButton("Make dwarf", () => V.activeSlave.height = Height.random(V.activeSlave, {limitMult:	[-4, -1], spread: 0.15}))
		.customButton("Make giant", () => V.activeSlave.height = Height.random(V.activeSlave, {limitMult:	[3, 10], spread: 0.15}))>>
	<</if>>

	<<run _options.addOption("Weight", "weight", $activeSlave)
	.addRange(-100, -95, "<", "Emaciated")
	.addRange(-50, -30, "<", "Skinny")
	.addRange(-20, -10, "<", "Thin")
	.addRange(0, 10, "<", "Average")
	.addRange(20, 30, "<", "Plush")
	.addRange(50, 95, "<", "Chubby")
	.addRange(100, 130, "<", "Fat")
	.addRange(140, 160, "<", "Obese")
	.addRange(180, 190, "<", "Super obese")
	.addRange(200, 190, ">=", "Dangerously obese")>>

	<<run _options.addOption("Muscles", "muscles", $activeSlave)
	.addRange(-100, -96, "<", "Frail")
	.addRange(-66, -51, "<", "Very weak")
	.addRange(-41, -6, "<", "Weak")
	.addRange(0, 5, "<", "Normal")
	.addRange(20, 30, "<", "Toned")
	.addRange(40, 50, "<", "Well built")
	.addRange(65, 95, "<", "Quite muscular")
	.addRange(100, 95, ">=", "Ripped")>>

	<<run _options.addOption("Waist", "waist", $activeSlave)
	.addRange(-100, -95, "<", "	Absurd")
	.addRange(-55, -40, "<", "Hourglass")
	.addRange(-25, -15, "<", "Feminine")
	.addRange(0, 10, "<", "Average")
	.addRange(15, 40, "<", "Unattractive")
	.addRange(55, 95, "<", "Ugly")
	.addRange(100, 10, ">=", "Masculine")>>

	<<set _option = _options.addOption("Facial appearance", "faceShape", $activeSlave)
	.addValue("Normal", "normal")>>
	<<if $seeDicks !== 0>>
		<<run _option.addValue("Masculine", "masculine")>>
	<</if>>
	<<run _option.addValueList([["Androgynous", "androgynous"], ["Cute", "cute"], ["Sensual", "sensual"], ["Exotic", "exotic"]])>>

	<<run _options.addOption("Facial attractiveness", "face", $activeSlave)
	.addRange(-100, -95, "<", "Very ugly")
	.addRange(-55, -40, "<", "Ugly")
	.addRange(-15, -10, "<", "Unattractive")
	.addRange(0, 10, "<", "Average")
	.addRange(15, 40, "<", "Attractive")
	.addRange(55, 95, "<", "Beautiful")
	.addRange(100, 95, ">=", "Very beautiful")>>

	<<set _option = _options.addOption("Lips", "lips", $activeSlave)
	.addRange(5, 10, "<", "Thin")
	.addRange(15, 20, "<", "Normal")
	.addRange(25, 40, "<", "Pretty")
	.addRange(55, 70, "<", "Plush")>>
	<<if $seeExtreme == 1>>
		<<run _option.addRange(85, 95, "<", "Huge")
			.addRange(100, 95, ">=", "Facepussy")>>
	<<else>>
		<<run _option.addRange(85, 70, ">=", "Huge")>>
	<</if>>

	<<run _options.addOption("Voice", "voice", $activeSlave)
	.addValueList([["Mute", 0], ["Deep", 1], ["Normal", 2], ["High", 3]])>>

	<<if $activeSlave.voice !== 0>>
		<<run _options.addOption("$language", "accent", $activeSlave)
		.addValueList([["Unaccented", 0], [`Pretty ${aNational($activeSlave.nationality)} accent`, 1],
		[`Thick ${aNational($activeSlave.nationality)} accent`, 2], ["Not fluent", 3]])>>
	<</if>>

	<<set _option = _options.addOption("Teeth", "teeth", $activeSlave)
	.addValueList([["Croooked", "crooked"], ["Gapped", "gapped"], ["Braces", "straightening braces"]])>>
	<<if $activeSlave.physicalAge >= 12>>
		<<if $activeSlave.teeth == "baby" || $activeSlave.teeth == "mixed">>
			<<set $activeSlave.teeth = "normal">>
		<</if>>
		<<run _option.addValue("Straight", "normal")>>
	<<elseif $activeSlave.physicalAge >= 6>>
		<<if $activeSlave.teeth == "baby" || $activeSlave.teeth == "normal" || $activeSlave.teeth == "">>
			<<set $activeSlave.teeth = "mixed">>
		<</if>>
		<<run _option.addValue("Mixed adult & child", "mixed")>>
	<<else>>
		<<if $activeSlave.teeth == "mixed" || $activeSlave.teeth == "normal" || $activeSlave.teeth == "">>
			<<set $activeSlave.teeth = "mixed">>
		<</if>>
		<<run _option.addValue("Baby", "baby")>>
	<</if>>

	<<run _options.addOption("Breasts", "boobs", $activeSlave).showTextBox("CCs")
	.addRange(200, 200, "<=", "Flat (AA-cup)")
	.addRange(300, 300, "<=", "Small (A-cup)")
	.addRange(400, 400, "<=", "Medium (B-cup)")
	.addRange(500, 500, "<=", "Healthy (C-cup)")
	.addRange(800, 800, "<=", "Large (DD-cup)")
	.addRange(1200, 1200, "<=", "Very Large (G-cup)")
	.addRange(2050, 2050, "<=", "Huge (K-cup)")
	.addRange(3950, 3950, "<=", "Massive (Q-cup)")
	.addRange(6000, 6000, "<=", "Monstrous")
	.addRange(8000, 6000, ">", "Science Experiment")>>

	<<run _options.addOption("Lactation", "lactation", $activeSlave)
	.addValue("Artificial", 2, () => V.activeSlave.lactationDuration = 2)
	.addValue("Natural", 1, () => V.activeSlave.lactationDuration = 2)
	.addValue("None", 0)>>

	<<run _options.addOption("Nipples", "nipples", $activeSlave)
	.addValueList([["Tiny", "tiny"], ["Cute", "cute"], ["Puffy", "puffy"], ["Inverted", "inverted"], ["Huge", "huge"]])>>

	<<run _options.addOption("Areolae", "areolae", $activeSlave)
	.addValueList([["Normal", 0], ["Large", 1], ["Wide", 2], ["Huge", 3], ["Massive", 4]])>>

	<<run _options.addOption("Shoulders", "shoulders", $activeSlave)
	.addValueList([["Very narrow", -2], ["Narrow", -1], ["Feminine", 0], ["Broad", 1], ["Very broad", 2]])>>

	<<run _options.addOption("Hips", "hips", $activeSlave)
	.addValueList([["Very narrow", -2], ["Narrow", -1], ["Normal", 0], ["Broad", 1], ["Very broad", 2]])>>

	<<run _options.addOption("Butt", "butt", $activeSlave)
	.addValueList([["Flat", 0], ["Small", 1], ["Plumb", 2], ["Big", 3], ["Huge", 4], ["Enormous", 5], ["Gigantic", 6], ["Massive", 7]])>>

	<<run _options.addOption("Anus", "anus", $activeSlave)
	.addValueList([["Virgin", 0], ["Normal", 1], ["Veteran", 2], ["Gaping", 3]])>>

	<<run _options.addOption("Vagina", "vagina", $activeSlave)
	.addValue("No vagina", -1, () => {
		V.activeSlave.preg = 0;
		WombFlush(V.activeSlave);
		V.activeSlave.belly = 0;
		V.activeSlave.bellyPreg = 0;
		V.activeSlave.pubertyXX = 0;
		V.activeSlave.pubertyAgeXX = V.fertilityAge;
		V.activeSlave.ovaries = 0;
	}).addValue("Virgin", 0, () => {
		V.activeSlave.preg = -1;
		V.activeSlave.belly = 0;
		V.activeSlave.bellyPreg = 0;
		V.activeSlave.ovaries = 1
	}).addValue("Normal", 1, () => {
		V.activeSlave.preg = -1;
		V.activeSlave.belly = 0;
		V.activeSlave.bellyPreg = 0;
		V.activeSlave.ovaries = 1
	}).addValue("Veteran", 2, () => {
		V.activeSlave.preg = -1;
		V.activeSlave.belly = 0;
		V.activeSlave.bellyPreg = 0;
		V.activeSlave.ovaries = 1
	}).addValue("Gaping", 3, () => {
		V.activeSlave.preg = -1;
		V.activeSlave.belly = 0;
		V.activeSlave.bellyPreg = 0;
		V.activeSlave.ovaries = 1
	})>>

	<<if $activeSlave.vagina > -1>>
		<<if $activeSlave.dick === 0>>
			<<run _options.addOption("Clit", "clit", $activeSlave)
			.addValueList([["Normal", 0], ["Large", 1], ["Huge", 2]])>>
		<</if>>

		<<run _options.addOption("Labia", "labia", $activeSlave)
		.addValueList([["Normal", 0], ["Large", 1], ["Huge", 2]])>>

		<<run _options.addOption("Vaginal wetness", "vaginaLube", $activeSlave)
		.addValueList([["Dry", 0], ["Normal", 1], ["Excessive", 2]])>>

		<<if $seePreg !== 0>>
			/* This is only shown if slave has vagina */
			<<run _options.addOption("Puberty", "pubertyXX", $activeSlave)
			.addValue("Prepubescent", 0, () => {
				V.activeSlave.pubertyAgeXX = V.fertilityAge;
				V.activeSlave.belly = 0;
				V.activeSlave.bellyPreg = 0;
				WombFlush(V.activeSlave)
			}).addValue("Postpubescent", 1)>>

			<<run _options.addOption("Age of puberty", "pubertyAgeXX", $activeSlave).showTextBox()>>

			<<if $activeSlave.pubertyXX === 1>>
				<<set _option = _options.addOption("Pregnancy", "preg", $activeSlave)>>
				<<if $seeHyperPreg === 1 && $cheatMode === 1>>
					<<run _option.addValue("Bursting at the seams", 43, () => {
						V.activeSlave.pregType = 150;
						V.activeSlave.pregWeek = 43;
						V.activeSlave.pregKnown = 1;
						V.activeSlave.belly = 2700000;
						V.activeSlave.bellyPreg = 2700000;
						V.activeSlave.pubertyXX = 1;
					})>>
					<<if $activeSlave.preg === 43>>
						<<run _option.addComment("Extreme hyper pregnancy!")>>
					<</if>>
				<</if>>
				<<run _option.addValue("Completely Filled", 42, () => {
					V.activeSlave.pregType = 8;
					V.activeSlave.pregWeek = 42;
					V.activeSlave.pregKnown = 1;
					V.activeSlave.belly = 120000;
					V.activeSlave.bellyPreg = 120000;
					V.activeSlave.pubertyXX = 1;
				}).addValue("Ready to drop", 40, () => {
					V.activeSlave.pregType = 1;
					V.activeSlave.pregWeek = 40;
					V.activeSlave.pregKnown = 1;
					V.activeSlave.belly = 15000;
					V.activeSlave.bellyPreg = 15000;
					V.activeSlave.pubertyXX = 1;
				}).addValue("Advanced", 34, () => {
					V.activeSlave.pregType = 1;
					V.activeSlave.pregWeek = 34;
					V.activeSlave.pregKnown = 1;
					V.activeSlave.belly = 10000;
					V.activeSlave.bellyPreg = 10000;
					V.activeSlave.pubertyXX = 1;
				}).addValue("Showing", 27, () => {
					V.activeSlave.pregType = 1;
					V.activeSlave.pregWeek = 27;
					V.activeSlave.pregKnown = 1;
					V.activeSlave.belly = 5000;
					V.activeSlave.bellyPreg = 5000;
					V.activeSlave.pubertyXX = 1;
				}).addValue("Early", 12, () => {
					V.activeSlave.pregType = 1;
					V.activeSlave.pregWeek = 12;
					V.activeSlave.pregKnown = 1;
					V.activeSlave.belly = 100;
					V.activeSlave.bellyPreg = 100;
					V.activeSlave.pubertyXX = 1;
				}).addValue("None", 0, () => {
					V.activeSlave.pregType = 0;
					V.activeSlave.belly = 0;
					V.activeSlave.bellyPreg = 0;
					V.activeSlave.pregSource = 0;
					V.activeSlave.pregWeek = 0;
					V.activeSlave.pregKnown = 0;
				}).addValue("Barren", -2, () => {
					V.activeSlave.pregType = 0;
					V.activeSlave.belly = 0;
					V.activeSlave.bellyPreg = 0;
					V.activeSlave.pregSource = 0;
					V.activeSlave.pregWeek = 0;
					V.activeSlave.pregKnown = 0;
				})>>
			<</if>>

			<<if $PC.dick > 0 && $activeSlave.preg > 0>>
				<<run _options.addOption("Father of child", "pregSource", $activeSlave)
				.addValueList([["My child", -1], ["Not me", 0]])>>
			<</if>>
		<</if>>
	<</if>>

	<<if $seeDicks !== 0 || $makeDicks === 1>>
		<<run _options.addOption("Penis", "dick", $activeSlave)
		.addValue("None", 0, () => {
			V.activeSlave.balls = 0;
			V.activeSlave.pubertyXY = 0;
			V.activeSlave.pubertyAgeXY = V.potencyAge;
		}).addValue("Tiny", 1, () => {V.activeSlave.clit = 0})
		.addValue("Small", 2, () => {V.activeSlave.clit = 0})
		.addValue("Normal", 3, () => {V.activeSlave.clit = 0})
		.addValue("Large", 4, () => {V.activeSlave.clit = 0})
		.addValue("Massive", 5, () => {V.activeSlave.clit = 0})>>

		<<if $activeSlave.dick > 0>>
			<<set _option = _options.addOption("Foreskin", "foreskin", $activeSlave)>>
			<<if $seeCircumcision === 1>>
				<<run _option.addValue("Circumcised", 0)>>
			<<elseif $activeSlave.foreskin === 0>>
				<<set $activeSlave.foreskin = 3>>
			<</if>>
			<<run _option.addValueList([["Tiny", 1], ["Small", 2], ["Normal", 3], ["Large", 4], ["Massive", 5]])>>
		<</if>>

		<<run _options.addOption("Testicles", "balls", $activeSlave)
		.addValue("None", 0, () => {
			V.activeSlave.pubertyXY = 0;
			V.activeSlave.pubertyAgeXY = V.potencyAge;
			V.activeSlave.scrotum = 0;
		}).addValueList([["Vestigial", 1], ["Small", 2], ["Normal", 3], ["Large", 4], ["Massive", 5]])>>

		<<run _options.addOption("Age of Male Puberty", "pubertyAgeXY", $activeSlave).showTextBox()>>

		<<if $activeSlave.balls > 0>>
			<<run _options.addOption("Ballsack", "scrotum", $activeSlave)
			.addValueList([["None", 0], ["Tiny", 1], ["Small", 2], ["Normal", 3], ["Large", 4], ["Massive", 5]])>>

			<<run _options.addOption("Male Puberty", "pubertyXY", $activeSlave)
			.addValue("Prepubescent", 0, () => {V.activeSlave.pubertyAgeXY = V.potencyAge})
			.addValue("Postpubescent", 1)>>
		<</if>>
	<</if>>

	<<run _options.addOption("Prostate", "prostate", $activeSlave)
	.addValueList([["No prostate", 0], ["Has a prostate", 1]])>>

	<<set _optionLeft = _options.addOption("Left eye", "vision", $activeSlave.eye.left)>>
	<<set _optionRight = _options.addOption("Right eye", "vision", $activeSlave.eye.right)>>
	<<if $seeExtreme === 1>>
		<<run _optionLeft.addValue("Blind", 0),  _optionRight.addValue("Blind", 0)>>
	<<else>>
		<<if $activeSlave.eye.left.vision === 0>>
			<<set $activeSlave.eye.left.vision = 2>>
		<</if>>
		<<if $activeSlave.eye.right.vision === 0>>
			<<set $activeSlave.eye.right.vision = 2>>
		<</if>>
	<</if>>
	<<run _optionLeft.addValueList([["Nearsighted", 1], ["Normal", 2]]), _optionRight.addValueList([["Nearsighted", 1], ["Normal", 2]])>>

	<<set _option = _options.addOption("Hearing", "hears", $activeSlave)>>
	<<if $seeExtreme == 1>>
		<<run _option.addValue("Deaf", -2)>>
	<<elseif $activeSlave.hears === 0>>
		<<set $activeSlave.hears = 2>>
	<</if>>
	<<run _option.addValueList([["Hard of hearing", -1], ["Normal", 0]])>>

	<<if $seeExtreme == 1>>
		<<run _options.addOption("Smell ability", "smells", $activeSlave)
		.addValueList([["Normal", 0], ["None", -1]])>>

		<<run _options.addOption("Taste ability", "tastes", $activeSlave)
		.addValueList([["Normal", 0], ["None", -1]])>>

		<<set _LA = hasLeftArm($activeSlave)>>
		<<run _options.addOption("Left arm", "LA", State.temporary)
		.addValue("Healthy", true, () => V.activeSlave.arm.left = new App.Entity.LimbState())
		.addValue("Amputated", false, () => V.activeSlave.arm.left = null)>>

		<<set _RA = hasRightArm($activeSlave)>>
		<<run _options.addOption("Right arm", "RA", State.temporary)
		.addValue("Healthy", true, () => V.activeSlave.arm.right = new App.Entity.LimbState())
		.addValue("Amputated", false, () => V.activeSlave.arm.right = null)>>

		<<set _LL = hasLeftLeg($activeSlave)>>
		<<run _options.addOption("Left leg", "LL", State.temporary)
		.addValue("Healthy", true, () => V.activeSlave.leg.left = new App.Entity.LimbState())
		.addValue("Amputated", false, () => V.activeSlave.leg.left = null)>>

		<<set _RL = hasRightLeg($activeSlave)>>
		<<run _options.addOption("Right leg", "RL", State.temporary)
		.addValue("Healthy", true, () => V.activeSlave.leg.right = new App.Entity.LimbState())
		.addValue("Amputated", false, () => V.activeSlave.leg.right = null)>>
	<</if>>

	<<includeDOM _options.render()>>

	<<set _options = new App.UI.OptionsGroup()>>
	<<if $activeSlave.fetishKnown === 0>>
		<<run _options.addOption("Fetish", "fetishKnown", $activeSlave)
		.addValueList([["Unknown", 0], ["Known", 1]])>>
	<<else>>
		<<set _option = _options.addOption("Fetish", "fetish", $activeSlave)
		.addValue("Unknown", "", () => {
			V.activeSlave.fetish = either("boobs", "buttslut", "cumslut", "dom", "humiliation", "masochist", "pregnancy", "sadist",
				"submissive", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none");
			V.activeSlave.fetishKnown = 0
		}).addValueList([["None", "none"], ["Sub", "submissive"], ["Dom", "dom"], ["Cumslut", "cumslut"], ["Humilation", "humilation"],
		["Buttslut", "buttslut"], ["Breasts", "breasts"], ["Pregnancy", "pregnancy"], ["Sadism", "sadism"], ["Masochism", "masochism"]])>>
		<<if $seeExtreme === 1>>
			<<run _option.addValue("Mindbroken", "mindbroken", () => {
				V.activeSlave.fetishStrength = 10;
				V.activeSlave.sexualFlaw = "none";
				V.activeSlave.sexualQuirk = "none";
				V.activeSlave.behavioralFlaw = "none";
				V.activeSlave.behavioralQuirk = "none";
			})>>
		<</if>>

		<<if $activeSlave.fetish !== "none" && $activeSlave.fetish !== "mindbroken">>
			<<run _options.addOption("Fetish strength", "fetishStrength", $activeSlave)
			.addRange(15, 30, "<=", "Very Low")
			.addRange(45, 60, "<=", "Low")
			.addRange(75, 85, "<=", "Normal")
			.addRange(90, 95, "<=", "High")
			.addRange(100, 95, ">", "Extremely High")>>
		<</if>>
	<</if>>

	<<run _options.addOption("Sexuality", "attrKnown", $activeSlave)
	.addValue("Unknown", 0).addValue("Known", 1, () => {
		V.activeSlave.attrXX = random(0, 100);
		V.activeSlave.attrXY = random(0, 100);
		V.activeSlave.energy = random(1, 90);
	})>>
	<<if $activeSlave.attrKnown === 1>>
		<<run _options.addOption("Attraction to men", "attrXY", $activeSlave)
		.addRange(0, 5, "<=", "Disgusted").off()
		.addRange(10, 15, "<=", "Turned off").off()
		.addRange(25, 35, "<=", "Not attracted").off()
		.addRange(50, 65, "<=", "Indifferent").neutral()
		.addRange(75, 85, "<=", "Attracted").on()
		.addRange(90, 95, "<=", "Aroused").on()
		.addRange(100, 95, ">", "Passionate").on()>>
		<<run _options.addOption("Attraction to women", "attrXX", $activeSlave)
		.addRange(0, 5, "<=", "Disgusted").off()
		.addRange(10, 15, "<=", "Turned off").off()
		.addRange(25, 35, "<=", "Not attracted").off()
		.addRange(50, 65, "<=", "Indifferent").neutral()
		.addRange(75, 85, "<=", "Attracted").on()
		.addRange(90, 95, "<=", "Aroused").on()
		.addRange(100, 95, ">", "Passionate").on()>>

		<<run _options.addOption("Sex drive", "energy", $activeSlave)
		.addRange(5, 10, "<=", "Frigid").off()
		.addRange(25, 40, "<=", "Poor").off()
		.addRange(45, 60, "<=", "Average").neutral()
		.addRange(65, 80, "<=", "Powerful").on()
		.addRange(85, 99, "<=", "Sex addict").on()
		.addRange(100, 99, ">", "Nympho").on()>>
	<</if>>

	<<if $activeSlave.fetish !== "mindbroken">>
		<<run _options.addOption("Behavioral Flaw", "behavioralFlaw", $activeSlave)
		.addValueList([["None", "none"], ["Arrogant", "arrogant"], ["Bitchy", "bitchy"], ["Odd", "odd"], ["Hates Men", "hates men"],
		["Hates Women", "hates women"], ["Anorexic", "anorexic"], ["Gluttonous", "gluttonous"], ["Devout", "devout"],
		["Liberated", "liberated"]])>>

		<<run _options.addOption("Behavioral Quirk", "behavioralQuirk", $activeSlave)
		.addValueList([["None", "none"], ["Confident", "confident"], ["Cutting", "cutting"], ["Funny", "funny"],
		["Adores Men", "adores men"], ["Adores Women", "adores women"], ["Insecure", "insecure"], ["Fitness", "fitness"],
		["Sinful", "sinful"], ["Advocate", "advocate"]])>>

		<<run _options.addOption("Sexual Flaw", "sexualFlaw", $activeSlave)
		.addValueList([["None", "none"], ["Hates Oral", "hates oral"], ["Hates Anal", "hates anal"],
		["Hates Penetration", "hates penetration"], ["Repressed", "repressed"], ["Shamefast", "shamefast"], ["Apathetic", "apathetic"],
		["Crude", "crude"], ["Judgemental", "judgemental"], ["Sexually idealistic", "idealistic"]])>>

		<<run _options.addOption("Sexual Quirk", "sexualQuirk", $activeSlave)
		.addValueList([["None", "none"], ["Oral", "gagfuck queen"], ["Anal", "painal queen"], ["Penetration", "strugglefuck queen"],
		["Perverted", "perverted"], ["Tease", "tease"], ["Caring", "caring"], ["Unflinching", "unflinching"], ["Size queen", "size queen"],
		["Romantic", "romantic"]])>>
	<</if>>

	<<includeDOM _options.render()>>

	<<set _options = new App.UI.OptionsGroup()>>

	<<run _options.addOption("Oral sex", "oral", $activeSlave.skill)
	.addRange(0, 10, "<=", "Unskilled")
	.addRange(15, 30, "<=", "Basic")
	.addRange(35, 60, "<=", "Skilled")
	.addRange(65, 60, ">", "Expert")>>

	<<set _option = _options.addOption("Anal sex", "anal", $activeSlave.skill)>>
	<<if $activeSlave.anus === 0>>
		<<run _option.addComment("Anal virgins cannot be given anal skills.")>>
	<<else>>
		<<run _option.addRange(0, 10, "<=", "Unskilled")
		.addRange(15, 30, "<=", "Basic")
		.addRange(35, 60, "<=", "Skilled")
		.addRange(65, 60, ">", "Expert")>>
	<</if>>

	<<set _option = _options.addOption("Vaginal sex", "vaginal", $activeSlave.skill)>>
	<<if $activeSlave.vagina === 0>>
		<<run _option.addComment("Virgins cannot be given anal skills.")>>
	<<elseif $activeSlave.vagina === -1>>
		<<run _option.addComment("Must have a vagina to have vaginal skills.")>>
	<<else>>
		<<run _option.addRange(0, 10, "<=", "Unskilled")
		.addRange(15, 30, "<=", "Basic")
		.addRange(35, 60, "<=", "Skilled")
		.addRange(65, 60, ">", "Expert")>>
	<</if>>

	<<run _options.addOption("Prostitution", "whoring", $activeSlave.skill)
	.addRange(0, 10, "<=", "Unskilled")
	.addRange(15, 30, "<=", "Basic")
	.addRange(35, 60, "<=", "Skilled")
	.addRange(65, 60, ">", "Expert")>>

	<<run _options.addOption("Entertainment", "entertainment", $activeSlave.skill)
	.addRange(0, 10, "<=", "Unskilled")
	.addRange(15, 30, "<=", "Basic")
	.addRange(35, 60, "<=", "Skilled")
	.addRange(65, 60, ">", "Expert")>>

	<<run _options.addOption("Combat", "combat", $activeSlave.skill)
	.addValueList([["Unskilled", 0], ["Skilled", 1]])>>

	<<set _totalSkill = $activeSlave.skill.whoring + $activeSlave.skill.entertainment + $activeSlave.skill.vaginal
		+ $activeSlave.skill.anal + $activeSlave.skill.oral + ($activeSlave.skill.combat * 100)>>
	<<if _totalSkill > 200>>
		<<set _comment = "Starting slaves incur">>
		<<if _totalSkill > 400>>
			<<set _comment += " a severe cost penalty for being highly">>
		<<else>>
			<<set _comment += " an additional cost penalty for being">>
		<</if>>
		<<set _comment += " skilled. This slave's">>
		<<if $activeSlave.actualAge >= 25>>
			<<if $activeSlave.actualAge > 35>>
				<<set _comment += " advanced">>
			<</if>>
			<<set _comment += " age decreases the penalty.">>
		<<else>>
			<<set _comment += " young age requires paying the full penalty.">>
		<</if>>
		<<run _options.addOption("").addComment(`<span class="warning">${_comment}</span>`)>>
	<</if>>

	<<includeDOM _options.render()>>

	<<editFamily>>

	''Birth name:'' <<textbox "$activeSlave.birthName" $activeSlave.birthName "Starting Girls">>
	| ''Slave name:'' <<textbox "$activeSlave.slaveName" $activeSlave.slaveName "Starting Girls">>

''Birth surname:'' <<textbox "$activeSlave.birthSurname" $activeSlave.birthSurname "Starting Girls">>
	| ''Slave surname:'' <<textbox "$activeSlave.slaveSurname" $activeSlave.slaveSurname "Starting Girls">>

''Career:'' <<textbox "$activeSlave.career" $activeSlave.career "Starting Girls">>

''Hair color:'' <<textbox "$activeSlave.origHColor" $activeSlave.origHColor "Starting Girls">> //This will also set eyebrow, pubic, and underarm hair color.//

''Hair Style:'' <<textbox "$activeSlave.hStyle" $activeSlave.hStyle "Starting Girls">>

''Hair Length:'' <<textbox "$activeSlave.hLength" $activeSlave.hLength "Starting Girls">>

''Eye color:'' <<textbox "$activeSlave.eye.origColor" $activeSlave.eye.origColor "Starting Girls">>
	<<if def $pupil_temp>>
		<<set $activeSlave.eye.left.pupil = $pupil_temp, $activeSlave.eye.right.pupil = $pupil_temp, delete $pupil_temp>>
	<</if>>

''Pupil shape:'' <<textbox "$pupil_temp" $activeSlave.eye.left.pupil "Starting Girls">>
	<<if def $sclerae_temp>>
		<<set $activeSlave.eye.left.sclera = $sclerae_temp, $activeSlave.eye.right.sclera = $sclerae_temp, delete $sclerae_temp>>
	<</if>>

''Sclera color:'' <<textbox "$sclerae_temp" $activeSlave.eye.left.sclera "Starting Girls">>

Custom tattoo: <<textbox "$activeSlave.custom.tattoo" $activeSlave.custom.tattoo "Starting Girls">> //Use complete, capitalized and punctuated sentences.//

Custom origin story: <<textbox "$activeSlave.origin" $activeSlave.origin "Starting Girls">> //Use complete, capitalized and punctuated sentences.//

Origin override:
	<<if $originOveride == 0>>
		@@.red;Disabled@@ [[Enable|Starting Girls][$originOveride = 1]] //Enabling will keep your custom origin and tattoo from being overwritten by Starting Girls.//
	<<else>>
		@@.green;Enabled@@ [[Disable|Starting Girls][$originOveride = 0]] //Disabling will allow Starting Girls to overwrite origins and tattoos with its defaults.//
	<</if>>
	<<if $activeSlave.prestige>>

Reason for prestigiousness: <<textbox "$activeSlave.prestigeDesc" $activeSlave.prestigeDesc>> //Use complete, capitalized and punctuated sentences.//
	<</if>>

Custom description: <<textbox "$activeSlave.custom.desc" $activeSlave.custom.desc "Starting Girls">> //Use complete, capitalized and punctuated sentences.//

Custom label: <<textbox "$activeSlave.custom.label" $activeSlave.custom.label "Starting Girls">> //Use a short phrase.//

	''Eyebrow hair style:'' $activeSlave.eyebrowHStyle.
	[[Natural|Starting Girls][$activeSlave.eyebrowHStyle = "natural"]]
	| [[Curved|Starting Girls][$activeSlave.eyebrowHStyle = "curved"]]
	| [[Elongated|Starting Girls][$activeSlave.eyebrowHStyle = "elongated"]]
	| [[High-Arched|Starting Girls][$activeSlave.eyebrowHStyle = "high-arched"]]
	| [[Rounded|Starting Girls][$activeSlave.eyebrowHStyle = "rounded"]]
	| [[Shaved|Starting Girls][$activeSlave.eyebrowHStyle = "shaved"]]
	| [[Shortened|Starting Girls][$activeSlave.eyebrowHStyle = "shortened"]]
	| [[Slanted Inwards|Starting Girls][$activeSlave.eyebrowHStyle = "slanted inwards"]]
	| [[Slanted Outwards|Starting Girls][$activeSlave.eyebrowHStyle = "slanted outwards"]]
	| [[Straight|Starting Girls][$activeSlave.eyebrowHStyle = "straight"]]

	''Eyebrow hair maintenance:'' $activeSlave.eyebrowFullness
	[[Natural|Starting Girls][$activeSlave.eyebrowFullness = "natural"]]
	| [[Bushy|Starting Girls][$activeSlave.eyebrowFullness = "bushy"]]
	| [[Thick|Starting Girls][$activeSlave.eyebrowFullness = "thick"]]
	| [[Tapered|Starting Girls][$activeSlave.eyebrowFullness = "tapered"]]
	| [[Threaded|Starting Girls][$activeSlave.eyebrowFullness = "threaded"]]
	| [[Thin|Starting Girls][$activeSlave.eyebrowFullness = "thin"]]
	| [[Pencil-Thin|Starting Girls][$activeSlave.eyebrowFullness = "pencil-thin"]]

	''Pubic hair maintenance:'' $activeSlave.pubicHStyle.
	[[Waxed|Starting Girls][$activeSlave.pubicHStyle = "waxed"]]
	| [[Naturally hairless|Starting Girls][$activeSlave.pubicHStyle = "hairless"]]
	| [[Landing strip|Starting Girls][$activeSlave.pubicHStyle = "in a strip"]]
	| [[Neat|Starting Girls][$activeSlave.pubicHStyle = "neat"]]
	| [[Bushy in the front|Starting Girls][$activeSlave.pubicHStyle = "bushy in the front and neat in the rear"]]
	| [[Bushy|Starting Girls][$activeSlave.pubicHStyle = "bushy"]]
	| [[Very Bushy|Starting Girls][$activeSlave.pubicHStyle = "very bushy"]]

	''Under arm hair maintenance:'' $activeSlave.underArmHStyle.
	[[Waxed|Starting Girls][$activeSlave.underArmHStyle = "waxed"]]
	| [[Naturally hairless|Starting Girls][$activeSlave.underArmHStyle = "hairless"]]
	| [[Shaved|Starting Girls][$activeSlave.underArmHStyle = "shaved"]]
	| [[Neat|Starting Girls][$activeSlave.underArmHStyle = "neat"]]
	| [[Bushy|Starting Girls][$activeSlave.underArmHStyle = "bushy"]]

	''Natural skin distinctiveness:'' $activeSlave.markings.
	[[None|Starting Girls][$activeSlave.markings = "none"]]
	| [[Freckles|Starting Girls][$activeSlave.markings = "freckles"]]
	| [[Heavily freckled|Starting Girls][$activeSlave.markings = "heavily freckled"]]
	| [[Beauty mark|Starting Girls][$activeSlave.markings = "beauty mark"]]
	| [[Birthmark|Starting Girls][$activeSlave.markings = "birthmark"]]

	<<if $activeSlave.anus > 0>>

		''External appearance of anus:''
		<<if $activeSlave.analArea <= $activeSlave.anus>>
			Recently stretched to current size.
		<<elseif $activeSlave.analArea - $activeSlave.anus == 1>>
			Used to current size.
		<<else>>
			Very broad.
		<</if>>
		[[Recently stretched|Starting Girls][$activeSlave.analArea = $activeSlave.anus]]
		| [[Used to current size|Starting Girls][$activeSlave.analArea = $activeSlave.anus+1]]
		| [[Very broad|Starting Girls][$activeSlave.analArea = $activeSlave.anus+2]]
	<</if>>

	''Natural breast shape:'' $activeSlave.boobShape.
	[[Normal|Starting Girls][$activeSlave.boobShape = "normal"]]
	| [[Perky|Starting Girls][$activeSlave.boobShape = "perky"]]
	| [[Torpedo-shaped|Starting Girls][$activeSlave.boobShape = "torpedo-shaped"]]
	| [[Wide-set|Starting Girls][$activeSlave.boobShape = "wide-set"]]
	| [[Downward-facing|Starting Girls][$activeSlave.boobShape = "downward-facing"]]
	| [[Saggy|Starting Girls][$activeSlave.boobShape = "saggy"]]

	''Births:'' <<textbox "$activeSlave.counter.birthsTotal" $activeSlave.counter.birthsTotal "Starting Girls">> //How many times $he has already given birth, not necessarily while owned by you.//

	<<if $cash >= _slaveCost>>
		<<if $activeSlave.prestige>>
			<<set $activeSlave.prestige = Math.clamp($activeSlave.prestige,0,3)>>
		<<else>>
			<<set $activeSlave.prestigeDesc = 0>>
		<</if>>
		<<set $activeSlave.actualAge = Number($activeSlave.actualAge) || 18>>
		<<set $activeSlave.visualAge = $activeSlave.actualAge>>
		<<set $activeSlave.physicalAge = $activeSlave.actualAge>>
		<<set $activeSlave.devotion = Number($activeSlave.devotion) || 0>>
		<<set $activeSlave.trust = Number($activeSlave.trust) || 0>>
		<<if $activeSlave.indenture >= 0>>
			<<set $activeSlave.indenture = Math.clamp($activeSlave.indenture, 26, 208) || 26>>
		<</if>>
		<<set $activeSlave.height = Math.clamp($activeSlave.height, 85, 274) || 140>>
		<<set $activeSlave.boobs = Math.clamp(Math.trunc($activeSlave.boobs/50)*50, 0, 50000) || 200>>
		<<if $PC.career != "engineer">>

				<<link "Add this slave">>
					<<set $applyCareerBonus = 1>>
					<<goto "Commit Starting Girl">>
				<</link>>

					This will apply your @@.springgreen;career bonus@@ to her:
					<<if $PC.career == "capitalist">>
						one free level of @@.cyan;prostitution skill.@@
					<<elseif $PC.career == "mercenary">>
						@@.mediumaquamarine;+10 trust.@@
					<<elseif $PC.career == "slaver">>
						@@.hotpink;+10 devotion.@@
					<<elseif $PC.career == "medicine">>
						free @@.lime;basic implants.@@
					<<elseif $PC.career == "celebrity">>
						one free level of @@.cyan;entertainment skill.@@
					<<elseif $PC.career == "escort">>
						two free levels of @@.cyan;sex skills,@@ one free level of @@.cyan;prostitution skill,@@ and one free level of @@.cyan;entertainment skill.@@
					<<elseif $PC.career == "servant">>
						@@.mediumaquamarine;+10 trust@@ and @@.hotpink;+10 devotion.@@
					<<elseif $PC.career == "gang">>
						@@.green;+5 health@@ and one free level of @@.cyan;combat skill.@@
					<<elseif $PC.career == "wealth">>
						two free levels of @@.cyan;sex skills.@@
					<<elseif $PC.career == "BlackHat">>
						one free level of @@.cyan;intelligence.@@
					<<else>>
						@@.hotpink;+10 devotion,@@ one free level of @@.cyan;prostitution skill@@ and @@.cyan;entertainment skill,@@ and two free levels of @@.cyan;sex skills.@@
					<</if>>

		<</if>>
		<<set _text = $PC.career != "engineer" ? "Add this slave without career bonus" : "Add this slave">>

			<<link _text>>
				<<set $applyCareerBonus = 0>>
				<<goto "Commit Starting Girl">>
			<</link>>

	<</if>>

repo_name: KnightBoulegard/fc

license: mit


code:
/**
 * @param {App.Entity.SlaveState} slave
 * @returns {string}
 */
App.Medicine.OrganFarm.growActions = function(slave) {
	const organOrder = App.Medicine.OrganFarm.organDisplayOrder;
	const O = App.Medicine.OrganFarm.Organs;

	// find already being grown/ready to implant organs
	const slaveOrgans = {};
	organOrder.forEach(organ => slaveOrgans[organ] = 0);
	V.completedOrgans.forEach(organ => {
		if (organ.ID === slave.ID) {
			slaveOrgans[organ.type] = -1;
		}
	});
	V.organs.forEach(organ => {
		if (organ.ID === slave.ID) {
			slaveOrgans[organ.type] = organ.weeksToCompletion;
		}
	});

	function weeksLeft(time) {
		if (V.organFarmUpgrade === 1) {
			return time;
		} else if (V.organFarmUpgrade === 2) {
			return Math.ceil(time / 2);
		} else {
			return Math.ceil(time / 4);
		}
	}

	const {His, him} = getPronouns(slave);

	// create entries for each organ
	let grow = "";
	let wait = [];
	for (const organ of organOrder) {
		if (slaveOrgans[organ] === 0) {
			if (O[organ].canGrow()) {
				grow += `<div>${App.UI.link(O[organ].name, App.Medicine.OrganFarm.growOrgan, [slave, organ], "Remote Surgery")}</div>`;
				grow += `<div class="detail">Costs ${cashFormat(O[organ].cost)}${O[organ].tooltip !== "" ? ` and ${O[organ].tooltip}` : ""}.</div>`;
			}
		} else if (slaveOrgans[organ] > 0) {
			// in growth organs at the end of the list
			wait.push({
				time: slaveOrgans[organ],
				text: `${His} ${O[organ].name.toLowerCase()} will be ready for implantation in ${weeksLeft(slaveOrgans[organ])} weeks.`
			});
		}
	}

	// put everything in one string
	let r = "";
	if (grow !== "") {
		// div.grid-2columns-auto is defined in mainStyleSheet.css
		r += `The fabricator is ready to grow an organ for ${him}. Extract tissue to begin growing:<div class="grid-2columns-auto">${grow}</div>`;
	}
	if (wait !== []) {
		// nearer to completion => higher up
		wait.sort((a, b) => a.time - b.time);
		for (let i = 0; i < wait.length; i++) {
			r += `<div>${wait[i].text}</div>`;
		}
	}

	return r;
};

App.Medicine.OrganFarm.growOrgan = function(slave, organType) {
	const organ = App.Medicine.OrganFarm.Organs[organType];

	V.organs.push({type: organType, weeksToCompletion: organ.time, ID: slave.ID});

	cashX(-organ.cost, "slaveSurgery", slave);
};

App.Medicine.OrganFarm.growIncubatorOrgan = function(slave, organType) {
	const organ = App.Medicine.OrganFarm.Organs[organType];

	V.incubatorOrgans.push({type: organType, weeksToCompletion: organ.time, ID: slave.ID});

	cashX(-organ.cost, "slaveSurgery", slave);
};

/**
 * @param {App.Entity.SlaveState} slave
 * @returns {string}
 */
App.Medicine.OrganFarm.implantActions = function(slave) {
	let slaveOrgans = V.completedOrgans.filter(o => o.ID === slave.ID);
	if (slaveOrgans.length === 0) { return ""; }

	const F = App.Medicine.OrganFarm;
	let r = "";

	for (const organ of slaveOrgans) {
		r += `<div>${F.Organs[organ.type].name}:</div><div>`;

		let anyAction = false;
		let lines = [];
		for (let i = 0; i < F.Organs[organ.type].implantActions.length; i++) {
			const action = F.Organs[organ.type].implantActions[i];
			if (action.canImplant(slave)) {
				const implantLink = App.UI.link(action.name, App.Medicine.OrganFarm.implant, [slave, organ.type, i], "Surgery Degradation");
				lines.push(`<span class="detail">${action.tooltip === "" ? "" : `${capFirstChar(action.tooltip)}: `}</span>${implantLink}`);
				anyAction = true;
				break; // there can only be one implant action
			} else {
				const error = action.implantError(slave);
				if (error !== "") {
					lines.push(`ERROR: ${error} `);
				}
			}
		}

		// each error on a new line
		for (let i = 0; i < lines.length - 1; i++) {
			r += `<div>${lines[i]}</div>`;
		}

		// last error or implant action has "Discard" after them.
		r += `<div>${lines[lines.length - 1]}`;
		if (anyAction) {
			r += " | ";
		}
		r += `${App.UI.link("Discard", App.Medicine.OrganFarm.removeOrgan, [slave, organ.type], "Remote Surgery")}</div></div>`;
	}

	return `The fabricator has completed ${slaveOrgans.length} organ(s):<div class="grid-2columns-auto">${r}</div>`;
};

/**
 * @param {App.Entity.SlaveState} slave
 * @param {string} type
 * @param {number} actionIndex
 */
App.Medicine.OrganFarm.implant = function(slave, type, actionIndex) {
	const A = App.Medicine.OrganFarm.Organs[type].implantActions[actionIndex];

	A.implant(slave);
	surgeryDamage(slave, A.healthImpact);
	if (V.organFarmUpgrade >= 2) {
		slave.chem += 20;
	}

	App.Medicine.OrganFarm.removeOrgan(slave, type);
	V.surgeryType = A.surgeryType;
};

/**
 * @param {App.Entity.SlaveState} slave
 * @param {string} type
 */
App.Medicine.OrganFarm.removeOrgan = function(slave, type) {
	let organIndex = V.completedOrgans.findIndex(o => (o.ID === slave.ID && o.type === type));

	if (organIndex !== -1) {
		V.completedOrgans.deleteAt(organIndex);
	}
};

/**
 * Organs the that can be implanted on the slave, sorted by dependencies first
 *
 * @param {App.Entity.SlaveState} slave
 * @returns {[string]}
 */
App.Medicine.OrganFarm.getSortedOrgans = function(slave) {
	const F = App.Medicine.OrganFarm;
	const organs = [];
	const dependencies = [];
	V.completedOrgans.forEach(organ => {
		if (organ.ID === slave.ID) {
			organs.push(organ.type);
		}
	});
	organs.forEach(o => {
		F.Organs[o].dependencies.forEach(d => {
			if (organs.includes(d)) { /* inefficient, is there a better way? */
				dependencies.push([d, o]);
			}
		});
	});
	try {
		return App.Utils.topologicalSort(organs, dependencies);
	} catch (e) { // closed loop
		console.log(e.message);
		return [];
	}
};

/**
 * Returns the full organ farm menu, hiding empty parts
 *
 * @param {App.Entity.SlaveState} slave
 * @returns {string}
 */
App.Medicine.OrganFarm.fullMenu = function(slave) {
	if (V.organFarmUpgrade >= 1 && slave.indentureRestrictions < 2) {
		let r = "";

		let actions = App.Medicine.OrganFarm.growActions(slave);
		if (actions !== "") {
			r += `<h3>Grow new organs</h3><div class="indent">${actions}</div>`;
		}

		actions = App.Medicine.OrganFarm.implantActions(slave);
		if (actions !== "") {
			r += `<h3>Implant organs</h3><div class="indent">${actions}</div>`;
		}

		if (r === "") {
			return "";
		}

		return `<h2>Organ Farm</h2>${r}`;
	} else {
		return "";
	}
};

App.Medicine.OrganFarm.currentlyGrowing = function() {
	function weeksToCompletion(weeks) {
		if (V.organFarmUpgrade === 1) {
			return weeks;
		} else if (V.organFarmUpgrade === 2) {
			return Math.ceil(weeks / 2);
		} else {
			return Math.ceil(weeks / 4);
		}
	}

	let r = "";

	let growLines = [];
	let finishLines = [];

	V.organs.forEach(o => {
		const index = V.slaveIndices[o.ID];
		if (index !== undefined) {
			growLines.push(`${V.slaves[index].slaveName}'s ${App.Medicine.OrganFarm.Organs[o.type].name}, ${
				weeksToCompletion(o.weeksToCompletion)} week(s) left.`);
		} else {
			growLines.push(`<span class="error">ERROR: No slave with ID ${o.ID} found.</span>`);
		}
	});
	V.incubatorOrgans.forEach(o => {
		const tank = V.tanks.find((t) => t.ID === o.ID);
		if (tank !== undefined) {
			if (o.weeksToCompletion <= 0) {
				finishLines.push(`${tank.slaveName}'s ${App.Medicine.OrganFarm.Organs[o.type].name}.`);
			} else {
				growLines.push(`${tank.slaveName}'s ${App.Medicine.OrganFarm.Organs[o.type].name}, ${
					weeksToCompletion(o.weeksToCompletion)} week(s) left.`);
			}
		} else {
			growLines.push(`<span class="error">ERROR: No tank with ID ${o.ID} found.</span>`);
		}
	});

	V.completedOrgans.forEach(o => {
		const index = V.slaveIndices[o.ID];
		if (index !== undefined) {
			finishLines.push(`${V.slaves[index].slaveName}'s ${App.Medicine.OrganFarm.Organs[o.type].name}.`);
		} else {
			finishLines.push(`<span class="error">ERROR: No slave with ID ${o.ID} found.</span>`);
		}
	});

	if (growLines.length > 0) {
		r += "
Growing Organs
";
	}
	growLines.forEach(l => {
		r += `<div>${l}</div>`;
	});

	if (finishLines.length > 0) {
		r += "
Finished Organs
";
	}
	finishLines.forEach(l => {
		r += `<div>${l}</div>`;
	});

	return r;
};


code:
/**
 * Organs will usually be displayed in this order.
 * If an organ is not part of this array, it will be unreachable.
 *
 * @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.init = function() {
	new App.Medicine.OrganFarm.Organ({
		type: "penis", name: "Penis", tooltip: "will add a prostate if one is not already present", cost: 5000, time: 5,
		canGrow: () => (V.seeDicks !== 0 || V.makeDicks === 1),
		actions: [
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Implant", healthImpact: 20, surgeryType: "addDick",
				canImplant: slave => (slave.dick <= 0),
				implantError: () => "this slave already has a penis",
				implant: slave => {
					if (slave.prostate === 0) {
						slave.prostate = 1;
					}
					slave.dick = 2;
					slave.clit = 0;
					slave.foreskin = slave.dick;
				}
			})
		]
	});

	new App.Medicine.OrganFarm.Organ({
		type: "foreskin", name: "Foreskin", cost: 2500, time: 5,
		actions: [
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Graft on", healthImpact: 10, surgeryType: "addForeskin",
				canImplant: slave => (slave.foreskin <= 0),
				implantError: slave => `This slave already has a ${slave.dick > 0 ? "foreskin" : "clitoral hood"}.`,
				implant: slave => {
					if (slave.dick > 0) {
						slave.foreskin = slave.dick;
					} else if (slave.clit > 0) {
						slave.foreskin = slave.clit;
					} else {
						slave.foreskin = 1;
					}
				}
			})
		]
	});

	new App.Medicine.OrganFarm.Testicles({
		type: "testicles", name: "Testicles", ballType: "human", animal: false
	});
	new App.Medicine.OrganFarm.Testicles({
		type: "pigTesticles", name: "Pig testicles", ballType: "pig", animal: true
	});
	new App.Medicine.OrganFarm.Testicles({
		type: "dogTesticles", name: "Dog testicles", ballType: "dog", animal: true
	});
	new App.Medicine.OrganFarm.Testicles({
		type: "horseTesticles", name: "Horse testicles", ballType: "horse", animal: true
	});
	new App.Medicine.OrganFarm.Testicles({
		type: "cowTesticles", name: "Cow testicles", ballType: "cow", animal: true
	});

	new App.Medicine.OrganFarm.Organ({
		type: "scrotum", name: "Scrotum", tooltip: "requires balls for successful implantation", cost: 2500, time: 5,
		dependencies: ["testicles", "pigTesticles", "dogTesticles", "horseTesticles", "cowTesticles"],
		actions: [
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Graft on", healthImpact: 10, surgeryType: "addScrotum",
				canImplant: slave => (slave.scrotum <= 0 && slave.balls > 0),
				implantError: slave => (slave.scrotum > 0) ? "This slave already has a scrotum." : "This slave lacks the balls necessary to accept a scrotum.",
				implant: slave => {
					slave.scrotum = slave.balls;
				}
			})
		]
	});

	new App.Medicine.OrganFarm.Ovaries({
		type: "ovaries", name: "Ovaries", eggType: "human", pregData: "human", animal: false
	});
	new App.Medicine.OrganFarm.Ovaries({
		type: "pigOvaries", name: "Pig ovaries", eggType: "pig", pregData: "pig", animal: true
	});
	new App.Medicine.OrganFarm.Ovaries({
		type: "dogOvaries",
		name: "Dog ovaries",
		eggType: "dog",
		pregData: "canineM",
		animal: true
	});
	new App.Medicine.OrganFarm.Ovaries({
		type: "horseOvaries",
		name: "Horse ovaries",
		eggType: "horse",
		pregData: "equine",
		animal: true
	});
	new App.Medicine.OrganFarm.Ovaries({
		type: "cowOvaries", name: "Cow ovaries", eggType: "cow", pregData: "cow", animal: true
	});

	new App.Medicine.OrganFarm.AnalWomb({
		type: "mpreg",
		name: "Anal womb and ovaries",
		eggType: "human",
		pregData: "human",
		animal: false
	});
	new App.Medicine.OrganFarm.AnalWomb({
		type: "mpregPig",
		name: "Anal pig womb and ovaries",
		eggType: "pig",
		pregData: "pig",
		animal: true
	});
	new App.Medicine.OrganFarm.AnalWomb({
		type: "mpregDog",
		name: "Anal dog womb and ovaries",
		eggType: "dog",
		pregData: "canineM",
		animal: true
	});
	new App.Medicine.OrganFarm.AnalWomb({
		type: "mpregHorse",
		name: "Anal horse womb and ovaries",
		eggType: "horse",
		pregData: "equine",
		animal: true
	});
	new App.Medicine.OrganFarm.AnalWomb({
		type: "mpregCow",
		name: "Anal cow womb and ovaries",
		eggType: "cow",
		pregData: "cow",
		animal: true
	});

	new App.Medicine.OrganFarm.Organ({
		type: "freshOvaries", name: "Younger Ovaries",
		tooltip: "requires a womb for successful implantation",
		cost: 10000, time: 10,
		canGrow: () => (V.youngerOvaries === 1),
		dependencies: ["ovaries", "pigOvaries", "dogOvaries", "horseOvaries", "cowOvaries", "mpreg", "mpregPig", "mpregDog", "mpregHorse", "mpregCow"],
		actions: [
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Implant", healthImpact: 20, surgeryType: "freshOvaries",
				canImplant: s => ((s.mpreg !== 0 || s.ovaries !== 0) && s.bellyImplant === -1 && s.physicalAge < 70),
				implantError: s => (s.physicalAge >= 70) ? "This slave's body is too old to handle pregnancy." : "This slave lacks a viable womb.",
				implant: s => {
					if (s.ovaryAge >= 47) {
						s.ovaryAge = 45;
					} else {
						s.ovaryAge = -2; // It shouldn't matter if this goes negative as it is just a signal for menopause to occur.
					}
					if (s.preg < 0) {
						s.preg = 0;
					}
					if (s.pubertyXX === 0 && s.physicalAge >= V.fertilityAge) {
						if (V.precociousPuberty === 1) {
							s.pubertyAgeXX = s.physicalAge + 1;
						} else {
							s.pubertyXX = 1;
						}
					}
				}
			})
		]
	});

	new App.Medicine.OrganFarm.Organ({
		type: "asexualReproOvaries", name: "Asexual reproduction modification",
		tooltip: "requires existing ovaries for successful implantation",
		cost: 10000, time: 10,
		canGrow: () => (V.asexualReproduction === 1),
		dependencies: ["ovaries", "pigOvaries", "dogOvaries", "horseOvaries", "cowOvaries", "mpreg", "mpregPig", "mpregDog", "mpregHorse", "mpregCow"],
		actions: [
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Implant", healthImpact: 20, surgeryType: "asexualReproOvaries",
				canImplant: s => (s.mpreg !== 0 || s.ovaries !== 0),
				implantError: () => "This slave lacks ovaries.",
				implant: s => {
					if (s.preg < 0) {
						s.preg = 0;
					}
					s.eggType = "human";
					s.pregData = clone(setup.pregData.human);
					if (s.pubertyXX === 0 && s.physicalAge >= V.fertilityAge) {
						if (V.precociousPuberty === 1) {
							s.pubertyAgeXX = s.physicalAge + 1;
						} else {
							s.pubertyXX = 1;
						}
					}
					s.ovaImplant = "asexual";
				}
			})
		]
	});

	new App.Medicine.OrganFarm.Organ({
		type: "prostate", name: "Prostate", cost: 5000, time: 5,
		actions: [
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Implant", healthImpact: 20, surgeryType: "addProstate",
				canImplant: s => (s.prostate === 0),
				implantError: () => "This slave already has a prostate.",
				implant: s => {
					s.prostate = 1;
				}
			})
		]
	});

	new App.Medicine.OrganFarm.Organ({
		type: "leftEye", name: "Left Eye", cost: 5000, time: 10,
		actions: [
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Implant", healthImpact: 10, surgeryType: "newEyes",
				canImplant: s => (getLeftEyeVision(s) === 0 && getBestVision(s) !== 0 && getLeftEyeType(s) !== 2),
				implantError: s => getLeftEyeVision(s) !== 0 ? "Slave has a working left eye." : "",
				implant: s => {
					eyeSurgery(s, "left", "normal");
				}
			}),
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Implant", healthImpact: 10, surgeryType: "unblind",
				canImplant: s => (getBestVision(s) === 0 && getLeftEyeType(s) !== 2),
				implantError: () => "",
				implant: s => {
					eyeSurgery(s, "left", "normal");
				}
			}),
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Replace", tooltip: "replace the existing ocular implant with an organic eye",
				healthImpact: 10, surgeryType: "newEyes", autoImplant: false,
				canImplant: s => (getLeftEyeType(s) === 2),
				implantError: () => "",
				implant: s => {
					eyeSurgery(s, "left", "normal");
				}
			})
		]
	});
	new App.Medicine.OrganFarm.Organ({
		type: "rightEye", name: "Right Eye", cost: 5000, time: 10,
		actions: [
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Implant", healthImpact: 10, surgeryType: "newEyes",
				canImplant: s => (getRightEyeVision(s) === 0 && getBestVision(s) !== 0 && getRightEyeType(s) !== 2),
				implantError: s => getRightEyeVision(s) !== 0 ? "Slave has a working right eye." : "",
				implant: s => {
					eyeSurgery(s, "right", "normal");
				}
			}),
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Implant", healthImpact: 10, surgeryType: "unblind",
				canImplant: s => (getBestVision(s) === 0 && getRightEyeType(s) !== 2),
				implantError: () => "",
				implant: s => {
					eyeSurgery(s, "right", "normal");
				}
			}),
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Replace", tooltip: "replace the existing ocular implant with an organic eye",
				healthImpact: 20, surgeryType: "newEyes", autoImplant: false,
				canImplant: s => (getRightEyeType(s) === 2),
				implantError: () => "",
				implant: s => {
					eyeSurgery(s, "right", "normal");
				}
			})
		]
	});

	new App.Medicine.OrganFarm.Organ({
		type: "ears", name: "Normal Ears", cost: 1000, time: 2,
		actions: [
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Attach", healthImpact: 15, surgeryType: "earMinor",
				canImplant: s => (s.earShape === "none"),
				implantError: () => "This slave already has ears.",
				implant: s => {
					s.earShape = "normal";
					if (s.hears === -1) {
						s.hears = 0;
					}
				}
			}),
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Replace", tooltip: "replace current ears with normal human ears",
				healthImpact: 20, surgeryType: "earMinor", autoImplant: false,
				canImplant: s => (s.earShape !== "normal"),
				implantError: () => "This slave already has normal ears.",
				implant: s => {
					s.earShape = "normal";
				}
			})
		]
	});
	new App.Medicine.OrganFarm.Organ({
		type: "topEars", name: "Top Ears", cost: 1000, time: 2,
		canGrow: () => (V.surgeryUpgrade >= 1),
		actions: [
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Attach", healthImpact: 10, surgeryType: "earMinor",
				canImplant: s => (s.earT === "none"),
				implantError: () => "This slave already has ears at the top of the head.",
				implant: s => {
					s.earT = "normal";
					s.earTColor = "hairless";
				}
			}),
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Replace", tooltip: "replace current top ears with normal ears",
				healthImpact: 20, surgeryType: "earMinor", autoImplant: false,
				canImplant: s => (s.earT !== "normal"),
				implantError: () => "This slave already has normal ears at the top of the head.",
				implant: s => {
					s.earT = "normal";
					s.earTColor = "hairless";
				}
			})
		]
	});

	new App.Medicine.OrganFarm.Organ({
		type: "cochleae", name: "Cochleae", cost: 8000, time: 6,
		actions: [
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Implant", healthImpact: 20, surgeryType: "undeafen",
				canImplant: s => (s.hears <= -2 && s.earImplant === 0),
				implantError: () => "This slave already has working ears.",
				implant: s => {
					s.hears = 0;
				}
			}),
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Replace", tooltip: "remove cochlear implants before implanting organic cochleae",
				healthImpact: 20, surgeryType: "newEars", autoImplant: false,
				canImplant: s => (s.earImplant === 1),
				implantError: () => "",
				implant: s => {
					s.hears = 0;
					s.earImplant = 0;
				}
			})
		]
	});

	new App.Medicine.OrganFarm.Organ({
		type: "voicebox", name: "Vocal Cords", cost: 5000, time: 5,
		actions: [
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Implant", healthImpact: 10, surgeryType: "restoreVoice",
				canImplant: s => (s.voice === 0 && s.electrolarynx === 0),
				implantError: () => "This slave is not mute.",
				implant: s => {
					if (s.ovaries === 1 && s.hormoneBalance >= 200) {
						s.voice = 3;
					} else if (s.balls > 0 || s.hormoneBalance < -20) {
						s.voice = 1;
					} else {
						s.voice = 2;
					}
				}
			}),
			new App.Medicine.OrganFarm.OrganImplantAction({
				name: "Replace", tooltip: "remove electrolarynx and implant organic vocal cords",
				healthImpact: 20, surgeryType: "newVoice", autoImplant: false,
				canImplant: s => (s.electrolarynx === 1),
				implantError: () => "",
				implant: s => {
					s.electrolarynx = 0;
					if (s.ovaries === 1 && s.hormoneBalance >= 200) {
						s.voice = 3;
					} else if (s.balls > 0 || s.hormoneBalance < -20) {
						s.voice = 1;
					} else {
						s.voice = 2;
					}
				}
			})
		]
	});
};


code:
App.Medicine.OrganFarm.TesticlesImplantAction = class extends App.Medicine.OrganFarm.OrganImplantAction {
	/**
	 * @param {string} name
	 * @param {string} tooltip
	 * @param {string} ballType
	 * @param {boolean} animal
	 * @param {boolean} autoImplant
	 * @param {function(App.Entity.SlaveState):boolean} canImplant
	 * @param {function(App.Entity.SlaveState):string} implantError
	 * @param {function(App.Entity.SlaveState)} implant
	 */
	constructor({name, tooltip = "", animal, autoImplant = true, canImplant, implantError, implant} = {}) {
		super({
			name: name,
			tooltip: tooltip,
			healthImpact: 20,
			surgeryType: animal ? "addAnimalBalls" : "addBalls",
			autoImplant: autoImplant,
			canImplant: s => (!this.animal || V.animalTesticles > 0) && canImplant(s),
			implantError: s => (this.animal && V.animalTesticles === 0) ? "" : implantError(s),
			implant: implant
		});
		this.animal = animal;
	}
};

App.Medicine.OrganFarm.Testicles = class extends App.Medicine.OrganFarm.Organ {
	/**
	 * @param {string} type
	 * @param {string} name
	 * @param {string} ballType
	 * @param {boolean} animal
	 */
	constructor({type, name, ballType, animal} = {}) {
		super({
			type: type, name: name,
			tooltip: "will add a prostate if one is not already present; requires a penis for successful implantation",
			cost: 5000, time: 10,
			canGrow: () => (!this.animal || V.animalTesticles > 0), dependencies: ["penis"],
			actions: [
				new App.Medicine.OrganFarm.TesticlesImplantAction({
					name: "Implant", ballType: ballType, animal: animal,
					canImplant: slave => (slave.balls <= 0 && slave.dick > 0),
					implantError: slave => {
						if (slave.dick === 0) {
							return "This slave lacks the penis necessary to accept testicles.";
						} else {
							return "This slave already has testicles.";
						}
					},
					implant: slave => {
						if (slave.prostate === 0) {
							slave.prostate = 1;
						}
						slave.balls = 2;
						slave.ballType = this.ballType;
						slave.scrotum = 2;
						if (slave.pubertyAgeXY === 0) {
							if (V.precociousPuberty === 1) {
								if (slave.physicalAge >= V.potencyAge) {
									slave.pubertyAgeXY = slave.physicalAge + 1;
								}
							} else {
								if (slave.physicalAge >= V.potencyAge) {
									slave.pubertyXY = 1;
								}
							}
						}
					}
				}),
				new App.Medicine.OrganFarm.TesticlesImplantAction({
					name: "Implant",
					tooltip: "you can forgo standard procedure and implant testicles directly into $his abdomen",
					ballType: ballType, animal: animal, surgeryType: "addTesticles", autoImplant: false,
					canImplant: slave => (slave.dick === 0 && slave.balls <= 0),
					implantError: slave => ((slave.balls > 0) ? "This slave already has testicles." : ""),
					implant: slave => {
						if (slave.prostate === 0) {
							slave.prostate = 1;
						}
						slave.balls = 2;
						slave.ballType = this.ballType;
						if (slave.pubertyAgeXY === 0) {
							if (V.precociousPuberty === 1) {
								if (slave.physicalAge >= V.potencyAge) {
									slave.pubertyAgeXY = slave.physicalAge + 1;
								}
							} else {
								if (slave.physicalAge >= V.potencyAge) {
									slave.pubertyXY = 1;
								}
							}
						}
					}
				}),
				new App.Medicine.OrganFarm.TesticlesImplantAction({
					name: "Replace",
					tooltip: "you can replace the existing testicles with a new pair",
					healthImpact: 20,
					surgeryType: "addTesticles",
					autoImplant: false,
					canImplant: slave => (slave.balls > 0 && slave.ballType !== this.ballType),
					implantError: slave => (slave.balls > 0 ? `This slave already has ${this.ballType} testicles.` : ""),
					implant: slave => {
						slave.balls = 2;
						slave.ballType = this.ballType;
						if (slave.pubertyAgeXY === 0) {
							if (V.precociousPuberty === 1) {
								if (slave.physicalAge >= V.potencyAge) {
									slave.pubertyAgeXY = slave.physicalAge + 1;
								}
							} else {
								if (slave.physicalAge >= V.potencyAge) {
									slave.pubertyXY = 1;
								}
							}
						}
					}
				})
			]
		});
		this.animal = animal;
		this.ballType = ballType;
	}
};

App.Medicine.OrganFarm.OvariesImplantAction = class extends App.Medicine.OrganFarm.OrganImplantAction {
	/**
	 * @param {string} name
	 * @param {string} tooltip
	 * @param {boolean} animal
	 * @param {boolean} autoImplant
	 * @param {function(App.Entity.SlaveState):boolean} canImplant
	 * @param {function(App.Entity.SlaveState):string} implantError
	 * @param {function(App.Entity.SlaveState)} implant
	 */
	constructor({name, tooltip = "", animal, autoImplant = true, canImplant, implantError, implant} = {}) {
		super({
			name: name, tooltip: tooltip, healthImpact: 20,
			surgeryType: animal ? "addAnimalOvaries" : "addOvaries", autoImplant: autoImplant,
			canImplant: s => (!this.animal || V.animalTesticles > 0) && canImplant(s),
			implantError: s => (this.animal && V.animalTesticles === 0) ? "" : implantError(s),
			implant: implant
		});
		this.animal = animal;
	}
};

App.Medicine.OrganFarm.Ovaries = class extends App.Medicine.OrganFarm.Organ {
	/**
	 * @param {string} type
	 * @param {string} name
	 * @param {string} eggType
	 * @param {string} pregData
	 * @param {boolean} animal
	 */
	constructor({type, name, eggType, pregData, animal} = {}) {
		super({
			type: type, name: name, tooltip: "requires a vagina for successful implantation",
			cost: 10000, time: 10,
			canGrow: () => (!this.animal || V.animalOvaries > 0),
			actions: [
				new App.Medicine.OrganFarm.OvariesImplantAction({
					name: "Implant", animal: animal,
					canImplant: s => (s.vagina >= 0 && s.ovaries <= 0 && s.mpreg === 0 && s.bellyImplant === -1),
					implantError: s => {
						if (s.vagina < 0) { return "This slave lacks the vagina necessary to accept ovaries."; }
						if (s.ovaries >= 0) { return "This slave already has ovaries."; }
						return "This slave's body cavity is filled with another organ.";
					},
					implant: s => {
						s.ovaries = 1;
						s.eggType = this.eggType;
						s.preg = 0;
						s.pregData = clone(setup.pregData[this.pregData]);
						if (s.pubertyXX === 0 && s.physicalAge >= V.fertilityAge) {
							if (V.precociousPuberty === 1) {
								s.pubertyAgeXX = s.physicalAge + 1;
							} else {
								s.pubertyXX = 1;
							}
						}
					}
				}),
				new App.Medicine.OrganFarm.OvariesImplantAction({
					name: "Replace",
					tooltip: "you can replace the existing ovaries with a new pair",
					animal: animal,
					autoImplant: false,
					canImplant: s => (s.vagina >= 0 && s.mpreg === 0 && s.bellyImplant === -1 && (s.eggType !== this.eggType || s.preg === -3)),
					implantError: s => (s.eggType === this.eggType) ? `This slave already has ${s.eggType} ovaries.` : "",
					implant: s => {
						s.eggType = this.eggType;
						s.preg = 0;
						s.pregData = clone(setup.pregData[this.pregData]);
						if (s.pubertyXX === 0 && s.physicalAge >= V.fertilityAge) {
							if (V.precociousPuberty === 1) {
								s.pubertyAgeXX = s.physicalAge + 1;
							} else {
								s.pubertyXX = 1;
							}
						}
					}
				})
			]
		});
		this.animal = animal;
		this.eggType = eggType;
		this.pregData = pregData;
	}
};

App.Medicine.OrganFarm.AnalWombImplantAction = class extends App.Medicine.OrganFarm.OrganImplantAction {
	/**
	 * @param {string} eggType
	 * @param {string} pregData
	 * @param {boolean} animal
	 */
	constructor({eggType, pregData, animal} = {}) {
		super({
			name: "Implant", healthImpact: 40,
			surgeryType: "mpreg",
			canImplant: s => ((!this.animal || V.animalTesticles > 0) && s.ovaries === 0 && s.vagina <= -1 && s.mpreg === 0 && s.bellyImplant < 0),
			implantError: s => {
				if (this.animal && V.animalTesticles === 0) { return ""; }
				if (s.bellyImplant >= 0) { return "This slave has a fillable abdominal implant."; }
				return "This slave has existing reproductive Organs.";
			},
			implant: s => {
				s.mpreg = 1;
				s.eggType = this.eggType;
				s.preg = 0;
				s.pregData = clone(setup.pregData[this.pregData]);
				if (s.pubertyXX === 0 && s.physicalAge >= V.fertilityAge) {
					if (V.precociousPuberty === 1) {
						s.pubertyAgeXX = s.physicalAge + 1;
					} else {
						s.pubertyXX = 1;
					}
				}
			}
		});
		this.animal = animal;
		this.eggType = eggType;
		this.pregData = pregData;
	}
};

App.Medicine.OrganFarm.AnalWomb = class extends App.Medicine.OrganFarm.Organ {
	/**
	 * @param {string} type
	 * @param {string} name
	 * @param {string} eggType
	 * @param {string} pregData
	 * @param {boolean} animal
	 */
	constructor({type, name, eggType, pregData, animal} = {}) {
		super({
			type: type, name: name,
			tooltip: "the slave must not have female reproductive organs for successful implantation",
			cost: 20000, time: 10,
			canGrow: () => (V.arcologies[0].FSGenderRadicalistResearch === 1 && (!this.animal || V.animalMpreg > 0)),
			actions: [
				new App.Medicine.OrganFarm.AnalWombImplantAction({
					eggType: eggType,
					pregData: pregData,
					animal: animal
				})
			]
		});
		this.animal = animal;
	}
};