:: Prosthetic Lab [nobr]

<<set $nextButton = "Back", $nextLink = "Main">>

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

Prosthetic Lab
<hr><br>

<<if $adjustProsthetics.length > 0>>
	Currently adjusting these prosthetics:<br>
	<<for _p range $adjustProsthetics>>
		&nbsp;&nbsp;<<= capFirstChar(setup.prosthetics[_p.id].name)>> for <<= SlaveFullName($slaves[$slaveIndices[_p.slaveID]])>><br>
	<</for>>
<<else>>
	//Currently there are no prosthetics being fit to a slave.//
<</if>>

<<if $researchLab.level > 0>>
	<br><br>Research Department
	<hr>
	//You switch one of the screens in your office to the feed from your research facility.//

	<br><br>
	__Personnel__
	<br><br>

	<<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)>>//<br>
	<</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>>
	<br>

	&nbsp;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>>
	<br><br>&nbsp;

	<<if ($researchLab.hired + $researchLab.menials) < $researchLab.maxSpace>>
		Hire [[x1|Prosthetic Lab][$researchLab.hired += 1,cashX(-2000, "lab")]]
		<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 5>>
			| [[x5|Prosthetic Lab][$researchLab.hired += 5,cashX(-10000, "lab")]]
		<</if>>
		<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 10>>
			| [[x10|Prosthetic Lab][$researchLab.hired += 10,cashX(-10000, "lab")]]
		<</if>>
		scientists.<br>
		&nbsp;&nbsp;&nbsp;//Each scientist will require an initial fee of <<= cashFormat(2000)>> and incur <<= cashFormat(300)>> weekly.//
		<br>
		<<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.<br>
		<<else>>You do not own any <<if $researchLab.menials != 0>>unassigned <</if>>menial slaves.<br>
		<</if>>
		&nbsp;&nbsp;&nbsp;//Using menial slaves is much cheaper than hiring scientists, but they are less effective. <<= cashFormat(100)>> per slave each week.//<br>
	<<else>>
		&nbsp;&nbsp;&nbsp;//Facility is fully staffed.//
	<</if>>
	<br>
	<<if $researchLab.hired > 0>>&nbsp;
		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>><br>&nbsp;
		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>>

	<br><br>

	__Tasks__

	<br><br>

	<<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>>
		<br>
		<<for _i = 0; _i < $researchLab.tasks.length; _i++>>
			&nbsp;
			<<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 @@.yellow;<<= SlaveFullName($slaves[$slaveIndices[$researchLab.tasks[_i].slaveID]])>>@@ you <<if _i == 0>>are constructing<<else>> plan to construct<</if>>
			<<default>>
				@@.red;Error: Unknown $$researchLab.tasks[].type: $researchLab.tasks[_i].type@@
			<</switch>>
			<<set _j += $researchLab.tasks[_i].workLeft>>
			@@.yellow;<<= 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>>

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

	<br><br>

	__Research__
	<br><br>

	&nbsp;Available research projects:<br>
	<<for _p range setup.prostheticIDs>>
		<<if $prosthetics[_p].research == 0>>
			<<if _p != "erectile">> /*excludes erectile*/
			&nbsp;&nbsp;
			<<if setup.prosthetics[_p].level <= $prostheticsUpgrade>>
				<<capture _p>>
				<<link "Reverse engineer <<= capFirstChar(setup.prosthetics[_p].name)>>" "Prosthetic Lab">>
					<<set cashX(forceNeg(setup.prosthetics[_p].costs), "lab"), $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 needed research material for researching <<= capFirstChar(setup.prosthetics[_p].name)>>.//
			<</if>>
			<br>
			<</if>>
		<</if>>
	<</for>>

	<br><br>
	__Manufacture__
	<br><br>&nbsp;

	Available building projects:<br>
	<<for _p range setup.prostheticIDs>>
		<<if $prosthetics[_p].research == 1>>
			<<if _p != setup.prostheticIDs.erectile>> /*excludes erectile*/
			&nbsp;&nbsp;
			<<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>>
			<br>
			<</if>>
		<</if>>
	<</for>>

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