code:
:: Research Lab [nobr]

<<switch $temp>>

<<case 0>>

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

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

[[Decommission facility|Manage Arcology][$researchLab.built = "false",$researchLab.hired = 0,$menials += $researchLab.menials,$researchLab.menials = 0,$researchLab.research = "none",$researchLab.manufacture = "none",$researchLab.productionTime = 0]] //Warning! This will cancel all projects, remove all staff and shut down this facility.//

[[Purchase cybernetics|Research Lab][$temp = 1]]

	__Personnel__

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

	<</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.menials != 0>> and<</if>>
		<<if $researchLab.menials == 0>>
		<<elseif $researchLab.menials == 1>>
			one menial slave
		<<elseif $researchLab.menials > 1>>
			$researchLab.menials menials
		<</if>>
		working in your lab.
			<<if $researchLab.aiModule != 0>>Occasionally you hear voice of your assistant as it helps direct and organize work.<</if>>//
	<</if>>

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

	<<if ($researchLab.hired + $researchLab.menials) < $researchLab.maxSpace>>
		Hire [[x1|Research Lab][$researchLab.hired += 1,cashX(-5000, "lab")]]
		<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 5>>
			| [[x5|Research Lab][$researchLab.hired += 5,cashX(-25000, "lab")]]
		<</if>>
		<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 10>>
			| [[x10|Research Lab][$researchLab.hired += 10,cashX(-50000, "lab")]]
		<</if>>
		scientists.

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

		<<if $menials > 0>>
			Assign [[x1|Research Lab][$researchLab.menials += 1,$menials -= 1]]
			<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 5 && $menials >= 5>>
				| [[x5|Research Lab][$researchLab.menials += 5,$menials -= 5]]
			<</if>>
			<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 10 && $menials >= 10>>
				| [[x10|Research 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. <<print cashFormat(100)>> per slave each week.//

	<<else>>
		   //Facility is fully staffed.//
	<</if>>

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

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

	__Research__

	<<if $researchLab.research != "none">>
		//Your lab staff is currently researching @@.yellow;$researchLab.research@@.//

		[[Cancel Research|Research Lab][$researchLab.productionTime = 0,$researchLab.research = "none"]]
	<<elseif $researchLab.manufacture != "none">>
		//Your lab staff is currently busy with other projects.//
	<<else>>
		//No research active.//

		<<if $researchLab.basicPLimbInterface == 0 && $stockpile.basicPLimbInterface > 0>>

			[[Reverse engineer basic prosthetics interface|Research Lab][$researchLab.productionTime = 80,$researchLab.research = "Basic prosthetics interface"]]
		<</if>>
		<<if $researchLab.basicPLimbInterface != 0 && $researchLab.advPLimbInterface == 0 && $stockpile.advPLimbInterface > 0>>

			[[Reverse engineer advanced prosthetics interface|Research Lab][$researchLab.productionTime = 120,$researchLab.research = "Advanced prosthetics interface"]]
		<</if>>
		<<if $researchLab.basicPLimb == 0 && $stockpile.basicPLimb > 0>>

			[[Reverse engineer basic prosthetic limbs|Research Lab][$researchLab.productionTime = 80,$researchLab.research = "Basic prosthetic limbs"]]
		<</if>>
		<<if $researchLab.advSexPLimb == 0 && $stockpile.advSexPLimb > 0>>

			[[Reverse engineer advanced sex limbs|Research Lab][$stockpile.advSexPLimb -= 1,$researchLab.productionTime = 100,$researchLab.research = "Advanced sex limbs"]]
		<</if>>
		<<if $researchLab.advGracePLimb == 0 && $stockpile.advGracePLimb > 0>>

			[[Reverse engineer advanced beauty limbs|Research Lab][$stockpile.advGracePLimb -= 1,$researchLab.productionTime = 100,$researchLab.research = "Advanced beauty limbs"]]
		<</if>>
		<<if $researchLab.advCombatPLimb == 0 && $stockpile.advCombatPLimb > 0>>

			[[Reverse engineer advanced combat limbs|Research Lab][$stockpile.advCombatPLimb -= 1,$researchLab.productionTime = 100,$researchLab.research = "Advanced combat limbs"]]
		<</if>>
		<<if $researchLab.cyberneticPLimb == 0 && $researchLab.advPLimbInterface == 1 && ($researchLab.advSexPLimb + $researchLab.advGracePLimb + $researchLab.advCombatPLimb) >= 1>>

			[[Develop cybernetic limbs|Research Lab][$researchLab.productionTime = 300,$researchLab.research = "Cybernetic limbs"]]
		<</if>>
		<<if $researchLab.ocularImplant == 0 && $stockpile.ocularImplant > 0>>

			[[Reverse engineer ocular implants|Research Lab][$stockpile.ocularImplant -= 1,$researchLab.productionTime = 100,$researchLab.research = "Ocular implants"]]
		<</if>>
		<<if $researchLab.cochlearImplant == 0 && $stockpile.cochlearImplant > 0>>

			[[Reverse engineer cochlear implants|Research Lab][$stockpile.cochlearImplant -= 1,$researchLab.productionTime = 80,$researchLab.research = "Cochlear implants"]]
		<</if>>
		<<if $researchLab.electrolarynx == 0 && $stockpile.electrolarynx > 0>>

			[[Reverse engineer electrolarynx|Research Lab][$stockpile.electrolarynx -= 1,$researchLab.productionTime = 80,$researchLab.research = "Electrolarynx"]]
		<</if>>
		/*<<if $researchLab.erectileImplant == 0 && $stockpile.erectileImplant > 0>>

			[[Reverse engineer erectile implant|Research Lab][$stockpile.erectileImplant -= 1,$researchLab.productionTime = 100,$researchLab.research = "Erectile implant"]]
		<</if>>*/
	<</if>>

	__Manufacture__

	<<if $researchLab.research != "none">>
		//Your lab staff is currently busy with research.//
	<<elseif $researchLab.manufacture != "none">>
		//Your lab staff is currently building @@.yellow;$researchLab.manufacture@@.//
		[[Cancel Project|Research Lab][$researchLab.productionTime = 0,$researchLab.manufacture = "none"]]
	<<else>>
		//No projects currently active.//

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

			[[Build basic prosthetics interface|Research Lab][$researchLab.productionTime = 50,$researchLab.manufacture = "Basic prosthetics interface"]] // Currently have: $stockpile.basicPLimbInterface//
		<</if>>
		<<if $researchLab.advPLimbInterface == 1>>

			[[Build advanced prosthetics interface|Research Lab][$researchLab.productionTime = 80,$researchLab.manufacture = "Advanced prosthetics interface"]] // Currently have: $stockpile.advPLimbInterface//
		<</if>>
		<<if $researchLab.basicPLimb == 1>>

			[[Build basic prosthetic limbs|Research Lab][$researchLab.productionTime = 20,$researchLab.manufacture = "Basic prosthetic limbs"]] // Currently have: $stockpile.basicPLimb//
		<</if>>
		<<if $researchLab.advSexPLimb == 1>>

			[[Build advanced sex limbs|Research Lab][$researchLab.productionTime = 100,$researchLab.manufacture = "Advanced sex limbs"]] // Currently have: $stockpile.advSexPLimb//
		<</if>>
		<<if $researchLab.advGracePLimb == 1>>

			[[Build advanced beauty limbs|Research Lab][$researchLab.productionTime = 100,$researchLab.manufacture = "Advanced beauty limbs"]] // Currently have: $stockpile.advGracePLimb//
		<</if>>
		<<if $researchLab.advCombatPLimb == 1>>

			[[Build advanced combat limbs|Research Lab][$researchLab.productionTime = 100,$researchLab.manufacture = "Advanced combat limbs"]] // Currently have: $stockpile.advCombatPLimb//
		<</if>>
		<<if $researchLab.cyberneticPLimb == 1>>

			[[Build cybernetic limbs|Research Lab][$researchLab.productionTime = 150,$researchLab.manufacture = "Cybernetic limbs"]] // Currently have: $stockpile.cyberneticPLimb//
		<</if>>
		<<if $researchLab.ocularImplant == 1>>

			[[Build ocular implants|Research Lab][$researchLab.productionTime = 80,$researchLab.manufacture = "Ocular implants"]] // Currently have: $stockpile.ocularImplant//
		<</if>>
		<<if $researchLab.cochlearImplant == 1>>

			[[Build cochlear implants|Research Lab][$researchLab.productionTime = 60,$researchLab.manufacture = "Cochlear implants"]] // Currently have: $stockpile.cochlearImplant//
		<</if>>
		<<if $researchLab.electrolarynx == 1>>

			[[Build electrolarynx|Research Lab][$researchLab.productionTime = 60,$researchLab.manufacture = "Electrolarynx"]] // Currently have: $stockpile.electrolarynx//
		<</if>>
		/*<<if $researchLab.erectileImplant == 1>>

			[[Build erectile implant|Research Lab][$researchLab.productionTime = 50,$researchLab.manufacture = "Erectile implant"]] // Costs <<print cashFormat(25000)>>. Currently have: $stockpile.erectileImplant//
		<</if>>*/
	<</if>>

<<if $researchLab.manufacture != "none"||$researchLab.research != "none">>

 <<= ResearchLabStockPile()>>
<</if>>

<<case 1>>
	<<set $temp = 0>>
	<<set $nextLink = "Research Lab">>
	//You contact a representative of one of the larger cybernetics companies and inquire about their products.
 This is what they have to offer://

	__Hardware__

	[[Basic prosthetics interface|Research Lab][$temp = 1, cashX(-25000, "lab"), $stockpile.basicPLimbInterface += 1]] //Costs <<print cashFormat(25000)>>. Currently have: $stockpile.basicPLimbInterface//

	[[Advanced prosthetics interface|Research Lab][$temp = 1, cashX(-60000, "lab"), $stockpile.advPLimbInterface += 1]] //Costs <<print cashFormat(60000)>>. Currently have: $stockpile.advPLimbInterface//

	[[Basic prosthetic limbs|Research Lab][$temp = 1, cashX(-15000, "lab"), $stockpile.basicPLimb += 1]] //Costs <<print cashFormat(15000)>>. Currently have: $stockpile.basicPLimb//

	[[Advanced sex limbs|Research Lab][$temp = 1, cashX(-30000, "lab"), $stockpile.advSexPLimb += 1]] //Costs <<print cashFormat(30000)>>. Currently have: $stockpile.advSexPLimb//

	[[Advanced beauty limbs|Research Lab][$temp = 1, cashX(-30000, "lab"), $stockpile.advGracePLimb += 1]] //Costs <<print cashFormat(30000)>>. Currently have: $stockpile.advGracePLimb//

	[[Advanced combat limbs|Research Lab][$temp = 1, cashX(-30000, "lab"), $stockpile.advCombatPLimb += 1]] //Costs <<print cashFormat(30000)>>. Currently have: $stockpile.advCombatPLimb//

	[[Ocular implants|Research Lab][$temp = 1, cashX(-35000, "lab"), $stockpile.ocularImplant += 1]] //Costs <<print cashFormat(35000)>>. Currently have: $stockpile.ocularImplant//

	[[Cochlear implants|Research Lab][$temp = 1, cashX(-15000, "lab"), $stockpile.cochlearImplant += 1]] //Costs <<print cashFormat(15000)>>. Currently have: $stockpile.cochlearImplant//

	[[Electrolarynx|Research Lab][$temp = 1, cashX(-50000, "lab"), $stockpile.electrolarynx += 1]] //Costs <<print cashFormat(50000)>>. Currently have: $stockpile.electrolarynx//

	/*[[Erectile implant|Research Lab][$temp = 1, cashX(-25000, "lab"), $stockpile.erectileImplant += 1]] //Costs <<print cashFormat(25000)>>. Currently have: $stockpile.erectileImplant//*/

__Schematics__

	<<if $researchLab.basicPLimbInterface != 1 && $researchLab.research != "Basic prosthetics interface">>
		[[Basic prosthetics interface|Research Lab][$temp = 1, cashX(-85000, "lab"), $researchLab.basicPLimbInterface = 1]] //Costs <<print cashFormat(85000)>>.//

	<</if>>
	<<if $researchLab.advPLimbInterface != 1 && $researchLab.research != "Advanced prosthetics interface">>
	[[Advanced prosthetics interface|Research Lab][$temp = 1, cashX(-260000, "lab"), $researchLab.advPLimbInterface = 1]] //Costs <<print cashFormat(260000)>>.//

	<</if>>
	<<if $researchLab.basicPLimb != 1 && $researchLab.research != "Basic prosthetic limbs">>
	[[Basic prosthetic limbs|Research Lab][$temp = 1, cashX(-60000, "lab"), $researchLab.basicPLimb = 1]] //Costs <<print cashFormat(60000)>>.//

	<</if>>
	<<if $researchLab.advSexPLimb != 1 && $researchLab.research != "Advanced sex limbs">>
	[[Advanced sex limbs|Research Lab][$temp = 1, cashX(-120000, "lab"), $researchLab.advSexPLimb = 1]] //Costs <<print cashFormat(120000)>>.//

	<</if>>
	<<if $researchLab.advGracePLimb != 1 && $researchLab.research != "Advanced beauty limbs">>
	[[Advanced beauty limbs|Research Lab][$temp = 1, cashX(-120000, "lab"), $researchLab.advGracePLimb = 1]] //Costs <<print cashFormat(120000)>>.//

	<</if>>
	<<if $researchLab.advCombatPLimb != 1 && $researchLab.research != "Advanced combat limbs">>
	[[Advanced combat limbs|Research Lab][$temp = 1, cashX(-120000, "lab"), $researchLab.advCombatPLimb = 1]] //Costs <<print cashFormat(120000)>>.//

	<</if>>
	<<if $researchLab.ocularImplant != 1 && $researchLab.research != "Ocular implants">>
	[[Ocular implants|Research Lab][$temp = 1, cashX(-160000, "lab"), $researchLab.ocularImplant = 1]] //Costs <<print cashFormat(160000)>>.//

	<</if>>
	<<if $researchLab.cochlearImplant != 1 && $researchLab.research != "Cochlear implants">>
	[[Cochlear implants|Research Lab][$temp = 1, cashX(-125000, "lab"), $researchLab.cochlearImplant = 1]] //Costs <<print cashFormat(125000)>>.//

	<</if>>
	<<if $researchLab.electrolarynx != 1 && $researchLab.research != "Electrolarynx">>
	[[Electrolarynx|Research Lab][$temp = 1, cashX(-125000, "lab"), $researchLab.electrolarynx = 1]] //Costs <<print cashFormat(200000)>>.//

	<</if>>
	/*<<if $researchLab.erectileImplant != 1 && $researchLab.research != "Erectile implant">>
	[[Erectile implant|Research Lab][$temp = 1, cashX(-95000, "lab"), $researchLab.erectileImplant = 1]] //Costs <<print cashFormat(95000)>>.//
	<</if>>*/

<</switch>>