code:
:: Prosthetics Configuration [nobr]

<<set $AS = $activeSlave.ID>>

<<switch $prostheticsConfig>>

<<case "main">>
	<<set $nextButton = "Confirm changes", $nextLink = "Slave Interact">>
	/* get all prosthetics that are ready for this slave */
	<<if $adjustProstheticsCompleted > 0>>
		<<set $adjustProsthetics = $adjustProsthetics.filter(function(p) {
			if (p.workLeft <= 0 && p.slaveID == getSlave($AS).ID) {
				addProsthetic(getSlave($AS), p.id);
				$adjustProstheticsCompleted--;
				return false;
			}
			return true;
		})>>
	<</if>>

/* base screen START */

Prosthetic Configuration

This room is lined with shelves and cabinets; it could be easily mistaken for a storage room if it were not for the examination table in its center.

<<if hasBothLegs(getSlave($AS))>>
	<<= getSlave($AS).slaveName>> is obediently waiting for your instructions.
<<else>>
	<<= getSlave($AS).slaveName>> is lying on the table, waiting for your instructions.
<</if>>

<<if hasAnyCyberneticEyes(getSlave($AS))>>

Eyes

 /* tab works better with links */
	$He has <<if hasBothCyberneticEyes(getSlave($AS))>> ocular implants <<else>> an ocular implant <</if>> installed. You can change <<if hasBothCyberneticEyes(getSlave($AS))>>their<<else>>its<</if>> settings:

	<<set _on = 0, _blur = 0, _off = 0>>
	<<if getLeftEyeType(getSlave($AS)) === 3>>

