From 0b8e67d536e4b62937e775e24f157b8c42e717a1 Mon Sep 17 00:00:00 2001
From: Arkerthan <arkerthan@gmail.com>
Date: Thu, 11 Apr 2019 20:17:00 +0200
Subject: [PATCH] all the good stuff from !4183

---
 src/interaction/researchLab.tw | 408 ++++++++++++++++++++++-----------
 src/uncategorized/labReport.tw | 154 ++++++-------
 2 files changed, 354 insertions(+), 208 deletions(-)

diff --git a/src/interaction/researchLab.tw b/src/interaction/researchLab.tw
index 025372716e1..e21f7ac2e56 100644
--- a/src/interaction/researchLab.tw
+++ b/src/interaction/researchLab.tw
@@ -4,17 +4,23 @@
 
 <<case 0>>
 
-	<<set $nextButton = "Back", $nextLink = "Manage Arcology">>
+	<<set $nextButton = "Back", $nextLink = "Main">>
 
-	//You switch one of the screens in your office to the feed from research facility.//<br><br>
+	<<set $researchLab.speed = (($researchLab.hired * 3) + $researchLab.menials) * $researchLab.aiModule>>
 
-	<br>[[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.//
+	//You switch one of the screens in your office to the feed from your research facility.//
+	/*<br><br>
 
-	<br><br>[[Purchase cybernetics|Research Lab][$temp = 1]]
-<br><br>
-	__Personnel__<br><br>&nbsp;
+	<br>[[Decommission facility|Manage Arcology][$researchLab.built = "false", $researchLab.hired = 0, $menials += $researchLab.menials, $researchLab.menials = 0,$researchLab.speed = 0, !!!TASKS!!!]] //Warning! This will cancel all projects, remove all staff and shut down this facility.//
+*/
+	<br><br>
+
+	[[Purchase cybernetics|Research Lab][$temp = 1]]
+
+	<br><br>
+	__Personnel__
+	<br><br>
 
-<br>
 	<<if $researchLab.aiModule == 1>>
 		[[Buy and install research module|Research Lab][cashX(-35000, "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 <<print cashFormat(35000)>>//<br>
 	<</if>>
@@ -27,16 +33,15 @@
 		<<elseif $researchLab.hired > 1>>
 			$researchLab.hired scientists
 		<</if>>
-		<<if $researchLab.menials != 0>> and<</if>>
-		<<if $researchLab.menials == 0>>
-		<<elseif $researchLab.menials == 1>>
+		<<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 != 0>>Occasionally you hear the voice of your assistant as _heA helps direct and organize work.<</if>>//
+			<<if $researchLab.aiModule > 1>>Occasionally you hear the voice of your assistant as _heA helps direct and organize work.<</if>>//
 	<</if>>
 	<br>
 
@@ -62,15 +67,15 @@
 	<br><br>&nbsp;
 
 	<<if ($researchLab.hired + $researchLab.menials) < $researchLab.maxSpace>>
-		Hire [[x1|Research Lab][$researchLab.hired += 1,cashX(-5000, "lab")]]
+		Hire [[x1|Research Lab][$researchLab.hired += 1,cashX(-2000, "lab")]]
 		<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 5>>
-			| [[x5|Research Lab][$researchLab.hired += 5,cashX(-25000, "lab")]]
+			| [[x5|Research Lab][$researchLab.hired += 5,cashX(-10000, "lab")]]
 		<</if>>
 		<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 10>>
-			| [[x10|Research Lab][$researchLab.hired += 10,cashX(-50000, "lab")]]
+			| [[x10|Research Lab][$researchLab.hired += 10,cashX(-10000, "lab")]]
 		<</if>>
 		scientists.<br>
-		&nbsp;&nbsp;&nbsp;//Each scientist will require an initial fee of <<print cashFormat(5000)>> and incur <<print cashFormat(300)>> weekly.//
+		&nbsp;&nbsp;&nbsp;//Each scientist will require an initial fee of <<print cashFormat(2000)>> and incur <<print cashFormat(300)>> weekly.//
 		<br>
 		<<if $menials > 0>>
 			Assign [[x1|Research Lab][$researchLab.menials += 1,$menials -= 1]]
@@ -107,103 +112,163 @@
 		<<if $researchLab.menials >= 10>>
 			| [[x10|Research Lab][$researchLab.menials -= 10,$menials += 10]]
 		<</if>>
-		| [[All|Research Lab][$menials += $researchLab.menials,$researchLab.menials = 0]]
+		| [[All|Research 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++>>
+			<<if $researchLab.tasks[_i].type == "research">>
+				You <<if _i == 0>>are researching<<else>> plan to research<</if>>
+			<<elseif $researchLab.tasks[_i].type == "manufacture">>
+				You <<if _i == 0>>are constructing<<else>> plan to construct<</if>>
+			<<else>>
+				@@.red;Error: Unkown $$researchLab.tasks[].type: $researchLab.tasks[_i].type@@
+			<</if>>
+			<<set _j += $researchLab.tasks[_i].workLeft>>
+			@@.yellow;$researchLab.tasks[_i].product@@.
+			<<if $researchLab.speed > 0>>
+				Finished in approximately <<print (Math.floor(_j / $researchLab.speed) + 1)>> week(s).
+			<</if>>
+
+			<<if $researchLab.tasks[_i].type == "research">>
+				<<set _link = "Cancel: Will not return prosthetics.">>
+			<<else>>
+				<<set _link = "Cancel">>
+			<</if>>
+			<<capture _i>>
+				<<link _link "Research Lab">>
+					<<if $researchLab.tasks[_i].type == "research">>
+						<<switch $researchLab.tasks[_i].product>>
+						<<case "Basic prosthetics interface">>
+							<<set $researchLab.basicPLimbInterface = 0>>
+						<<case "Advanced prosthetics interface">>
+							<<set $researchLab.advPLimbInterface = 0>>
+						<<case "Basic prosthetic limbs">>
+							<<set $researchLab.basicPLimb = 0>>
+						<<case "Advanced sex limbs">>
+							<<set $researchLab.advSexPLimb = 0>>
+						<<case "Advanced beauty limbs">>
+							<<set $researchLab.advGracePLimb = 0>>
+						<<case "Advanced combat limbs">>
+							<<set $researchLab.advCombatPLimb = 0>>
+						<<case "Cybernetic limbs">>
+							<<set $researchLab.cyberneticPLimb = 0>>
+						<<case "Ocular implants">>
+							<<set $researchLab.ocularImplant = 0>>
+						<<case "Cochlear implants">>
+							<<set $researchLab.cochlearImplant = 0>>
+						<<case "Electrolarynx">>
+							<<set $researchLab.electrolarynx = 0>>
+						/*<<case "Erectile implant">>
+						<<set $researchLab.erectileImplant = 1>>*/
+						<</switch>>
+					<</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;
-	<<if $researchLab.research != "none">>
-		//Your lab staff is currently researching @@.yellow;$researchLab.research@@.//<br>
-		[[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.//<br>
-		<<if $researchLab.basicPLimbInterface == 0 && $stockpile.basicPLimbInterface > 0>><br>
-			[[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>><br>
-			[[Reverse engineer advanced prosthetics interface|Research Lab][$researchLab.productionTime = 120,$researchLab.research = "Advanced prosthetics interface"]]
-		<</if>>
-		<<if $researchLab.basicPLimb == 0 && $stockpile.basicPLimb > 0>><br>
-			[[Reverse engineer basic prosthetic limbs|Research Lab][$researchLab.productionTime = 80,$researchLab.research = "Basic prosthetic limbs"]]
-		<</if>>
-		<<if $researchLab.advSexPLimb == 0 && $stockpile.advSexPLimb > 0>><br>
-			[[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>><br>
-			[[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>><br>
-			[[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>><br>
-			[[Develop cybernetic limbs|Research Lab][$researchLab.productionTime = 300,$researchLab.research = "Cybernetic limbs"]]
-		<</if>>
-		<<if $researchLab.ocularImplant == 0 && $stockpile.ocularImplant > 0>><br>
-			[[Reverse engineer ocular implants|Research Lab][$stockpile.ocularImplant -= 1,$researchLab.productionTime = 100,$researchLab.research = "Ocular implants"]]
-		<</if>>
-		<<if $researchLab.cochlearImplant == 0 && $stockpile.cochlearImplant > 0>><br>
-			[[Reverse engineer cochlear implants|Research Lab][$stockpile.cochlearImplant -= 1,$researchLab.productionTime = 80,$researchLab.research = "Cochlear implants"]]
-		<</if>>
-		<<if $researchLab.electrolarynx == 0 && $stockpile.electrolarynx > 0>><br>
-			[[Reverse engineer electrolarynx|Research Lab][$stockpile.electrolarynx -= 1,$researchLab.productionTime = 80,$researchLab.research = "Electrolarynx"]]
-		<</if>>
+
+	Available research projects:
+	<<if $researchLab.basicPLimbInterface == 0 && $stockpile.basicPLimbInterface > 0>><br>
+		[[Reverse engineer basic prosthetics interface|Research Lab][$stockpile.basicPLimbInterface -= 1, $researchLab.basicPLimbInterface = -1, $researchLab.tasks.push({type: "research", product: "Basic prosthetics interface", workLeft: 100})]]
+	<</if>>
+	<<if $researchLab.basicPLimbInterface > 0 && $researchLab.advPLimbInterface == 0 && $stockpile.advPLimbInterface > 0>><br>
+		[[Reverse engineer advanced prosthetics interface|Research Lab][$stockpile.advPLimbInterface -= 1, $researchLab.advPLimbInterface = -1, $researchLab.tasks.push({type: "research", product: "Advanced prosthetics interface", workLeft: 160})]]
+	<</if>>
+	<<if $researchLab.basicPLimb == 0 && $stockpile.basicPLimb > 0>><br>
+		[[Reverse engineer basic prosthetic limbs|Research Lab][$stockpile.basicPLimb -= 1, $researchLab.basicPLimb = -1, $researchLab.tasks.push({type: "research", product: "Basic prosthetic limbs", workLeft: 80})]]
+	<</if>>
+	<<if $researchLab.advSexPLimb == 0 && $stockpile.advSexPLimb > 0>><br>
+		[[Reverse engineer advanced sex limbs|Research Lab][$stockpile.advSexPLimb -= 1, $researchLab.advSexPLimb = -1, $researchLab.tasks.push({type: "research", product: "Advanced sex limbs", workLeft: 140})]]
+	<</if>>
+	<<if $researchLab.advGracePLimb == 0 && $stockpile.advGracePLimb > 0>><br>
+		[[Reverse engineer advanced beauty limbs|Research Lab][$stockpile.advGracePLimb -= 1, $researchLab.advGracePLimb = -1, $researchLab.tasks.push({type: "research", product: "Advanced beauty limbs", workLeft: 140})]]
+	<</if>>
+	<<if $researchLab.advCombatPLimb == 0 && $stockpile.advCombatPLimb > 0>><br>
+		[[Reverse engineer advanced combat limbs|Research Lab][$stockpile.advCombatPLimb -= 1, $researchLab.advCombatPLimb = -1, $researchLab.tasks.push({type: "research", product: "Advanced combat limbs", workLeft: 140})]]
+	<</if>>
+	<<if $researchLab.cyberneticPLimb == 0 && $researchLab.advPLimbInterface == 1 && ($researchLab.advSexPLimb > 0 || $researchLab.advGracePLimb > 0 || $researchLab.advCombatPLimb > 0)>><br>
+		[[Develop cybernetic limbs|Research Lab][$researchLab.cyberneticPLimb = -1, $researchLab.tasks.push({type: "research", product: "Cybernetic limbs", workLeft: 250})]]
+	<</if>>
+	<<if $researchLab.ocularImplant == 0 && $stockpile.ocularImplant > 0>><br>
+		[[Reverse engineer ocular implants|Research Lab][$stockpile.ocularImplant -= 1, $researchLab.ocularImplant = -1, $researchLab.tasks.push({type: "research", product: "Ocular implants", workLeft: 150})]]
+	<</if>>
+	<<if $researchLab.cochlearImplant == 0 && $stockpile.cochlearImplant > 0>><br>
+		[[Reverse engineer cochlear implants|Research Lab][$stockpile.cochlearImplant -= 1, $researchLab.cochlearImplant = -1, $researchLab.tasks.push({type: "research", product: "Cochlear implants", workLeft: 80})]]
+	<</if>>
+	<<if $researchLab.electrolarynx == 0 && $stockpile.electrolarynx > 0>><br>
+		[[Reverse engineer electrolarynx|Research Lab][$stockpile.electrolarynx -= 1, $researchLab.electrolarynx = -1, $researchLab.tasks.push({type: "research", product: "Electrolarynx", workLeft: 80})]]
+	<</if>>
 		/*<<if $researchLab.erectileImplant == 0 && $stockpile.erectileImplant > 0>><br>
 			[[Reverse engineer erectile implant|Research Lab][$stockpile.erectileImplant -= 1,$researchLab.productionTime = 100,$researchLab.research = "Erectile implant"]]
 		<</if>>*/
-	<</if>>
+	<br>
+	//When researching a schematic one prosthetic will be destroyed while analyzing its structure.//
 
 	<br><br>
 	__Manufacture__
 	<br><br>&nbsp;
-	<<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.//<br>
-		<<if $researchLab.basicPLimbInterface == 1>><br>
-			[[Build basic prosthetics interface|Research Lab][$researchLab.productionTime = 50,$researchLab.manufacture = "Basic prosthetics interface"]] // Currently have: $stockpile.basicPLimbInterface//
-		<</if>>
-		<<if $researchLab.advPLimbInterface == 1>><br>
-			[[Build advanced prosthetics interface|Research Lab][$researchLab.productionTime = 80,$researchLab.manufacture = "Advanced prosthetics interface"]] // Currently have: $stockpile.advPLimbInterface//
-		<</if>>
-		<<if $researchLab.basicPLimb == 1>><br>
-			[[Build basic prosthetic limbs|Research Lab][$researchLab.productionTime = 20,$researchLab.manufacture = "Basic prosthetic limbs"]] // Currently have: $stockpile.basicPLimb//
-		<</if>>
-		<<if $researchLab.advSexPLimb == 1>><br>
-			[[Build advanced sex limbs|Research Lab][$researchLab.productionTime = 100,$researchLab.manufacture = "Advanced sex limbs"]] // Currently have: $stockpile.advSexPLimb//
-		<</if>>
-		<<if $researchLab.advGracePLimb == 1>><br>
-			[[Build advanced beauty limbs|Research Lab][$researchLab.productionTime = 100,$researchLab.manufacture = "Advanced beauty limbs"]] // Currently have: $stockpile.advGracePLimb//
-		<</if>>
-		<<if $researchLab.advCombatPLimb == 1>><br>
-			[[Build advanced combat limbs|Research Lab][$researchLab.productionTime = 100,$researchLab.manufacture = "Advanced combat limbs"]] // Currently have: $stockpile.advCombatPLimb//
-		<</if>>
-		<<if $researchLab.cyberneticPLimb == 1>><br>
-			[[Build cybernetic limbs|Research Lab][$researchLab.productionTime = 150,$researchLab.manufacture = "Cybernetic limbs"]] // Currently have: $stockpile.cyberneticPLimb//
-		<</if>>
-		<<if $researchLab.ocularImplant == 1>><br>
-			[[Build ocular implants|Research Lab][$researchLab.productionTime = 80,$researchLab.manufacture = "Ocular implants"]] // Currently have: $stockpile.ocularImplant//
-		<</if>>
-		<<if $researchLab.cochlearImplant == 1>><br>
-			[[Build cochlear implants|Research Lab][$researchLab.productionTime = 60,$researchLab.manufacture = "Cochlear implants"]] // Currently have: $stockpile.cochlearImplant//
-		<</if>>
-		<<if $researchLab.electrolarynx == 1>><br>
-			[[Build electrolarynx|Research Lab][$researchLab.productionTime = 60,$researchLab.manufacture = "Electrolarynx"]] // Currently have: $stockpile.electrolarynx//
-		<</if>>
+	Available building projects:<br>
+	<<if $researchLab.basicPLimbInterface == 1>><br>
+		[[Build basic prosthetics interface|Research Lab][$researchLab.tasks.push({type: "manufacture", product: "Basic prosthetics interface", workLeft: 50})]] // Currently have: $stockpile.basicPLimbInterface//
+	<</if>>
+	<<if $researchLab.advPLimbInterface == 1>><br>
+		[[Build advanced prosthetics interface|Research Lab][$researchLab.tasks.push({type: "manufacture", product: "Advanced prosthetics interface", workLeft: 80})]] // Currently have: $stockpile.advPLimbInterface//
+	<</if>>
+	<<if $researchLab.basicPLimb == 1>><br>
+		[[Build basic prosthetic limbs|Research Lab][$researchLab.tasks.push({type: "manufacture", product: "Basic prosthetic limbs", workLeft: 40})]] // Currently have: $stockpile.basicPLimb//
+	<</if>>
+	<<if $researchLab.advSexPLimb == 1>><br>
+		[[Build advanced sex limbs|Research Lab][$researchLab.tasks.push({type: "manufacture", product: "Advanced sex limbs", workLeft: 70})]] // Currently have: $stockpile.advSexPLimb//
+	<</if>>
+	<<if $researchLab.advGracePLimb == 1>><br>
+		[[Build advanced beauty limbs|Research Lab][$researchLab.tasks.push({type: "manufacture", product: "Advanced beauty limbs", workLeft: 70})]] // Currently have: $stockpile.advGracePLimb//
+	<</if>>
+	<<if $researchLab.advCombatPLimb == 1>><br>
+		[[Build advanced combat limbs|Research Lab][$researchLab.tasks.push({type: "manufacture", product: "Advanced combat limbs", workLeft: 70})]] // Currently have: $stockpile.advCombatPLimb//
+	<</if>>
+	<<if $researchLab.cyberneticPLimb == 1>><br>
+		[[Build cybernetic limbs|Research Lab][$researchLab.tasks.push({type: "manufacture", product: "Cybernetic limbs", workLeft: 150})]] // Currently have: $stockpile.cyberneticPLimb//
+	<</if>>
+	<<if $researchLab.ocularImplant == 1>><br>
+		[[Build ocular implants|Research Lab][$researchLab.tasks.push({type: "manufacture", product: "Ocular implants", workLeft: 100})]] // Currently have: $stockpile.ocularImplant//
+	<</if>>
+	<<if $researchLab.cochlearImplant == 1>><br>
+		[[Build cochlear implants|Research Lab][$researchLab.tasks.push({type: "manufacture", product: "Cochlear implants", workLeft: 40})]] // Currently have: $stockpile.cochlearImplant//
+	<</if>>
+	<<if $researchLab.electrolarynx == 1>><br>
+		[[Build electrolarynx|Research Lab][$researchLab.tasks.push({type: "manufacture", product: "Electrolarynx", workLeft: 40})]] // Currently have: $stockpile.electrolarynx//
+	<</if>>
 		/*<<if $researchLab.erectileImplant == 1>><br>
 			[[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">>
-	<br><br> <<= ResearchLabStockPile()>>
-<</if>>
+	<br><br>
+	 <<= ResearchLabStockPile()>>
 
 <<case 1>>
 	<<set $temp = 0>>
@@ -211,58 +276,143 @@
 	//You contact a representative of one of the larger cybernetics companies and inquire about their products.<br>&nbsp;This is what they have to offer://<br><br>
 
 	__Hardware__<br>
-	[[Basic prosthetics interface|Research Lab][$temp = 1, cashX(-25000, "lab"), $stockpile.basicPLimbInterface += 1]] //Costs <<print cashFormat(25000)>>. Currently have: $stockpile.basicPLimbInterface//<br>
-	[[Advanced prosthetics interface|Research Lab][$temp = 1, cashX(-60000, "lab"), $stockpile.advPLimbInterface += 1]] //Costs <<print cashFormat(60000)>>. Currently have: $stockpile.advPLimbInterface//<br>
-	[[Basic prosthetic limbs|Research Lab][$temp = 1, cashX(-15000, "lab"), $stockpile.basicPLimb += 1]] //Costs <<print cashFormat(15000)>>. Currently have: $stockpile.basicPLimb//<br>
-	[[Advanced sex limbs|Research Lab][$temp = 1, cashX(-30000, "lab"), $stockpile.advSexPLimb += 1]] //Costs <<print cashFormat(30000)>>. Currently have: $stockpile.advSexPLimb//<br>
-	[[Advanced beauty limbs|Research Lab][$temp = 1, cashX(-30000, "lab"), $stockpile.advGracePLimb += 1]] //Costs <<print cashFormat(30000)>>. Currently have: $stockpile.advGracePLimb//<br>
-	[[Advanced combat limbs|Research Lab][$temp = 1, cashX(-30000, "lab"), $stockpile.advCombatPLimb += 1]] //Costs <<print cashFormat(30000)>>. Currently have: $stockpile.advCombatPLimb//<br>
-	[[Ocular implants|Research Lab][$temp = 1, cashX(-35000, "lab"), $stockpile.ocularImplant += 1]] //Costs <<print cashFormat(35000)>>. Currently have: $stockpile.ocularImplant//<br>
-	[[Cochlear implants|Research Lab][$temp = 1, cashX(-15000, "lab"), $stockpile.cochlearImplant += 1]] //Costs <<print cashFormat(15000)>>. Currently have: $stockpile.cochlearImplant//<br>
-	[[Electrolarynx|Research Lab][$temp = 1, cashX(-50000, "lab"), $stockpile.electrolarynx += 1]] //Costs <<print cashFormat(50000)>>. Currently have: $stockpile.electrolarynx//<br>
+
+	[[Basic prosthetics interface|Research Lab][$temp = 1, cashX(-7000, "lab"), $stockpile.basicPLimbInterface += 1]] //Costs <<print cashFormat(7000)>>. Currently have: $stockpile.basicPLimbInterface//<br>
+	<<if $rep > 11000>>
+		[[Advanced prosthetics interface|Research Lab][$temp = 1, cashX(-10000, "lab"), $stockpile.advPLimbInterface += 1]] //Costs <<print cashFormat(10000)>>.//
+	<<else>>
+		//You lack the reputation to obtain advanced prosthetics interface.//
+	<</if>>
+	//Currently have: $stockpile.advPLimbInterface//<br>
+	[[Basic prosthetic limbs|Research Lab][$temp = 1, cashX(-7000, "lab"), $stockpile.basicPLimb += 1]] //Costs <<print cashFormat(10000)>>. Currently have: $stockpile.basicPLimb//<br>
+	<<if $rep > 11000>>
+		[[Advanced sex limbs|Research Lab][$temp = 1, cashX(-15000, "lab"), $stockpile.advSexPLimb += 1]] //Costs <<print cashFormat(15000)>>.//
+	<<else>>
+		//You lack the reputation to obtain advanced sex limbs.//
+	<</if>>
+	//Currently have: $stockpile.advSexPLimb//<br>
+	<<if $rep > 11000>>
+	[[Advanced beauty limbs|Research Lab][$temp = 1, cashX(-15000, "lab"), $stockpile.advGracePLimb += 1]] //Costs <<print cashFormat(15000)>>.//
+	<<else>>
+		//You lack the reputation to obtain advanced beauty limbs.//
+	<</if>>
+	//Currently have: $stockpile.advGracePLimb//<br>
+	<<if $rep > 11000>>
+		[[Advanced combat limbs|Research Lab][$temp = 1, cashX(-15000, "lab"), $stockpile.advCombatPLimb += 1]] //Costs <<print cashFormat(15000)>>.//
+	<<else>>
+		//You lack the reputation to obtain advanced combat limbs.//
+	<</if>>
+	//Currently have: $stockpile.advCombatPLimb//<br>
+	<<if $rep > 9000>>
+		[[Ocular implants|Research Lab][$temp = 1, cashX(-20000, "lab"), $stockpile.ocularImplant += 1]] //Costs <<print cashFormat(20000)>>.//
+	<<else>>
+		//You lack the reputation to obtain ocular implants.//
+	<</if>>
+	//Currently have: $stockpile.ocularImplant//<br>
+	[[Cochlear implants|Research Lab][$temp = 1, cashX(-5000, "lab"), $stockpile.cochlearImplant += 1]] //Costs <<print cashFormat(5000)>>. Currently have: $stockpile.cochlearImplant//<br>
+	[[Electrolarynx|Research Lab][$temp = 1, cashX(-5000, "lab"), $stockpile.electrolarynx += 1]] //Costs <<print cashFormat(5000)>>. Currently have: $stockpile.electrolarynx//<br>
 	/*[[Erectile implant|Research Lab][$temp = 1, cashX(-25000, "lab"), $stockpile.erectileImplant += 1]] //Costs <<print cashFormat(25000)>>. Currently have: $stockpile.erectileImplant//*/
 
-	<br><br>__Schematics__<br>
-	<<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)>>.//<br>
+	<br>__Schematics__<br>
+	<<if $researchLab.basicPLimbInterface == 0>>
+		<<if $rep > 8000>>
+			[[Basic prosthetics interface|Research Lab][$temp = 1, cashX(-85000, "lab"), $researchLab.basicPLimbInterface = 1]] //Costs <<print cashFormat(85000)>>.//
+		<<else>>
+			//You lack the reputation to obtain schematics for basic prosthetics interfaces.//
+		<</if>>
+		<br>
 	<</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)>>.//<br>
+	<<if $researchLab.advPLimbInterface == 0>>
+		<<if $rep > 12000>>
+			[[Advanced prosthetics interface|Research Lab][$temp = 1, cashX(-260000, "lab"), $researchLab.advPLimbInterface = 1]] //Costs <<print cashFormat(260000)>>.//
+		<<else>>
+			//You lack the reputation to obtain schematics for advanced prosthetics interfaces.//
+		<</if>>
+		<br>
 	<</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)>>.//<br>
+	<<if $researchLab.basicPLimb == 0>>
+		<<if $rep > 8000>>
+			[[Basic prosthetic limbs|Research Lab][$temp = 1, cashX(-60000, "lab"), $researchLab.basicPLimb = 1]] //Costs <<print cashFormat(60000)>>.//
+		<<else>>
+			//You lack the reputation to obtain schematics for basic prosthetics limbs.//
+		<</if>>
+		<br>
 	<</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)>>.//<br>
+	<<if $researchLab.advSexPLimb == 0>>
+		<<if $rep > 12000>>
+			[[Advanced sex limbs|Research Lab][$temp = 1, cashX(-120000, "lab"), $researchLab.advSexPLimb = 1]] //Costs <<print cashFormat(120000)>>.//
+		<<else>>
+			//You lack the reputation to obtain schematics for advanced sex limbs.//
+		<</if>>
+		<br>
 	<</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)>>.//<br>
+	<<if $researchLab.advGracePLimb == 0>>
+		<<if $rep > 12000>>
+			[[Advanced beauty limbs|Research Lab][$temp = 1, cashX(-120000, "lab"), $researchLab.advGracePLimb = 1]] //Costs <<print cashFormat(120000)>>.//
+		<<else>>
+			//You lack the reputation to obtain schematics for advanced beauty limbs.//
+		<</if>>
+		<br>
 	<</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)>>.//<br>
+	<<if $researchLab.advCombatPLimb == 0>>
+		<<if $rep > 12000>>
+			[[Advanced combat limbs|Research Lab][$temp = 1, cashX(-120000, "lab"), $researchLab.advCombatPLimb = 1]] //Costs <<print cashFormat(120000)>>.//
+		<<else>>
+			//You lack the reputation to obtain schematics for advanced combat limbs.//
+		<</if>>
+		<br>
 	<</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)>>.//<br>
+	<<if $researchLab.ocularImplant == 0>>
+		<<if $rep > 10000>>
+			[[Ocular implants|Research Lab][$temp = 1, cashX(-160000, "lab"), $researchLab.ocularImplant = 1]] //Costs <<print cashFormat(160000)>>.//
+		<<else>>
+			//You lack the reputation to obtain schematics for ocular implants.//
+		<</if>>
+		<br>
 	<</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)>>.//<br>
+	<<if $researchLab.cochlearImplant == 0>>
+		<<if $rep > 8000>>
+			[[Cochlear implants|Research Lab][$temp = 1, cashX(-125000, "lab"), $researchLab.cochlearImplant = 1]] //Costs <<print cashFormat(125000)>>.//
+		<<else>>
+			//You lack the reputation to obtain schematics for cochlear implants.//
+		<</if>>
+		<br>
 	<</if>>
-	<<if $researchLab.electrolarynx != 1 && $researchLab.research != "Electrolarynx">>
-	[[Electrolarynx|Research Lab][$temp = 1, cashX(-125000, "lab"), $researchLab.electrolarynx = 1]] //Costs <<print cashFormat(200000)>>.//<br>
+	<<if $researchLab.electrolarynx == 0>>
+		<<if $rep > 8000>>
+			[[Electrolarynx|Research Lab][$temp = 1, cashX(-125000, "lab"), $researchLab.electrolarynx = 1]] //Costs <<print cashFormat(200000)>>.//
+		<<else>>
+			//You lack the reputation to obtain schematics for electrolarynx.//
+		<</if>>
+		<br>
 	<</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>>*/
 
-<br><br>
-	//You contact a representative of one of the most popular Japanese cybernetics companies and inquire about their products.<br>&nbsp;This is what they have to offer://<br><br>
+	<br><br>
+
+	//You contact a representative of one of the most popular Japanese cybernetics companies and inquire about their products.<br>
+	&nbsp;This is what they have to offer://
+
+	<br><br>
 
 	__Hardware__<br>
 	[[Neural Tail Interface|Research Lab][$temp = 1, cashX(-10000, "lab"), $stockpile.interfacePTail += 1]] //Costs <<print cashFormat(10000)>>. Currently have: $stockpile.interfacePTail//<br>
 	[[Modular Tail|Research Lab][$temp = 1, cashX(-3000, "lab"), $stockpile.modPTail += 1]] //Costs <<print cashFormat(5000)>>. Currently have: $stockpile.modPTail//<br>
-	[[Combat Tail|Research Lab][$temp = 1, cashX(-15000, "lab"), $stockpile.warPTail += 1]] //Costs <<print cashFormat(15000)>>. Currently have: $stockpile.warPTail//<br>
-	[[Pleasure Tail|Research Lab][$temp = 1, cashX(-10000, "lab"), $stockpile.sexPTail += 1]] //Costs <<print cashFormat(10000)>>. Currently have: $stockpile.sexPTail//<br>
+	<<if $rep > 11000>>
+		[[Combat Tail|Research Lab][$temp = 1, cashX(-15000, "lab"), $stockpile.warPTail += 1]] //Costs <<print cashFormat(15000)>>.//
+	<<else>>
+		//You lack the reputation to obtain combat tails.//
+	<</if>>
+	//Currently have: $stockpile.warPTail//<br>
+	<<if $rep > 10000>>
+		[[Pleasure Tail|Research Lab][$temp = 1, cashX(-10000, "lab"), $stockpile.sexPTail += 1]] //Costs <<print cashFormat(10000)>>.//
+	<<else>>
+		//You lack the reputation to obtain pleasure tails.//
+	<</if>>
+	//Currently have: $stockpile.sexPTail//<br>
 
-	<br><br>__Schematics__<br>
+	<br>__Schematics__<br>
 	They do not currently offer schematics for sale.
-<</switch>>
\ No newline at end of file
+<</switch>>
diff --git a/src/uncategorized/labReport.tw b/src/uncategorized/labReport.tw
index 712f2635332..acf533dc3f0 100644
--- a/src/uncategorized/labReport.tw
+++ b/src/uncategorized/labReport.tw
@@ -2,85 +2,81 @@
 
 ''Lab Report''<hr style="margin:0">
 <br>
-<<if ($researchLab.hired + $researchLab.menials) != 0>>
-	<<if $researchLab.research == "none" && $researchLab.manufacture == "none">>
-		Since the lab is currently not working on any projects it takes contract work and earns you @@.yellowgreen;<<print cashFormat((($researchLab.hired * 3 + $researchLab.menials) * $researchLab.aiModule * 20))>>.@@
-		<<set _cashX = (($researchLab.hired * 3 + $researchLab.menials) * $researchLab.aiModule * 20)>>
+<<if ($researchLab.hired + $researchLab.menials) > 0>>
+	<<if $researchLab.tasks.length == 0>>
+		Since the lab is currently not working on any projects it takes contract work and earns you @@.yellowgreen;<<print cashFormat($researchLab.speed * 20)>>.@@
+		<<set _cashX = ($researchLab.speed * 90)>>
 		<<run cashX(_cashX, "lab")>>
-	<<elseif $researchLab.research != "none">>
-		<<set $researchLab.productionTime -= (($researchLab.hired * 3) + ($researchLab.menials) * ($researchLab.aiModule))>>
-		<<if $researchLab.productionTime <= 0>>
-			Your lab staff have @@.green;completed@@ their $researchLab.research research project, and
-			<<switch $researchLab.research>>
-			<<case "Basic prosthetics interface">>
-				<<set $researchLab.basicPLimbInterface = 1>>
-			<<case "Advanced prosthetics interface">>
-				<<set $researchLab.advPLimbInterface = 1>>
-			<<case "Basic prosthetic limbs">>
-				<<set $researchLab.basicPLimb = 1>>
-			<<case "Advanced sex limbs">>
-				<<set $researchLab.advSexPLimb = 1>>
-			<<case "Advanced beauty limbs">>
-				<<set $researchLab.advGracePLimb = 1>>
-			<<case "Advanced combat limbs">>
-				<<set $researchLab.advCombatPLimb = 1>>
-			<<case "Cybernetic limbs">>
-				<<set $researchLab.cyberneticPLimb = 1>>
-			<<case "Ocular implants">>
-				<<set $researchLab.ocularImplant = 1>>
-			<<case "Cochlear implants">>
-				<<set $researchLab.cochlearImplant = 1>>
-			<<case "Electrolarynx">>
-				<<set $researchLab.electrolarynx = 1>>
-			/*<<case "Erectile implant">>
-				<<set $researchLab.erectileImplant = 1>>*/
-			<</switch>>
-			they are awaiting your next instruction.
-			<<set $researchLab.productionTime = 0, $researchLab.research = "none">>
-		<<else>>
-			Your lab staff are currently researching @@.yellow;$researchLab.research.@@
-		<</if>>
-		<br><br> <<= ResearchLabStockPile()>>
-	<<elseif $researchLab.manufacture != "none">>
-		<<set $researchLab.productionTime -= (($researchLab.hired * 3) + ($researchLab.menials) * ($researchLab.aiModule))>>
-		<<if $researchLab.productionTime <= 0>>
-			Your lab staff have @@.green;completed@@ their $researchLab.manufacture project, and
-			<<switch $researchLab.manufacture>>
-			<<case "Basic prosthetics interface">>
-				<<set $stockpile.basicPLimbInterface += 1, $researchLab.productionTime = 50>>
-			<<case "Advanced prosthetics interface">>
-				<<set $stockpile.advPLimbInterface += 1, $researchLab.productionTime = 80>>
-			<<case "Basic prosthetic limbs">>
-				<<set $stockpile.basicPLimb += 1, $researchLab.productionTime = 20>>
-			<<case "Advanced sex limbs">>
-				<<set $stockpile.advSexPLimb += 1, $researchLab.productionTime = 100>>
-			<<case "Advanced beauty limbs">>
-				<<set $stockpile.advGracePLimb += 1, $researchLab.productionTime = 100>>
-			<<case "Advanced combat limbs">>
-				<<set $stockpile.advCombatPLimb += 1, $researchLab.productionTime = 100>>
-			<<case "Cybernetic limbs">>
-				<<set $stockpile.cyberneticPLimb += 1, $researchLab.productionTime = 150>>
-			<<case "Ocular implants">>
-				<<set $stockpile.ocularImplant += 1, $researchLab.productionTime = 80>>
-			<<case "Cochlear implants">>
-				<<set $stockpile.cochlearImplant += 1, $researchLab.productionTime = 60>>
-			<<case "Electrolarynx">>
-				<<set $stockpile.electrolarynx += 1, $researchLab.productionTime = 100>>
-			/*<<case "Erectile implant">>
-				<<set $stockpile.erectileImplant += 1, $researchLab.productionTime = 50>>*/
-			<</switch>>
-			<span id="haltproduction">
-				they are starting work on another unit.
-				<<link "Halt production">>
-					<<set $researchLab.productionTime = 0, $researchLab.manufacture = "none">>
-					<<replace "#haltproduction">>
-						they are awaiting your next instruction.
-					<</replace>>
-				<</link>>
-			</span>
-		<<else>>
-			Your lab staff are currently working on @@.yellow;$researchLab.manufacture.@@
-		<</if>>
-		<br><br> <<= ResearchLabStockPile()>>
+	<<else>>
+		<<set _work = $researchLab.speed, _task = $researchLab.tasks[0]>>
+		/*<<for _i = 0; _i < $researchLab.tasks.length && _work > 0; _i++>>*/
+		<<for _work > 0>>
+			<<if _work < _task.workLeft>>
+				<<set _task.workLeft -= _work, _work = 0>>
+				The lab continues <<if _task.type == "research">>research<<else>>working<</if>> on @@.yellow;_task.product.@@ It will take approximately <<print (Math.floor($researchLab.productionTime / $researchLab.speed) + 1)>> week(s) to complete.
+			<<else>>
+				<<set _work -= _task.workLeft>>
+				<<if _task.type == "research">>
+					Your lab staff have @@.green;completed@@ their _task.product research project.
+					<<switch _task.product>>
+					<<case "Basic prosthetics interface">>
+						<<set $researchLab.basicPLimbInterface = 1>>
+					<<case "Advanced prosthetics interface">>
+						<<set $researchLab.advPLimbInterface = 1>>
+					<<case "Basic prosthetic limbs">>
+						<<set $researchLab.basicPLimb = 1>>
+					<<case "Advanced sex limbs">>
+						<<set $researchLab.advSexPLimb = 1>>
+					<<case "Advanced beauty limbs">>
+						<<set $researchLab.advGracePLimb = 1>>
+					<<case "Advanced combat limbs">>
+						<<set $researchLab.advCombatPLimb = 1>>
+					<<case "Cybernetic limbs">>
+						<<set $researchLab.cyberneticPLimb = 1>>
+					<<case "Ocular implants">>
+						<<set $researchLab.ocularImplant = 1>>
+					<<case "Cochlear implants">>
+						<<set $researchLab.cochlearImplant = 1>>
+					<<case "Electrolarynx">>
+						<<set $researchLab.electrolarynx = 1>>
+					/*<<case "Erectile implant">>
+						<<set $researchLab.erectileImplant = 1>>*/
+					<</switch>>
+				<<else>>
+					Your lab staff have @@.green;completed@@ their _task.product construction project.
+					<<switch _task.product>>
+					<<case "Basic prosthetics interface">>
+						<<set $stockpile.basicPLimbInterface += 1>>
+					<<case "Advanced prosthetics interface">>
+						<<set $stockpile.advPLimbInterface += 1>>
+					<<case "Basic prosthetic limbs">>
+						<<set $stockpile.basicPLimb += 1>>
+					<<case "Advanced sex limbs">>
+						<<set $stockpile.advSexPLimb += 1>>
+					<<case "Advanced beauty limbs">>
+						<<set $stockpile.advGracePLimb += 1>>
+					<<case "Advanced combat limbs">>
+						<<set $stockpile.advCombatPLimb += 1>>
+					<<case "Cybernetic limbs">>
+						<<set $stockpile.cyberneticPLimb += 1>>
+					<<case "Ocular implants">>
+						<<set $stockpile.ocularImplant += 1>>
+					<<case "Cochlear implants">>
+						<<set $stockpile.cochlearImplant += 1>>
+					<<case "Electrolarynx">>
+						<<set $stockpile.electrolarynx += 1>>
+					/*<<case "Erectile implant">>
+						<<set $stockpile.erectileImplant += 1, $researchLab.productionTime = 50>>*/
+					<</switch>>
+				<</if>>
+				<<set $researchLab.tasks.shift(), _task = $researchLab.tasks[0]>>
+				<<if ndef _task>>
+					<<set _cashX = (_work * 90), _work = 0>>
+					<br>Your lab has @@.green;finished all projects.@@ The remaining time is used for contract work earning you @@.yellowgreen;<<print cashFormat(_cashX)>>.@@
+					<<run cashX(_cashX, "lab")>>
+				<</if>>
+			<</if>>
+			<br>
+		<</for>>
 	<</if>>
 <</if>>
-- 
GitLab