Left:

		<<if getLeftEyeVision(getSlave($AS)) !== 2>>
			<<set _on++>>
			[["[ON]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "left", "fix")]]
		<<else>>
			<<print "[ON]">>
		<</if>>

		<<if getLeftEyeVision(getSlave($AS)) !== 1>>
			<<set _blur++>>
			[["[BLUR]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "left", "blur")]]
		<<else>>
			<<print "[BLUR]">>
		<</if>>

		<<if getLeftEyeVision(getSlave($AS)) !== 0>>
			<<set _off++>>
			[["[OFF]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "left", "blind")]]
		<<else>>
			<<print "[OFF]">>
		<</if>>

	<</if>>
	<<if getRightEyeType(getSlave($AS)) === 3>>

Right:

		<<if getRightEyeVision(getSlave($AS)) !== 2>>
			<<set _on++>>
			[["[ON]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "right", "fix")]]
		<<else>>
			<<print "[ON]">>
		<</if>>

		<<if getRightEyeVision(getSlave($AS)) !== 1>>
			<<set _blur++>>
			[["[BLUR]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "right", "blur")]]
		<<else>>
			<<print "[BLUR]">>
		<</if>>

		<<if getRightEyeVision(getSlave($AS)) !== 0>>
			<<set _off++>>
			[["[OFF]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "right", "blind")]]
		<<else>>
			<<print "[OFF]">>
		<</if>>

	<</if>>
	<<if hasBothCyberneticEyes(getSlave($AS))>>

Both:

		<<if _on > 0>>
			[["[ON]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "both", "fix")]]
		<<else>>
			<<print "[ON]">>
		<</if>>

		<<if _blur > 0>>
			[["[BLUR]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "both", "blur")]]
		<<else>>
			<<print "[BLUR]">>
		<</if>>

		<<if _off > 0>>
			[["[OFF]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "both", "blind")]]
		<<else>>
			<<print "[OFF]">>
		<</if>>

	<</if>>

	$He has <<print App.Desc.eyesColor(getSlave($AS))>>. To change $his eye color visit the [[auto salon|Salon][$primaryHairColor = "", $secondaryHairColor = "", $primaryEarColor = "", $secondaryEarColor = "", $primaryTailColor = "", $secondaryTailColor = "", $artificialEyeColor = "", $artificialEyeShape = "",$artificialEyeFill = ""]].

<</if>>

<<if getSlave($AS).earImplant == 1>>

Ears

	$He has cochlear implants installed.
	<<if getSlave($AS).hears == 0>>
		They are operating normally.
	<<elseif getSlave($AS).hears == -1>>
		They are set to muffle $his hearing.
	<<else>>
		They are turned off.
	<</if>>

	<<if getSlave($AS).hears != 0>>
		[[Restore hearing|Prosthetics Configuration][getSlave($AS).hears = 0, $prostheticsConfig = "hearing"]] |
	<</if>>
	<<if getSlave($AS).hears != -1>>
		[[Muffle|Prosthetics Configuration][getSlave($AS).hears = -1, $prostheticsConfig = "hearing"]]
		<<if getSlave($AS).hears != -2>>
			|
		<</if>>
	<</if>>
	<<if getSlave($AS).hears != -2>>
		[[Disable|Prosthetics Configuration][getSlave($AS).hears = -2, $prostheticsConfig = "hearing"]]
	<</if>>

<</if>>

<<if getSlave($AS).electrolarynx == 1>>

Voice

	$He has an electrolarynx installed.
	<<if getSlave($AS).voice == 0>>
		It is turned off.
	<<elseif getSlave($AS).voice == 1>>
		It is set to its "deep voice" setting.
	<<elseif getSlave($AS).voice == 2>>
		It is set to its "normal voice" setting.
	<<elseif getSlave($AS).voice == 3>>
		It is set to its "high voice" setting.
	<</if>>

	<<if getSlave($AS).voice != 0>>
		[[Disable|Prosthetics Configuration][getSlave($AS).voice = 0, $prostheticsConfig = "voice"]] |
	<</if>>
	<<if getSlave($AS).voice != 1>>
		[[Deep voice setting|Prosthetics Configuration][getSlave($AS).voice = 1, $prostheticsConfig = "voice"]] |
	<</if>>
	<<if getSlave($AS).voice != 2>>
		[[Standard voice setting|Prosthetics Configuration][getSlave($AS).voice = 2, $prostheticsConfig = "voice"]]
		<<if getSlave($AS).voice != 3>>
			|
		<</if>>
	<</if>>
	<<if getSlave($AS).voice != 3>>
		[[High voice setting|Prosthetics Configuration][getSlave($AS).voice = 3, $prostheticsConfig = "voice"]]
	<</if>>

<</if>>

Limbs

	<<= App.Desc.limbChange().selector(getSlave($AS), App.Desc.limbChange().currentLimbs(getSlave($AS)))>>

Tail

<<if getSlave($AS).PTail == 1>>

	$He has a neural tail interface installed. You can assign and adjust $his tail here.

	<<if getSlave($AS).tail != "none">>
		$He currently has a tail attached, if you wish to change it you will first need to detach it.

		[[Detach|Prosthetics Configuration][$prostheticsConfig = "detachTail",$nextButton = "Continue", $nextLink = "Prosthetics Configuration"]]

	<<else>>
		<<if isProstheticAvailable(getSlave($AS), "modT")>>

			Attach a modular tail designed to look like a:

			[[Cat's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "neko", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Dog's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "inu", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Fox's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "kit", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Kitsune's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "kitsune", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Tanuki's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "tanuki", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Cow's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "ushi", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Rabbit's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "usagi", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Squirrel's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "risu", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Horse's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "uma", getSlave($AS).tailColor = getSlave($AS).hColor]]

		<</if>>

		<<if isProstheticAvailable(getSlave($AS), "combatT")>>
			[[Attach Combat Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "combat", getSlave($AS).tailColor = "jet black"]]
			<<if isProstheticAvailable(getSlave($AS), "sexT")>>
				|
			<</if>>
		<</if>>
		<<if isProstheticAvailable(getSlave($AS), "sexT")>>
			[[Attach Pleasure Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "sex", getSlave($AS).tailColor = "pink"]]
		<</if>>

	<</if>>

<<else>>
	//$He does not have a neural tail interface installed so you cannot attach a tail.//
<</if>>
<<if getSlave($AS).tail == "mod">>

	$He currently has a modular tail, styled to look like
	<<if getSlave($AS).tailShape == "neko">>
		a long, slender cat tail.
	<<elseif getSlave($AS).tailShape == "inu">>
		a bushy dog tail.
	<<elseif getSlave($AS).tailShape == "kit">>
		a soft, fluffy fox tail.
	<<elseif getSlave($AS).tailShape == "kitsune">>
		three incredibly soft, fluffy fox tails.
	<<elseif getSlave($AS).tailShape == "tanuki">>
		a long, fluffy tanuki tail.
	<<elseif getSlave($AS).tailShape == "ushi">>
		a long cow tail.
	<<elseif getSlave($AS).tailShape == "usagi">>
		a short rabbit tail.
	<<elseif getSlave($AS).tailShape == "risu">>
		a large squirrel tail.
	<<elseif getSlave($AS).tailShape == "uma">>
		a long horse tail.
	<</if>>

	Modify $his tail's appearance:

	[[Cat|Prosthetics Configuration][getSlave($AS).tailShape = "neko", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Dog|Prosthetics Configuration][getSlave($AS).tailShape = "inu", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Fox|Prosthetics Configuration][getSlave($AS).tailShape = "kit", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Kitsune|Prosthetics Configuration][getSlave($AS).tailShape = "kitsune", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Tanuki|Prosthetics Configuration][getSlave($AS).tailShape = "tanuki", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Bovine|Prosthetics Configuration][getSlave($AS).tailShape = "ushi", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Rabbit|Prosthetics Configuration][getSlave($AS).tailShape = "usagi", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Squirrel|Prosthetics Configuration][getSlave($AS).tailShape = "risu", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Horse|Prosthetics Configuration][getSlave($AS).tailShape = "uma", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]

<</if>>

Prosthetics

//Fit prosthetics to $him://

''Buy and fit''

		<<if $researchLab.level > 0>>
			<<= App.UI.disabledLink(`''Construct in lab''`, ["Depending on lab speed, it might be faster than fitting an existing prosthetic but should almost always be faster than first building and then fitting it to $him."])>>
		<<else>>
			<<= App.UI.disabledLink(`''Construct in lab''`, ["With a lab you could both increase speed and decrease cost."])>>
		<</if>>

		<<if $researchLab.speed >= 300>> /* max speed */
			<<= App.UI.disabledLink(`''Fast assembly''`, ["Your lab is so fast that fitting prosthetics to your slave can done instantly though you will sacrifice some efficiency."])>>
		<<elseif $researchLab.level > 0>>
			<<= App.UI.disabledLink(`''Fast assembly''`, ["Your lab is not fast enough to fit prosthetics instantly."])>>
		<</if>>

<<for _p range setup.prostheticIDs>>
	<<if _p != "erectile">> /* exclude erectile implant */

<<= capFirstChar(setup.prosthetics[_p].name)>>

		<<if $adjustProsthetics.findIndex(function(p) {return p.id == _p && p.slaveID == getSlave($AS).ID}) != -1 || $researchLab.tasks.findIndex(function(p) {return p.type == "craftFit" && p.id == _p && p.slaveID == getSlave($AS).ID}) != -1>>

//Currently being fitted to $him.//

		<<elseif setup.prosthetics[_p].level > $prostheticsUpgrade>>

//Better contracts are needed to buy this.//

		<<elseif isProstheticAvailable(getSlave($AS), _p)>>

//Completed.//

		<<else>>
			<<capture _p>>

			<<if $prosthetics[_p].amount > 0>>
				<<link "From storage" "Prosthetics Configuration">>
					<<set $adjustProsthetics.push({id: _p, workLeft: setup.prosthetics[_p].adjust, slaveID: getSlave($AS).ID}), $prosthetics[_p].amount -= 1>>
				<</link>>
			<<else>>
				<<link "<<= cashFormat(setup.prosthetics[_p].costs)>>" "Prosthetics Configuration">>
					<<set $adjustProsthetics.push({id: _p, workLeft: setup.prosthetics[_p].adjust, slaveID: getSlave($AS).ID}), cashX(forceNeg(setup.prosthetics[_p].costs), "slaveMod", getSlave($AS))>>
				<</link>>
			<</if>>

			<<if $prosthetics[_p].research > 0>>

			<<if $researchLab.level > 0 && $prosthetics[_p].research > 0>>
				<<link "Construct" "Prosthetics Configuration">>
					<<set $researchLab.tasks.push({
						type: "craftFit",
						id: _p,
						workLeft: (setup.prosthetics[_p].adjust + setup.prosthetics[_p].craft) / 1.5,
						slaveID: $AS})>>
					/* 1.5: longer than adjust, but faster than adjust+craft. */
				<</link>>
			<</if>>

			<<if $researchLab.speed >= 300 && $prosthetics[_p].research > 0>> /* max speed */
			<<if $prosthetics[_p].amount > 0>>
				<<link "From storage: <<= cashFormat(setup.prosthetics[_p].adjust * 50)>>" "Prosthetics Configuration">>
					<<set cashX(forceNeg(setup.prosthetics[_p].costs * 1.5), "slaveMod", getSlave($AS)), addProsthetic(getSlave($AS), _p)>>
				<</link>>
			<<else>>
				<<link "<<= cashFormat(setup.prosthetics[_p].costs + setup.prosthetics[_p].adjust * 100)>>" "Prosthetics Configuration">>
					<<set cashX(forceNeg(setup.prosthetics[_p].costs + setup.prosthetics[_p].adjust * 100), "slaveMod", getSlave($AS)), addProsthetic(getSlave($AS), _p)>>
				<</link>>
			<</if>>
			<</if>>

			<<elseif $researchLab.level > 0>>

				//Not researched.//

			<</if>>
			<</capture>>
		<</if>>
	<</if>>
<</for>>

/* base screen END */

/*
<<case "eyes">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	<<if getSlave($AS).eyes == 1>>
		$He blinks as $his vision returns.
	<<elseif getSlave($AS).eyes == -1>>
		$He squints at you as $his vision becomes a blur.
	<<else>>
		$He has a panicked expression when $his vision suddenly goes out.
	<</if>>
*/

<<case "limbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	<<= App.Desc.limbChange().reaction(getSlave($AS), $oldLimbs)>>
	<<unset $oldLimbs>>

/*
<<case "basicPLimbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Attaching $his limbs is a simple procedure, you simply push a connector on each limb into the socket in $his implants until the lock engages.<<if getSlave($AS).PLimb == 2>> $He jumps a bit as limbs connect to $his nerves.<</if>>
	<<if getSlave($AS).fetish != "mindbroken" && getSlave($AS).fuckdoll == 0>>
		<<if getSlave($AS).devotion > 20>>
			$He's overwhelmed with gratitude and thanks you profusely the first chance $he gets. $He follows the acclimation program diligently, doing $his best to learn how to be a good slave despite, or sometimes even because of, $his artificial arms and legs.
		<<elseif getSlave($AS).devotion >= -20>>
			$He's overwhelmed with gratitude in part because $he didn't think you'd do something like this for $him. $He thanks you profusely the first chance $he gets, and follows the acclimation program diligently, trying to deserve the expense you went to.
		<<else>>
			Despite $his hatred of you, $he can't help but notice that you clearly have a plan for $him that involves putting a good deal of value into $him. Your goals might not be $hers, but at least $he has an indication that you're not toying with $him.
		<</if>>
	<</if>>

<<case "sexPLimbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Attaching $his limbs is a simple procedure, you simply push a connector on each limb into the socket in $his implants until the lock engages.<<if getSlave($AS).PLimb == 2>> $He jumps a bit as limbs connect to $his nerves.<</if>>
	While exiting the prosthetic lab $he is experimenting with $his new arms and legs.
	<<if getSlave($AS).fetish != "mindbroken" && getSlave($AS).fuckdoll == 0>>
		<<if getSlave($AS).devotion <= 20>>
			$He rapidly discovers that $his fingertips are now vibrators, and then makes a mess when $he figures out that $his hands can dispense lube without figuring out how to make them stop dispensing lube. $He's frustrated and frightened, realizing that even $his prosthetics are now customized to suit $his purpose as a human sex toy. $He knew $he was a toy before, but somehow, being a literal vibrator is a bit much for $him.
		<<elseif getSlave($AS).energy > 95>>
			Since $he's a nympho, $he discovers $his new sexual functions in a hurry. They trigger in part is based on arousal, and $he's never not aroused, so they activate one by one as $he leaves the surgery. The vibration, lube, and other dirty functions surprise $him, and it takes $him a moment to realize what's going on, but $he begins to breathe hard when $he understands.
		<<else>>
			$He discovers $his sexy new functions one by one. The vibration, lube, and other dirty functions surprise $him, and it takes $him a moment to realize what's going on, but $he begins to shake with amusement when $he understands. $He heads off to try them out.
		<</if>>
	<</if>>

<<case "beautyPLimbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Attaching $his limbs is a simple procedure, you simply push a connector on each limb into the socket in $his implants until the lock engages.<<if getSlave($AS).PLimb == 2>> $He jumps a bit as limbs connect to $his nerves.<</if>> $He exits the prosthetic lab <<if canSee(getSlave($AS))>>marveling at the beautiful, natural appearance of $his new arms and legs<<else>>thanking you for $his new arms and legs, unaware of how natural they look<</if>>.
	<<if getSlave($AS).fetish != "mindbroken" && getSlave($AS).fuckdoll == 0>>
		<<if getSlave($AS).devotion <= 20>>
			If $he doubts that you have some sort of long term plan for $him, all $he has to do is <<if canSee(getSlave($AS))>>look down and examine<<else>>feel<</if>> $his elegant, natural prosthetics, which are often mistaken for the genuine article. Even $he makes the mistake at times as $he gets used to them.
		<<elseif getSlave($AS).skill.entertainment >= 100>>
			Since $he's a masterful entertainer, $he knows multiple styles of dance, though $his straightforward modern prosthetics never allowed $him to be anything more than a mechanically competent dancer. $He finds that $he has far better balance now, in addition to looking more natural. Before long, $he goes //en pointe// and holds the position, before collapsing in a heap. It soon becomes apparent that this wasn't due to clumsiness: $he's sobbing so hard $he can barely breathe. $He thanks you profusely the next time $he sees you, eyes still puffy with tears of joy.
		<<else>>
			When $he first <<if canSee(getSlave($AS))>>catches sight of $himself in a mirror<<else>>runs a new finger over $his natural feeling skin<</if>>, $he begins to cry. Terribly complex emotions war across $his face: gratitude, joy, regret, and something undefinable. Blinking, $he uses newly elegant fingertips to trace the scarcely visible seams where $his artificial and natural skin meet. $He thanks you profusely the next time $he sees you, eyes still puffy with tears.
		<</if>>
	<</if>>

<<case "combatPLimbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Attaching $his limbs is a simple procedure, you simply push a connector on each limb into the socket in $his implants until the lock engages.<<if getSlave($AS).PLimb == 2>> $He jumps a bit as limbs connect to $his nerves.<</if>> While exiting the prosthetic lab $he is wondering over the bulky <<if canSee(getSlave($AS))>>appearance<<else>>weight<</if>> of $his reinforced arms and legs.
	<<if getSlave($AS).fetish != "mindbroken" && getSlave($AS).fuckdoll == 0>>
		<<if getSlave($AS).devotion <= 20>>
			$He's frightened, once $he discovers what $he can do, and what $he is. $His integral weapons are locked out by the arcology systems, for now, but $he quickly realizes what they are. $He is not, to say the least, thrilled by the revelation that $he is now a living weapon, and is kept awake by thoughts of what you might be planning for $him.
		<<elseif (getSlave($AS).skill.combat == 1) && (getSlave($AS).devotion > 75)>>
			$He leaves the prosthetic lab with a purpose, $his footsteps a bit heavier than before. $He heads down to the armory's range, still naked, and when $he gets there, $he places $his dominant hand over $his thigh on that side. It folds open, revealing a handgun, which $he draws and empties into a <<if canSee(getSlave($AS))>>target<<else>>beeping target<</if>>; as $he fires the last rounds, $he uses $his off hand to reach down to that thigh, which folds open and reveals spare magazines. $He knows that $his prosthetics are a wash, at best, in terms of actual combat effectiveness; they'll never match the reliability and dexterity of the genuine article. But $he thinks they are //cool.//
		<<else>>
			$He has mixed feelings about what $he soon discovers. $He's a living weapon now, and has to live with the constant knowledge that $he can incapacitate or kill with nothing more than what's contained within $his arms and legs. $He's touched, though, by the tremendous trust this shows. $He knows that the arcology would instantly lock out $his weapons if $he were to misbehave, but $he's still affected.
		<</if>>
	<</if>>

<<case "cyberPLimbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Attaching $his limbs is a simple procedure, you simply push a connector on each limb into the socket in $his implants until the lock engages.<<if getSlave($AS).PLimb == 2>> $He jumps a bit as limbs connect to $his nerves.<</if>> $He exits the prosthetic lab marveling <<if canSee(getSlave($AS))>>at the shiny artificial skin of $his new arms and legs<<else>>at the feel of the artificial skin of $his new arms and legs under $his new fingers<</if>>.
	<<if getSlave($AS).fetish != "mindbroken" && getSlave($AS).fuckdoll == 0>>
		<<if getSlave($AS).devotion <= 20>>
			$He's frightened, once $he discovers what $he can do, and what $he is. $His cybernetic limbs are restricted by the arcology systems, for now, but $he quickly realizes what they are. $He is not, to say the least, thrilled by the revelation that $he is now a living weapon, and is kept awake by thoughts of what you might be planning for $him.
		<<elseif (getSlave($AS).skill.combat == 1) && (getSlave($AS).devotion > 75)>>
			$He leaves the surgery with a purpose, $his footsteps a bit heavier than before. $He heads down to the armory's range, still naked, and when $he gets there, $he places $his dominant hand over $his thigh on that side. It folds open, revealing a handgun, which $he draws and empties into a <<if canSee(getSlave($AS))>>target<<else>>beeping target<</if>>; as $he fires the last rounds, $he uses $his off hand to reach down to that thigh, which folds open and reveals spare magazines. $He knows that $his prosthetics will enhance $his combat effectiveness and $he thinks they are //cool.//
		<<else>>
			$He has mixed feelings about what $he soon discovers. $He's a living weapon now, and has to live with the constant knowledge that $he can incapacitate or kill with nothing more than $his arms and legs themselves. $He's touched, though, by the tremendous trust this shows. $He knows that the arcology would instantly lock out $his limbs if $he were to misbehave, but $he's still affected.
		<</if>>
	<</if>>

<<case "removeLimbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Due to built-in safeties it is necessary to remove each limb separately, first releasing the lock and then waiting for automated seal release.

	<<if (getSlave($AS).devotion > 20)>>
		You instruct $him to lie down on the table and proceed to remove $his limbs. $He <<if canSee(getSlave($AS))>>watches<<elseif canHear(getSlave($AS))>>listens<<else>>waits<</if>> with interest as you work.<<if (getSlave($AS).devotion > 50)>> As you remove the last limb $he playfully wiggles $his stumps at you.<</if>>
	<<else>>
		You order $him to lie down on the table and proceed to remove $his limbs. $He <<if canSee(getSlave($AS))>>watches<<elseif canHear(getSlave($AS))>>listens<<else>>waits<</if>> with a bitter expression as you work.
	<</if>>
*/

<<case "hearing">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	<<if getSlave($AS).hears == 0>>
		$He tilts $his head as $his hearing returns.
	<<elseif getSlave($AS).hears == -1>>
		$He shakes $his head as $his hearing becomes muffled.
	<<else>>
		$He has a panicked expression when $his hearing is suddenly silenced.
	<</if>>

<<case "voice">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	<<if getSlave($AS).voice == 0>>
		$He tries testing out $his new voice, only to discover $he's been made mute.
	<<elseif getSlave($AS).voice == 1>>
		$He tests out the <<if canHear(getSlave($AS))>>sound<<else>>feeling<</if>> of $his new, deep voice.
	<<elseif getSlave($AS).voice == 2>>
		$He tests out the <<if canHear(getSlave($AS))>>sound<<else>>feeling<</if>> of $his new, normal voice.
	<<elseif getSlave($AS).voice == 3>>
		$He tests out the <<if canHear(getSlave($AS))>>sound<<else>>feeling<</if>> of $his new, high voice.
	<</if>>

<<case "detachTail">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	<<set getSlave($AS).tail = "none", getSlave($AS).tailShape = "none", getSlave($AS).tailColor = "none">>
	You send the release signal and the mechanical lock disengages allowing the artificial tail to pop right off.

<<case "attachTail">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Attaching $his tail is a simple procedure, you simply push the connector into a socket, right where $his tailbone ends, until the lock engages.

	When you are done, $he looks back and
	<<if getSlave($AS).tailShape == "neko">>sways $his tail side to side enigmatically.
	<<elseif getSlave($AS).tailShape == "inu">>wags $his tail side to side energetically.
	<<elseif getSlave($AS).tailShape == "kit">>slowly sways $his tail feeling the soft fur brush against $his skin.
	<<elseif getSlave($AS).tailShape == "kitsune">>slowly sways $his tails luxuriating in the incredibly soft, fluffy fur brushing against $his skin.
	<<elseif getSlave($AS).tailShape == "tanuki">>admires $his long, thick fluffy tail.
	<<elseif getSlave($AS).tailShape == "ushi">>swats $himself playfully.
	<<elseif getSlave($AS).tailShape == "usagi">>wiggles $his little tail a bit.
	<<elseif getSlave($AS).tailShape == "risu">>admires $his the size of $his fluffy tail.
	<<elseif getSlave($AS).tailShape == "uma">>sways $his tail back and forth.
	<<elseif getSlave($AS).tail == "combat">>experimentally whips the long tail side to side then takes aim at a prepared fruit, lashes out with blinding speed and smiles as it explodes into chunks.
	<<elseif getSlave($AS).tail == "sex">>accidentally engages the vibrating and lube functions, startling $him and making quite a mess.
	<<else>>admires $his new tail.
	<</if>>

/*
<<case "interface">>

	<<set _first = 1>>
	/*TODO save .legsTat and .armsTat / link them to prosthetic*/
/*	<<if getLeftArmID(getSlave($AS)) !== 2 && isProstheticAvailable(getSlave($AS), "basicL")) != -1>>
		<<if _first>>

Since you already have prepared limbs for $him you might as well attach them while you are working on $him:

			<<set _first = 0>>
		<</if>>
		<<link "Attach <<= addA(setup.prosthetics.basicL.name)>>">>
			<<set removeLimbs(getSlave($AS), "all"), attachLimbs(getSlave($AS), "all", 2), $prostheticsConfig = "basicPLimbs">>
			<<replace #attach>>

<<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
		<</link>>

	<</if>>
	<<if getLeftArmID(getSlave($AS)) !== 3 && isProstheticAvailable(getSlave($AS), "sexL"))>>
		<<if _first>>

Since you already have prepared limbs for $him you might as well attach them while you are working on $him:

			<<set _first = 0>>
		<</if>>
		<<link "Attach <<= addA(setup.prosthetics.sexL.name)>>">>
			<<set removeLimbs(getSlave($AS), "all"), attachLimbs(getSlave($AS), "all", 3), $prostheticsConfig = "sexPLimbs">>
			<<replace #attach>>

<<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
		<</link>>

	<</if>>
	<<if getLeftArmID(getSlave($AS)) !== 4 && isProstheticAvailable(getSlave($AS), "beautyL")>>
		<<if _first>>

Since you already have prepared limbs for $him you might as well attach them while you are working on $him:

			<<set _first = 0>>
		<</if>>
		<<link "Attach <<= addA(setup.prosthetics.beautyL.name)>>">>
			<<set removeLimbs(getSlave($AS), "all"), attachLimbs(getSlave($AS), "all", 4), $prostheticsConfig = "beautyPLimbs">>
			<<replace #attach>>

<<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
		<</link>>

	<</if>>
	<<if getLeftArmID(getSlave($AS)) !== 5 && isProstheticAvailable(getSlave($AS), "combatL")>>
		<<if _first>>

Since you already have prepared limbs for $him you might as well attach them while you are working on $him:

			<<set _first = 0>>
		<</if>>
		<<link "Attach <<= addA(setup.prosthetics.combatL.name)>>">>
			<<set removeLimbs(getSlave($AS), "all"), attachLimbs(getSlave($AS), "all", 5), $prostheticsConfig = "combatPLimbs">>
			<<replace #attach>>

<<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
		<</link>>

	<</if>>
	<<if getLeftArmID(getSlave($AS)) !== 6 && isProstheticAvailable(getSlave($AS), "cyberneticL")>>
		<<if getSlave($AS).PLimb == 2>>
			<<if _first>>

Since you already have prepared limbs for $him you might as well attach them while you are working on $him:

				<<set _first = 0>>
			<</if>>
			<<link "Attach <<= addA(setup.prosthetics.cyberneticL.name)>>" "Prosthetics Configuration">>
				<<set removeLimbs(getSlave($AS), "all"), attachLimbs(getSlave($AS), "all", 6), $prostheticsConfig = "cyberPLimbs">>
				<<replace #attach>>

<<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
			<</link>>
		<</if>>
	<</if>>

*/
<</switch>>

repo_name: KnightBoulegard/fc

license: mit


code:
:: Prosthetic Lab [nobr jump-to-safe jump-from-safe]

<<set $nextButton = "Back", $nextLink = "Manage Penthouse">>

<<set $researchLab.speed = (($researchLab.hired * 3) + $researchLab.menials) * $researchLab.aiModule>>

Prosthetic Lab

<<if $adjustProsthetics.length > $adjustProstheticsCompleted>>

External contract workers

	Currently adjusting these prosthetics:
	<<for _p range $adjustProsthetics>>
		<<if _p.workLeft > 0>>

				<<= capFirstChar(setup.prosthetics[_p.id].name)>> for <<= SlaveFullName($slaves[$slaveIndices[_p.slaveID]])>>

		<</if>>
	<</for>>
<</if>>

<<if $researchLab.level > 0>>

Research Department

	//You switch one of the screens in your office to the feed from your research facility.//

Personnel

	<<if $researchLab.aiModule == 1>>

			[[Buy and install research module|Prosthetic Lab][cashX(forceNeg(35000*$upgradeMultiplierArcology), "capEx"), $researchLab.aiModule = 2]] //This module enables your personal assistant to assist staff and direct menials assigned to your research facility, increasing efficiency. It costs <<= cashFormat(35000*$upgradeMultiplierArcology)>>//

	<</if>>
	<<if ($researchLab.hired + $researchLab.menials) == 0>>
		//Facility is currently unstaffed.//
	<<else>>
		//You have
		<<if $researchLab.hired == 1>>
			one scientist
		<<elseif $researchLab.hired > 1>>
			$researchLab.hired scientists
		<</if>>
		<<if $researchLab.hired > 0 && $researchLab.menials > 0 >> and<</if>>
		<<if $researchLab.menials == 1>>
			one menial slave
		<<elseif $researchLab.menials > 1>>
			$researchLab.menials menials
		<</if>>
		working in your lab.
			<<setAssistantPronouns>>
			<<if $researchLab.aiModule > 1>>Occasionally you hear the voice of your assistant as _heA helps direct and organize work.<</if>>//
	<</if>>

	Currently, this facility can employ $researchLab.maxSpace people.
	<<if $researchLab.maxSpace == 5>>
		[[Expand facility|Prosthetic Lab][cashX(forceNeg(Math.trunc(5000*$upgradeMultiplierArcology)), "capEx"), $researchLab.maxSpace = 10]]
		//Costs <<= cashFormat(Math.trunc(5000*$upgradeMultiplierArcology))>>//
	<<elseif $researchLab.maxSpace == 10>>
		[[Expand facility|Prosthetic Lab][cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierArcology)), "capEx"), $researchLab.maxSpace = 20]]
		//Costs <<= cashFormat(Math.trunc(10000*$upgradeMultiplierArcology))>>//
	<<elseif $researchLab.maxSpace == 20>>
		[[Expand facility|Prosthetic Lab][cashX(forceNeg(Math.trunc(15000*$upgradeMultiplierArcology)), "capEx"), $researchLab.maxSpace = 30]]
		//Costs <<= cashFormat(Math.trunc(15000*$upgradeMultiplierArcology))>>//
	<<elseif $researchLab.maxSpace == 30>>
		[[Expand facility|Prosthetic Lab][cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "capEx"), $researchLab.maxSpace = 40]]
		//Costs <<= cashFormat(Math.trunc(20000*$upgradeMultiplierArcology))>>//
	<<elseif $researchLab.maxSpace == 40>>
		[[Expand facility|Prosthetic Lab][cashX(forceNeg(Math.trunc(25000*$upgradeMultiplierArcology)), "capEx"), $researchLab.maxSpace = 50]]
		//Costs <<= cashFormat(Math.trunc(25000*$upgradeMultiplierArcology))>>//
	<<elseif $researchLab.maxSpace == 50>>
		//Facility is fully expanded.//
	<</if>>

	<<if ($researchLab.hired + $researchLab.menials) < $researchLab.maxSpace>>

		Hire [[x1|Prosthetic Lab][$researchLab.hired += 1,cashX(forceNeg(2000), "labScientistsTransfer")]]
		<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 5>>
			| [[x5|Prosthetic Lab][$researchLab.hired += 5,cashX(forceNeg(10000), "labScientistsTransfer")]]
		<</if>>
		<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 10>>
			| [[x10|Prosthetic Lab][$researchLab.hired += 10,cashX(forceNeg(10000), "labScientistsTransfer")]]
		<</if>>
		scientists.

		//Each scientist will require an initial fee of <<= cashFormat(2000)>> and incur <<= cashFormat(300)>> weekly.//

		<<if $menials > 0>>
			Assign [[x1|Prosthetic Lab][$researchLab.menials += 1,$menials -= 1]]
			<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 5 && $menials >= 5>>
				| [[x5|Prosthetic Lab][$researchLab.menials += 5,$menials -= 5]]
			<</if>>
			<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 10 && $menials >= 10>>
				| [[x10|Prosthetic Lab][$researchLab.menials += 10,$menials -= 10]]
			<</if>>
			menial slaves to lab.
		<<else>>
			You do not own any <<if $researchLab.menials != 0>>unassigned <</if>>menial slaves.
		<</if>>

		//Using menial slaves is much cheaper than hiring scientists, but they are less effective. <<= cashFormat(100)>> per slave each week.//

	<<else>>

//Facility is fully staffed.//

	<</if>>

	<<if $researchLab.hired > 0>>

		Fire [[x1|Prosthetic Lab][$researchLab.hired -= 1]]
		<<if $researchLab.hired >= 5>>
			| [[x5|Prosthetic Lab][$researchLab.hired -= 5]]
		<</if>>
		<<if $researchLab.hired >= 10>>
			| [[x10|Prosthetic Lab][$researchLab.hired -= 10]]
		<</if>>
		| [[All|Prosthetic Lab][$researchLab.hired = 0]]
		scientists.

	<</if>>
	<<if $researchLab.menials > 0>>

		Dismiss [[x1|Prosthetic Lab][$researchLab.menials -= 1,$menials += 1]]
		<<if $researchLab.menials >= 5>>
			| [[x5|Prosthetic Lab][$researchLab.menials -= 5,$menials += 5]]
		<</if>>
		<<if $researchLab.menials >= 10>>
			| [[x10|Prosthetic Lab][$researchLab.menials -= 10,$menials += 10]]
		<</if>>
		| [[All|Prosthetic Lab][$menials += $researchLab.menials, $researchLab.menials = 0]]
		menial slaves.

	<</if>>

Tasks

	<<if $researchLab.tasks.length > 0>>
		<<set _j = 0>>
		<<if $researchLab.speed > 0>>
			The following tasks are queued:
		<<else>>
			You have projects planned but without researchers you won't be able to work on them:
		<</if>>

		<<for _i = 0; _i < $researchLab.tasks.length; _i++>>

			<<switch $researchLab.tasks[_i].type>>
			<<case "research">>
				You <<if _i == 0>>are researching<<else>> plan to research<</if>>
			<<case "craft">>
				You <<if _i == 0>>are constructing<<else>> plan to construct<</if>>
			<<case "craftFit">>
				For @@.noteworthy;<<= SlaveFullName($slaves[$slaveIndices[$researchLab.tasks[_i].slaveID]])>>@@ you <<if _i == 0>>are constructing<<else>> plan to construct<</if>>
			<<default>>
				@@.error;Error: Unknown $researchLab.tasks[].type: $researchLab.tasks[_i].type@@
			<</switch>>
			<<set _j += $researchLab.tasks[_i].workLeft>>
			@@.noteworthy;<<= capFirstChar(setup.prosthetics[$researchLab.tasks[_i].id].name)>>@@.
			<<if $researchLab.speed > 0>>
				Finished in approximately <<= (Math.floor(_j / $researchLab.speed) + 1)>> week(s).
			<</if>>

			<<if $researchLab.tasks[_i].type == "research">>
				<<set _link = "Cancel: Will not return investments.">>
			<<else>>
				<<set _link = "Cancel">>
			<</if>>
			<<capture _i>>
				<<link _link "Prosthetic Lab">>
					<<if $researchLab.tasks[_i].type == "research">>
						<<set $prosthetics[$researchLab.tasks[_i].id].research = 0>>
					<</if>>
					<<set $researchLab.tasks.deleteAt(_i)>>
				<</link>>
			<</capture>>

		<</for>>
	<<else>>
		//Currently the research lab has no tasks planned.//
	<</if>>

Research

	Available research projects:
	<<for _p range setup.prostheticIDs>>
		<<if $prosthetics[_p].research == 0>>
			<<if _p != "erectile">> /*excludes erectile*/

			<<if setup.prosthetics[_p].level <= $prostheticsUpgrade>>
				<<capture _p>>
				<<link "Reverse engineer <<= addA(setup.prosthetics[_p].name)>>" "Prosthetic Lab">>
					<<set cashX(forceNeg(setup.prosthetics[_p].costs), "labResearch"), $prosthetics[_p].research = -1, $researchLab.tasks.push({type: "research", id: _p, workLeft: setup.prosthetics[_p].research})>>
				<</link>>
				<</capture>>
					//Costs <<= cashFormat(setup.prosthetics[_p].costs)>> of initial investment.//
			<<else>>
				//You need better contracts to get the required research material for reverse engineering <<= addA(setup.prosthetics[_p].name)>>.//
			<</if>>

			<</if>>
		<</if>>
	<</for>>

Manufacture

	Available building projects:
	<<for _p range setup.prostheticIDs>>
		<<if $prosthetics[_p].research == 1>>
			<<if _p != "erectile">> /*excludes erectile*/

			<<capture _p>>
			<<link "Build <<= addA(setup.prosthetics[_p].name)>>" "Prosthetic Lab">>
				<<set $researchLab.tasks.push({type: "craft", id: _p, workLeft: setup.prosthetics[_p].craft})>>
			<</link>>
			<</capture>>

			<</if>>
		<</if>>
	<</for>>

Prepared prosthetics

		<<= getProstheticsStockpile()>>

<</if>>