From 1f79e9cb9f283653fc19cf4ed8f6136164b6e68f Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Sat, 18 Mar 2017 08:32:22 -0400
Subject: [PATCH] Bugfixes, corp overhaul mod.

---
 src/gui/Encyclopedia/encyclopedia.tw         |   3 +-
 src/gui/css/accordianStyleSheet.tw           |  38 +-
 src/js/textboxJS.tw                          |  28 +
 src/pregmod/electiveSurgery.tw               |  24 +-
 src/pregmod/incubator.tw                     |   2 +-
 src/uncategorized/corporationDevelopments.tw | 573 ++++++++++---------
 src/uncategorized/slaveAssignmentsReport.tw  | 245 ++++++--
 7 files changed, 583 insertions(+), 330 deletions(-)
 create mode 100644 src/js/textboxJS.tw

diff --git a/src/gui/Encyclopedia/encyclopedia.tw b/src/gui/Encyclopedia/encyclopedia.tw
index f3b0747f98c..3e5e23a3a26 100644
--- a/src/gui/Encyclopedia/encyclopedia.tw
+++ b/src/gui/Encyclopedia/encyclopedia.tw
@@ -930,7 +930,8 @@ __I do not give credit without explicit permission to do so.__ If you have contr
 ''anon'' for HGExclusion and animal pregnancy work.
 ''anon'' for putting up with my javascript incompetence.
 ''anon'' for player family listing.
-''anon'' for interchangable prosthetics, advanced facial surgeries and custom nationality distribution.
+''anon'' for interchangable prosthetics, advanced facial surgeries, custom nationality distribution and corporation assets overhaul.
+''anon'' for forcing dicks onto slavegirls.
 ''brpregmodfan'' for Brazilian start and slave gen.
 ''Bane70'' optimized huge swaths of code with notable professionalism.
 ''Circle Tritagonist'' provided several new collars and outfits.
diff --git a/src/gui/css/accordianStyleSheet.tw b/src/gui/css/accordianStyleSheet.tw
index 3f8434a1b40..b93cc9bca2e 100644
--- a/src/gui/css/accordianStyleSheet.tw
+++ b/src/gui/css/accordianStyleSheet.tw
@@ -6,14 +6,16 @@ button.accordion {
     padding: 5px;
     width: 100%;
     margin-bottom: 10px;
-    border-bottom: 3px double;
-    border-right: 3px double;
+    border-bottom: 2px double grey;
+    border-right: none;
     border-left: none;
     border-top: none;
     text-align: left;
     outline: none;
     transition: 0.4s;
+    -webkit-transition-duration: 0.4s; /* Safari */
     background-color: transparent;
+    font-weight: 900;
 }
 
 button.accordion.active, button.accordion:hover {
@@ -28,6 +30,38 @@ button.accordion:before {
     margin-right: 5px;
 }
 
+.unStaffed {
+    background-color: transparent;
+    padding: .5em .2em;
+    margin-bottom: 1em;
+    border-bottom: thin inset grey;
+}
+
+.unStaffed:before {
+    content: '\00D7';
+    color: #777;
+    font-weight: bold;
+    color: red;
+    float: left;
+    margin-right: 5px;
+}
+
+.unStaffed:after {
+    content: attr(data-after);
+    float: right;
+    margin-left: 2em;
+    font-weight: strong;
+    color: green;
+}
+
+button.accordion:after {
+    content: attr(data-after);
+    float: right;
+    margin-left: 2em;
+    font-weight: normal;
+    color: green;
+}
+
 button.accordion.active:before {
     content: "\2212";
 }
diff --git a/src/js/textboxJS.tw b/src/js/textboxJS.tw
new file mode 100644
index 00000000000..100a9b896bc
--- /dev/null
+++ b/src/js/textboxJS.tw
@@ -0,0 +1,28 @@
+:: textboxJS [script]
+
+/* Nicked off greyelf, works for <<replace>> textboxes */
+window.setTextboxMaxLength = function (storyVarName, maxLength) {
+	var textboxId = '#textbox-' + Util.slugify(storyVarName);
+	$(textboxId)
+			.attr('maxlength', maxLength)
+			.css({
+				'min-width' : 'initial',
+				width       : maxLength + 'em',
+				padding		: '3px 2px'
+			});
+};
+
+/* Nicked off TheMadExile, works for non-<<replace>> textboxes */
+window.setTextboxMaxLength = function (storyVarName, maxLength) {
+	var textboxId = '#textbox-' + Util.slugify(storyVarName);
+	postdisplay[textboxId + '-maxlength'] = function (taskName) {
+		delete postdisplay[taskName];
+		$(textboxId)
+			.attr('maxlength', maxLength)
+			.css({
+				'min-width' : 'initial',
+				width       : maxLength + 'em',
+				padding		: '3px 2px'
+			});
+	};
+};
diff --git a/src/pregmod/electiveSurgery.tw b/src/pregmod/electiveSurgery.tw
index 9f3e71843b6..7e9d2051398 100644
--- a/src/pregmod/electiveSurgery.tw
+++ b/src/pregmod/electiveSurgery.tw
@@ -3,67 +3,87 @@
 You arrive at your favorite plastic surgeon for your appointment to find them as busy as ever. She wastes no time in hurrying in into their office, stripping you down, measuring you and making sure you are healthy enough for surgery, all the while not so subtly running her hands across every part of you. "So, what can I help you with?"
 
 <br><br>
-"You sure you want to mess with that lovely face?" She states, caressing your cheek.
+"You sure you want to mess with that lovely face?" She teases, caressing your cheek. "<<print $surgeryCost*2>>¤."
 You're $PC.actualAge old.
 <<if $PC.actualAge >= 65>>
 	<<if $PC.visualAge > $PC.actualAge>>
 		You've had surgery to make yourself look older.
+		<br>[[Undo Facial surgery|PC Surgery Degradation][$PC.faceImplant = 0,$cash -= $surgeryCost*2, $surgeryType to "restoreFace"]]
 	<<elseif $PC.visualAge < $PC.actualAge>>
 		You've had surgery to make yourself look younger.
+		<br>[[Undo Facial surgery|PC Surgery Degradation][$PC.faceImplant = 0,$cash -= $surgeryCost*2, $surgeryType to "restoreFace"]]
 	<<else>>
 		You could benefit from a face lift.
+		<br>[[Get a face lift|PC Surgery Degradation][$PC.faceImplant = 1,$cash -= $surgeryCost*2, $surgeryType to "ageDown"]] | [[Remodel your face to appear older|PC Surgery Degradation][$PC.faceImplant = 1,$cash -= $surgeryCost*2, $surgeryType to "ageUp"]]
 	<</if>>
 <<elseif $PC.actualAge >= 50>>
 	<<if $PC.visualAge > $PC.actualAge>>
 		You've had surgery to make yourself look older.
+		<br>[[Undo Facial surgery|PC Surgery Degradation][$PC.faceImplant = 0,$cash -= $surgeryCost*2, $surgeryType to "restoreFace"]]
 	<<elseif $PC.visualAge < $PC.actualAge>>
 		You've had surgery to make yourself look younger.
+		<br>[[Undo Facial surgery|PC Surgery Degradation][$PC.faceImplant = 0,$cash -= $surgeryCost*2, $surgeryType to "restoreFace"]]
 	<<else>>
 		You could benefit from a face lift.
+		<br>[[Get a face lift|PC Surgery Degradation][$PC.faceImplant = 1,$cash -= $surgeryCost*2, $surgeryType to "ageDown"]] | [[Remodel your face to appear older|PC Surgery Degradation][$PC.faceImplant = 1,$cash -= $surgeryCost*2, $surgeryType to "ageUp"]]
 	<</if>>
 <<elseif $PC.actualAge >= 35>>
 	<<if $PC.visualAge > $PC.actualAge>>
 		You've had surgery to make yourself look older.
+		<br>[[Undo Facial surgery|PC Surgery Degradation][$PC.faceImplant = 0,$cash -= $surgeryCost*2, $surgeryType to "restoreFace"]]
 	<<elseif $PC.visualAge < $PC.actualAge>>
 		You've had surgery to make yourself look younger.
+		<br>[[Undo Facial surgery|PC Surgery Degradation][$PC.faceImplant = 0,$cash -= $surgeryCost*2, $surgeryType to "restoreFace"]]
 	<<else>>
 		You could go for a face lift, though making yourself look older could be useful.
+		<br>[[Get a face lift|PC Surgery Degradation][$PC.faceImplant = 1,$cash -= $surgeryCost*2, $surgeryType to "ageDown"]] | [[Remodel your face to appear older|PC Surgery Degradation][$PC.faceImplant = 1,$cash -= $surgeryCost*2, $surgeryType to "ageUp"]]
 	<</if>>
 <<else>>
 	<<if $PC.visualAge > $PC.actualAge>>
 		You've had surgery to make yourself look older.
+		<br>[[Undo Facial surgery|PC Surgery Degradation][$PC.faceImplant = 0,$cash -= $surgeryCost*2, $surgeryType to "restoreFace"]]
 	<<elseif $PC.visualAge < $PC.actualAge>>
 		You've had surgery to make yourself look younger.
+		<br>[[Undo Facial surgery|PC Surgery Degradation][$PC.faceImplant = 0,$cash -= $surgeryCost*2, $surgeryType to "restoreFace"]]
 	<<else>>
 		You could undergo facial surgery to make yourself look older, though you could also make yourself look even younger.
+		<br>[[Remodel your face to appear younger|PC Surgery Degradation][$PC.faceImplant = 1,$cash -= $surgeryCost*2, $surgeryType to "ageDown"]] | [[Remodel your face to appear older|PC Surgery Degradation][$PC.faceImplant = 1,$cash -= $surgeryCost*2, $surgeryType to "ageUp"]]
 	<</if>>
 <</if>>
 
-<br>"Maybe some breast work? I assure you they are lovely." She says as she brushes the back of your head with her own pair.<br>
+<br>"Maybe some breast work? I assure you they are lovely." She says as she brushes the back of your head with her own pair. "5000¤ for a reduction, 10000¤ for implants, that includes size ups, and 15000¤ for additional breast tissue. That last one might as well be real!"<br>
 <<if $PC.boobsBonus > 0>>
 	<<if $PC.boobsBonus > 2>>
 		<<if $PC.boobsImplant == 1>>
 			You have a pair of round H-cup breasts; they are very obviously implants.
+			<br>[[Have your implants removed|PC Surgery Degradation][$PC.boobsBonus = 0, $PC.boobsImplants = 0, $cash -= 5000, $surgeryType to "breastReductionImplant"]]
 		<<else>>
 			You have a heavy H-cup bust. They tend to sag a little when you free them from your top, though they have some perk to them.
+			<br>[[Have tissue removed|PC Surgery Degradation][$PC.boobsBonus = 2, $cash -= 5000, $surgeryType to "breastShrinkage"]]
 		<</if>>
 	<<elseif $PC.boobsBonus == 2>>
 		<<if $PC.boobsImplant == 1>>
 			You have a pair of rounded G-cup breasts; they are a little too perky for their size to pass as natural.
+			<br>[[Have your implants removed|PC Surgery Degradation][$PC.boobsBonus = 0, $PC.boobsImplants = 0, $cash -= 5000, $surgeryType to "breastReductionImplant"]] | [[Get the next size up|PC Surgery Degradation][$PC.boobsBonus = 3, $cash -= 10000, $surgeryType to "breastEnlargementImplant"]]
 		<<else>>
 			You have a huge G-cup bust.
+			<br>[[Add additional breast tissue|PC Surgery Degradation][$PC.boobsBonus = 3, $cash -= 15000, $surgeryType to "breastEnlargement"]] | [[Have tissue removed|PC Surgery Degradation][$PC.boobsBonus = 1, $cash -= 5000, $surgeryType to "breastShrinkage"]]
 		<</if>>
 	<<elseif $PC.boobsBonus == 1>>
 		<<if $PC.boobsImplant == 1>>
 			You have a pair of perky F-cup breasts; you can barely tell they are implanted.
+			<br>[[Have your implants removed|PC Surgery Degradation][$PC.boobsBonus = 0, $PC.boobsImplants = 0, $cash -= 5000, $surgeryType to "breastReductionImplant"]] | [[Get the next size up|PC Surgery Degradation][$PC.boobsBonus = 2, $cash -= 10000, $surgeryType to "breastEnlargementImplant"]]
 		<<else>>
 			You have a hefty F-cup bust.
+			<br>[[Add additional breast tissue|PC Surgery Degradation][$PC.boobsBonus = 2, $cash -= 15000, $surgeryType to "breastEnlargement"]] | [[Have tissue removed|PC Surgery Degradation][$PC.boobsBonus = 0, $cash -= 5000, $surgeryType to "breastShrinkage"]]
 		<</if>>
 	<</if>>
 <<elseif $PC.boobs == 1>>
 	You have a big pair of DD breasts.
+	<br>[[Get a pair of breast implants|PC Surgery Degradation][$PC.boobsBonus = 1, $PC.boobsImplants = 1, $cash -= 10000, $surgeryType to "breastEnlargementImplant"]] | [[Add additional breast tissue|PC Surgery Degradation][$PC.boobsBonus = 1, $cash -= 15000, $surgeryType to "breastEnlargement"]] | [[Have them removed|PC Surgery Degradation][$PC.boobs = 0, $cash -= 5000, $surgeryType to "flatChest"]]
 <<else>>
 	You have a masculine chest. At your request, breast tissue could be added until you have a healthy bust, though society is unlikely to approve.
+	<br>[[Get a pair of breasts|PC Surgery Degradation][$PC.boobs = 1, $cash -= 15000, $surgeryType to "breasts"]]
 <</if>>
 	
 <<if $PC.preg >= 8>>
diff --git a/src/pregmod/incubator.tw b/src/pregmod/incubator.tw
index 92d54b148a5..802c733fcd8 100644
--- a/src/pregmod/incubator.tw
+++ b/src/pregmod/incubator.tw
@@ -4,7 +4,7 @@
 <<set $nextButton to "Back to Main">>
 <<set $nextLink to "Main">>
 <<set $returnTo to "Incubator">>
-<<set $targetAge to Math.clamp($targetAge, $minimumSlaveAge, 18)>>
+<<set $targetAge to Math.clamp($targetAge, $minimumSlaveAge, 42)>>
 
 <<if $incubatorName != "the Incubator">>
 	<<set $incubatorNameCaps to $incubatorName.replace("the ", "The ")>>
diff --git a/src/uncategorized/corporationDevelopments.tw b/src/uncategorized/corporationDevelopments.tw
index 0c1dbd3c0aa..d65d4ea36c4 100644
--- a/src/uncategorized/corporationDevelopments.tw
+++ b/src/uncategorized/corporationDevelopments.tw
@@ -1,5 +1,13 @@
 :: Corporation Developments [nobr]
-
+<<if ndef _NumGeneral || ndef _NumSlaves || ndef _NumEntrap || ndef _NumCapture || ndef _NumTrain || ndef _NumSurgery || ndef _NumPharma>>
+<<set _NumGeneral = 1>>
+<<set _NumSlaves = 1>>
+<<set _NumEntrapment = 1>>
+<<set _NumCapture = 1>>
+<<set _NumTraining = 1>>
+<<set _NumSurgery = 1>>
+<<set _NumDrug = 1>>
+<</if>>
 __The Corporation__
 <br>
 
@@ -131,10 +139,9 @@ You hold $personalShares shares personally while $publicShares are publicly held
 
 <br>
 &nbsp;&nbsp;&nbsp;&nbsp;
-<span id="purchasing">
+<span id="purchasing"></span>
 <span id="cashOnHand">¤$corpCash </span>in cash on hand.
-<span id="update">
-</span>
+<span id="update"></span>
 
 <br>
 <<if $generalAssetPrice > 10>>
@@ -159,126 +166,137 @@ You hold $personalShares shares personally while $publicShares are publicly held
 	<</if>>
 <</if>>
 &nbsp;&nbsp;&nbsp;&nbsp;
-<span id="genAssets">¤<<print $generalAssetPrice*$generalAssets>></span> in general assets.
-General asset prices are
-<<if $generalAssetPrice > 12>>@@color:yellowgreen;very high@@<<elseif $generalAssetPrice > 10>>@@color:yellowgreen;high@@<<elseif $generalAssetPrice == 10>>average<<elseif $generalAssetPrice >= 8>>@@color:gold;low@@<<else>>@@color:gold;very low@@<</if>>.
-| <<link "Buy">>
-	<<if $generalAssetPrice*500 < $corpCash>>
-		<<set $generalAssets += 500>>
-		<<set $corpCash -= 500*$generalAssetPrice>>
+<span id="genAssets">¤<<print $generalAssetPrice*$generalAssets>> (<<print $generalAssets/500>> unit<<if $generalAssets/500 > 1>>s<</if>>)</span> in general assets.
+Prices are 
+<<if $generalAssetPrice > 10>>
+	@@color:yellowgreen;¤<<print $generalAssetPrice*500>>ea@@.
+<<elseif $generalAssetPrice < 10>>
+	@@color:gold;¤<<print $generalAssetPrice*500>>ea@@.
+<<else>>
+	¤<<print $generalAssetPrice*500>>ea.
+<</if>>
+| Trade Qty <<textbox "_NumGeneral" _NumGeneral>><<script>>setTextboxMaxLength('_NumGeneral', 5);<</script>>
+ : <<link "Buy">>
+	<<if Number.isInteger(Number.parseFloat(_NumGeneral)) == false>>
+		<<replace "#genAssetsPurchasing">>
+		Please input a round number.
+		<</replace>>
+	<<elseif _NumGeneral*$generalAssetPrice*500 < $corpCash>>
+		<<set $generalAssets += _NumGeneral*500>>
+		<<set $corpCash -= _NumGeneral*500*$generalAssetPrice>>
 		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
 		<<replace "#genAssets">>
-			¤<<print $generalAssetPrice*$generalAssets>>
-		<</replace>>
-		<<replace "#update">>
+			¤<<print $generalAssetPrice*$generalAssets>> (<<print $generalAssets/500>> unit<<if $generalAssets/500 > 1>>s<</if>>)
 		<</replace>>
+		<<replace "#genAssetsPurchasing">><</replace>>
+	<<elseif $corpCash > $generalAssetPrice*500>>
+		<<replace "#genAssetsPurchasing">> You can only buy <<print Math.floor($corpCash/($generalAssetPrice*500))>> more unit<<if Math.floor($corpCash/($generalAssetPrice*500)) > 1 >>s<</if>> of this asset. <</replace>>
 	<<else>>
-	<<replace "#purchasing">>
+		<<replace "#genAssetsPurchasing">>
 		There are insufficient funds for additional purchases.
-	<</replace>>
-	<</if>>
-<</link>>
-| <<link "Massive investment">>
-	 <<if $generalAssetPrice*1000 < $corpCash>>
-		<<set $generalAssets += (Math.trunc($corpCash/($generalAssetPrice*500)))*500>>
-		<<set $corpCash -= (Math.trunc($corpCash/($generalAssetPrice*500)))*($generalAssetPrice*500)>>
-	 	<<replace "#cashOnHand">>
-			¤<<print $corpCash>>
 		<</replace>>
-		<<replace "#genAssets">>
-			¤<<print $generalAssetPrice*$generalAssets>>
-		<</replace>>
-	<<else>>
-	<<replace "#purchasing">>
-		There are insufficient funds for additional purchases.
-	<</replace>>
 	<</if>>
 <</link>>
 | <<link "Sell">>
-	<<if $generalAssets >= 1000>>
-		<<set $generalAssets -= 500>>
-		<<set $corpCash += 500*$generalAssetPrice>>
+	<<if Number.isInteger(Number.parseFloat(_NumGeneral)) == false>>
+		<<replace "#genAssetsPurchasing">>
+		Please input a round number.
+		<</replace>>
+	<<elseif $generalAssets > 500 && (_NumGeneral*500) < $generalAssets>>
+		<<set $generalAssets -= _NumGeneral*500>>
+		<<set $corpCash += _NumGeneral*500*$generalAssetPrice>>
 		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
 		<<replace "#genAssets">>
-			¤<<print $generalAssetPrice*$generalAssets>>
+			¤<<print $generalAssetPrice*$generalAssets>> (<<print $generalAssets/500>> unit<<if $generalAssets > 1>>s<</if>>)
+		<</replace>>
+		<<replace "#genAssetsPurchasing">>
 		<</replace>>
-		<<replace "#update">>
+	<<elseif $generalAssets > 500>>
+		<<replace "#genAssetsPurchasing">>
+			You can only sell <<print Math.floor(($generalAssets-500)/500)>> more unit<<if Math.floor(($generalAssets-500)/500) > 1 >>s<</if>> of this asset.
 		<</replace>>
 	<<else>>
-		<<replace "#update">>
-			You cannot sell any more assets.
+		<<replace "#genAssetsPurchasing">>
+			You cannot sell any more of this asset.
 		<</replace>>
 	<</if>>
 <</link>>
-
-
-
+<span id="genAssetsPurchasing"></span>
 <br>
+
 <<set $slaveAssetPrice = Math.trunc(10*$slaveCostFactor)>>
 &nbsp;&nbsp;&nbsp;&nbsp;
-<span id="slavAssets">¤<<print $slaveAssetPrice*$slaveAssets>></span> in slaves.
-Slave prices are
-<<if $slaveAssetPrice > 12>>@@color:yellowgreen;very high@@<<elseif $slaveAssetPrice > 10>>@@color:yellowgreen;high@@<<elseif $slaveAssetPrice == 10>>average<<elseif $slaveAssetPrice >= 8>>@@color:gold;low@@<<else>>@@color:gold;very low@@<</if>>.
-| <<link "Buy">>
-	 <<if $slaveAssetPrice*500 < $corpCash>>
-		<<set $slaveAssets += 500>>
-		<<set $corpPeopleEnslaved += Math.trunc((500*$slaveAssetPrice)/1000)>>
-		<<set $corpCash -= 500*$slaveAssetPrice>>
+<span id="slaveAssets">¤<<print $slaveAssetPrice*$slaveAssets>> (<<print Math.floor($slaveAssets/500)>> unit<<if Math.floor($slaveAssets/500) > 1>>s<</if>>)</span> in slaves.
+Prices are 
+<<if $slaveAssetPrice > 10>>
+	@@color:yellowgreen;¤<<print $slaveAssetPrice*500>>ea@@
+<<elseif $slaveAssetPrice < 10>>
+	@@color:gold;¤<<print $slaveAssetPrice*500>>ea@@
+<<else>>
+	¤<<print $slaveAssetPrice*500>>ea
+<</if>>
+| Trade Qty <<textbox "_NumSlaves" _NumSlaves>><<script>>setTextboxMaxLength('_NumSlaves', 5);<</script>>
+ : <<link "Buy">>
+	<<if Number.isInteger(Number.parseFloat(_NumSlaves)) == false>>
+		<<replace "#slaveAssetsPurchasing">>
+		Please input a round number.
+		<</replace>>
+	<<elseif _NumSlaves*$slaveAssetPrice*500 < $corpCash>>
+		<<set $slaveAssets += _NumSlaves*500>>
+		<<set $corpCash -= _NumSlaves*500*$slaveAssetPrice>>
 		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
-		<<replace "#slavAssets">>
-			¤<<print $slaveAssetPrice*$slaveAssets>>
-		<</replace>>
-		<<replace "#update">>
+		<<replace "#slaveAssets">>
+			¤<<print $slaveAssetPrice*$slaveAssets>> (<<print Math.floor($slaveAssets/500)>> unit<<if $slaveAssets/500 > 1>>s<</if>>)
 		<</replace>>
+		<<replace "#slaveAssetsPurchasing">><</replace>>
+	<<elseif $corpCash > $slaveAssetPrice*500>>
+		<<replace "#slaveAssetsPurchasing">> The corp can only buy <<print Math.floor($corpCash/($slaveAssetPrice*500))>> more unit<<if Math.floor($corpCash/($slaveAssetPrice*500)) > 1 >>s<</if>> of this asset. <</replace>>
 	<<else>>
-	<<replace "#purchasing">>
+	<<replace "#slaveAssetsPurchasing">>
 		There are insufficient funds for additional purchases.
 	<</replace>>
 	<</if>>
 <</link>>
-| <<link "Massive investment">>
-	<<if $slaveAssetPrice*1000 < $corpCash>>
-		<<set $slaveAssets += (Math.trunc($corpCash/($slaveAssetPrice*500)))*500>>
-		<<set $corpPeopleEnslaved += Math.trunc(($corpCash/($slaveAssetPrice*2))/1000)>>
-		<<set $corpCash -= (Math.trunc($corpCash/($slaveAssetPrice*500)))*($slaveAssetPrice*500)>>
-	 	<<replace "#cashOnHand">>
-			¤<<print $corpCash>>
-		<</replace>>
-		<<replace "#slavAssets">>
-			¤<<print $slaveAssetPrice*$slaveAssets>>
-		<</replace>>
-	<<else>>
-		<<replace "#purchasing">>
-			There are insufficient funds for additional purchases.
-		<</replace>>
-	<</if>>
-<</link>>
 | <<link "Sell">>
-	<<if $slaveAssets >= 1000>>
-		<<set $slaveAssets -= 500>>
-		<<set $corpCash += 500*$slaveAssetPrice>>
+	<<if Number.isInteger(Number.parseFloat(_NumSlaves)) == false>>
+		<<replace "#slaveAssetsPurchasing">>
+		Please input a round number.
+		<</replace>>
+	<<elseif $slaveAssets >500 && (_NumSlaves*500) < $slaveAssets>>
+		<<set $slaveAssets -= _NumSlaves*500>>
+		<<set $corpCash += _NumSlaves*500*$slaveAssetPrice>>
 		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
-		<<replace "#slavAssets">>
-			¤<<print $slaveAssetPrice*$slaveAssets>>
+		<<replace "#slaveAssets">>
+				¤<<print $slaveAssetPrice*$slaveAssets>> 
+					<<if $slaveAssetPrice*$slaveAssets < $slaveAssetPrice*500>>
+					(<1 unit)
+					<<else>>
+					(<<print Math.floor($slaveAssets/500)>> unit<<if Math.floor($slaveAssets/500) > 1>>s<</if>>)
+					<</if>>
+		<</replace>>
+		<<replace "#slaveAssetsPurchasing">>
 		<</replace>>
-		<<replace "#update">>
+	<<elseif $slaveAssets > 500>>
+		<<replace "#slaveAssetsPurchasing">>
+			The corp can only sell <<print Math.ceil(($slaveAssets-500)/500)>> more unit<<if Math.ceil(($slaveAssets-500)/500) > 1 >>s<</if>> of this asset.
 		<</replace>>
 	<<else>>
-		<<replace "#update">>
-			You cannot sell any more assets.
+		<<replace "#slaveAssetsPurchasing">>
+			The corp cannot sell any more of this asset.
 		<</replace>>
 	<</if>>
 <</link>>
-
+<span id="slaveAssetsPurchasing"></span>
 <br>
+
 <<if $entrapmentAssetPrice > 10>>
 	<<if random(1,100) > 50>>
 	<<set $entrapmentAssetPrice -= 1>>
@@ -303,64 +321,68 @@ Slave prices are
 	<<set $entrapmentAssetPrice to 5>>
 <</if>>
 &nbsp;&nbsp;&nbsp;&nbsp;
-<span id="trapAssets">¤<<print $entrapmentAssetPrice*$entrapmentAssets>></span> in legal enslavement assets.
-Legal enslavement asset prices are
-<<if $entrapmentAssetPrice > 12>>@@color:yellowgreen;very high@@<<elseif $entrapmentAssetPrice > 10>>@@color:yellowgreen;high@@<<elseif $entrapmentAssetPrice == 10>>average<<elseif $entrapmentAssetPrice >= 8>>@@color:gold;low@@<<else>>@@color:gold;very low@@<</if>>.
-| <<link "Buy">>
-	<<if $entrapmentAssetPrice*500 < $corpCash>>
-		<<set $entrapmentAssets += 500>>
-		<<set $corpCash -= 500*$entrapmentAssetPrice>>
-		<<replace "#cashOnHand">>
-			¤<<print $corpCash>>
-		<</replace>>
-		<<replace "#trapAssets">>
-			¤<<print $entrapmentAssetPrice*$entrapmentAssets>>
-		<</replace>>
-		<<replace "#update">>
-		<</replace>>
-	<<else>>
-		<<replace "#purchasing">>
-			There are insufficient funds for additional purchases.
+<span id="trapAssets">¤<<print $entrapmentAssetPrice*$entrapmentAssets>> (<<print Math.floor($entrapmentAssets/500)>> unit<<if Math.floor($entrapmentAssets/500) > 1>>s<</if>>)</span> in legal enslavement assets.
+Prices are 
+<<if $entrapmentAssetPrice > 10>>
+	@@color:yellowgreen;¤<<print $entrapmentAssetPrice*500>>ea@@
+<<elseif $entrapmentAssetPrice < 10>>
+	@@color:gold;¤<<print $entrapmentAssetPrice*500>>ea@@
+<<else>>
+	¤<<print $entrapmentAssetPrice*500>>ea
+<</if>>
+| Trade Qty <<textbox "_NumEntrapment" _NumEntrapment>><<script>>setTextboxMaxLength('_NumEntrapment', 5);<</script>>
+ : <<link "Buy">>
+	<<if Number.isInteger(Number.parseFloat(_NumEntrapment)) == false>>
+		<<replace "#entrapmentAssetsPurchasing">>
+		Please input a round number.
 		<</replace>>
-	<</if>>
-<</link>>
-| <<link "Massive investment">>
-	<<if $entrapmentAssetPrice*1000 < $corpCash>>
-		<<set $entrapmentAssets += (Math.trunc($corpCash/($entrapmentAssetPrice*500)))*500>>
-		<<set $corpCash -= (Math.trunc($corpCash/($entrapmentAssetPrice*500)))*($entrapmentAssetPrice*500)>>
-	 	<<replace "#cashOnHand">>
+	<<elseif _NumEntrapment*$entrapmentAssetPrice*500 < $corpCash>>
+		<<set $entrapmentAssets += _NumEntrapment*500>>
+		<<set $corpCash -= _NumEntrapment*500*$entrapmentAssetPrice>>
+		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
 		<<replace "#trapAssets">>
-			¤<<print $entrapmentAssetPrice*$entrapmentAssets>>
+			¤<<print $entrapmentAssetPrice*$entrapmentAssets>> (<<print Math.floor($entrapmentAssets/500)>> unit<<if $entrapmentAssets/500 > 1>>s<</if>>)
 		<</replace>>
+		<<replace "#entrapmentAssetsPurchasing">><</replace>>
+	<<elseif $corpCash > $entrapmentAssetPrice*500>>
+		<<replace "#entrapmentAssetsPurchasing">> The corp can only buy <<print Math.floor($corpCash/($entrapmentAssetPrice*500))>> more unit<<if Math.floor($corpCash/($entrapmentAssetPrice*500)) > 1 >>s<</if>> this asset. <</replace>>
 	<<else>>
-		<<replace "#purchasing">>
-			There are insufficient funds for additional purchases.
-		<</replace>>
+	<<replace "#entrapmentAssetsPurchasing">>
+		There are insufficient funds for additional purchases.
+	<</replace>>
 	<</if>>
 <</link>>
 | <<link "Sell">>
-	<<if $entrapmentAssets >= 1000>>
-		<<set $entrapmentAssets -= 500>>
-		<<set $corpCash += 500*$entrapmentAssetPrice>>
+	<<if Number.isInteger(Number.parseFloat(_NumEntrapment)) == false>>
+		<<replace "#entrapmentAssetsPurchasing">>
+		Please input a round number.
+		<</replace>>
+	<<elseif $entrapmentAssets > 500 && ((_NumEntrapment*500) < $entrapmentAssets)>>
+		<<set $entrapmentAssets -= _NumEntrapment*500>>
+		<<set $corpCash += _NumEntrapment*500*$entrapmentAssetPrice>>
 		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
 		<<replace "#trapAssets">>
-			¤<<print $entrapmentAssetPrice*$entrapmentAssets>>
+			¤<<print $entrapmentAssetPrice*$entrapmentAssets>> (<<print Math.floor($entrapmentAssets/500)>> unit<<if Math.floor($entrapmentAssets/500) > 1>>s<</if>>)
 		<</replace>>
-		<<replace "#update">>
+		<<replace "#entrapmentAssetsPurchasing">>
+		<</replace>>
+	<<elseif $entrapmentAssets > 500>>
+		<<replace "#entrapmentAssetsPurchasing">>
+			The corp can only sell <<print Math.floor(($entrapmentAssets-500)/500)>> more unit<<if Math.floor(($entrapmentAssets-500)/500) > 1 >>s<</if>> of this asset.
 		<</replace>>
 	<<else>>
-		<<replace "#update">>
-			You cannot sell any more assets.
+		<<replace "#entrapmentAssetsPurchasing">>
+			The corp cannot sell any more of this asset.
 		<</replace>>
 	<</if>>
 <</link>>
-
-
+<span id="entrapmentAssetsPurchasing"></span>
 <br>
+
 <<if $captureAssetPrice > 10>>
 	<<if random(1,100) > 50>>
 	<<set $captureAssetPrice -= 1>>
@@ -385,61 +407,66 @@ Legal enslavement asset prices are
 	<<set $captureAssetPrice to 5>>
 <</if>>
 &nbsp;&nbsp;&nbsp;&nbsp;
-<span id="capAssets">¤<<print $captureAssetPrice*$captureAssets>></span> in conflict zone enslavement assets.
-Extralegal enslavement asset prices are
-<<if $captureAssetPrice > 12>>@@color:yellowgreen;very high@@<<elseif $captureAssetPrice > 10>>@@color:yellowgreen;high@@<<elseif $captureAssetPrice == 10>>average<<elseif $captureAssetPrice >= 8>>@@color:gold;low@@<<else>>@@color:gold;very low@@<</if>>.
-| <<link "Buy">>
-	<<if $captureAssetPrice*500 < $corpCash>>
-		<<set $captureAssets += 500>>
-		<<set $corpCash -= 500*$captureAssetPrice>>
-		<<replace "#cashOnHand">>
-			¤<<print $corpCash>>
-		<</replace>>
-		<<replace "#capAssets">>
-			¤<<print $captureAssetPrice*$captureAssets>>
-		<</replace>>
-		<<replace "#update">>
-		<</replace>>
-	<<else>>
-		<<replace "#purchasing">>
-			There are insufficient funds for additional purchases.
+<span id="capAssets">¤<<print $captureAssetPrice*$captureAssets>> (<<print Math.floor($captureAssets/500)>> unit<<if Math.floor($captureAssets/500) > 1>>s<</if>>)</span> in conflict zone enslavement assets.
+Prices are 
+<<if $captureAssetPrice > 10>>
+	@@color:yellowgreen;¤<<print $captureAssetPrice*500>>ea@@
+<<elseif $captureAssetPrice < 10>>
+	@@color:gold;¤<<print $captureAssetPrice*500>>ea@@
+<<else>>
+	¤<<print $captureAssetPrice*500>>ea
+<</if>>
+| Trade Qty <<textbox "_NumCapture" _NumCapture>><<script>>setTextboxMaxLength('_NumCapture', 5);<</script>>
+ : <<link "Buy">>
+	<<if Number.isInteger(Number.parseFloat(_NumCapture)) == false>>
+		<<replace "#captureAssetsPurchasing">>
+		Please input a round number.
 		<</replace>>
-	<</if>>
-<</link>>
-| <<link "Massive investment">>
-	<<if $captureAssetPrice*1000 < $corpCash>>
-		<<set $captureAssets += (Math.trunc($corpCash/($captureAssetPrice*500)))*500>>
-		<<set $corpCash -= (Math.trunc($corpCash/($captureAssetPrice*500)))*($captureAssetPrice*500)>>
-	 	<<replace "#cashOnHand">>
+	<<elseif _NumCapture*$captureAssetPrice*500 < $corpCash>>
+		<<set $captureAssets += _NumCapture*500>>
+		<<set $corpCash -= _NumCapture*500*$captureAssetPrice>>
+		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
 		<<replace "#capAssets">>
-			¤<<print $captureAssetPrice*$captureAssets>>
+			¤<<print $captureAssetPrice*$captureAssets>> (<<print Math.floor($captureAssets/500)>> unit<<if $captureAssets/500 > 1>>s<</if>>)
 		<</replace>>
+		<<replace "#captureAssetsPurchasing">><</replace>>
+	<<elseif $corpCash > $captureAssetPrice*500>>
+		<<replace "#captureAssetsPurchasing">> The corp can only buy <<print Math.floor($corpCash/($captureAssetPrice*500))>> more unit<<if Math.floor($corpCash/($captureAssetPrice*500)) > 1 >>s<</if>> of this asset. <</replace>>
 	<<else>>
-		<<replace "#purchasing">>
-			There are insufficient funds for additional purchases.
-		<</replace>>
+	<<replace "#captureAssetsPurchasing">>
+		There are insufficient funds for additional purchases.
+	<</replace>>
 	<</if>>
 <</link>>
 | <<link "Sell">>
-	<<if $captureAssets >= 1000>>
-		<<set $captureAssets -= 500>>
-		<<set $corpCash += 500*$captureAssetPrice>>
+	<<if Number.isInteger(Number.parseFloat(_NumCapture)) == false>>
+		<<replace "#captureAssetsPurchasing">>
+		Please input a round number.
+		<</replace>>
+	<<elseif $captureAssets > 500 && (_NumCapture*500) < $captureAssets>>
+		<<set $captureAssets -= _NumCapture*500>>
+		<<set $corpCash += _NumCapture*500*$captureAssetPrice>>
 		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
 		<<replace "#capAssets">>
-			¤<<print $captureAssetPrice*$captureAssets>>
+			¤<<print $captureAssetPrice*$captureAssets>> (<<print Math.floor($captureAssets/500)>> unit<<if Math.floor($captureAssets/500) > 1>>s<</if>>)
+		<</replace>>
+		<<replace "#captureAssetsPurchasing">>
 		<</replace>>
-		<<replace "#update">>
+	<<elseif $captureAssets > 500>>
+		<<replace "#captureAssetsPurchasing">>
+			The corp can only sell <<print Math.floor(($captureAssets-500)/500)>> more unit<<if Math.floor(($captureAssets-500)/500) > 1 >>s<</if>> of this asset.
 		<</replace>>
 	<<else>>
-		<<replace "#update">>
-			You cannot sell any more assets.
+		<<replace "#captureAssetsPurchasing">>
+			The corp cannot sell any more of this asset.
 		<</replace>>
 	<</if>>
 <</link>>
+<span id="captureAssetsPurchasing"></span>
 
 <br>
 <<if $trainingAssetPrice > 10>>
@@ -466,61 +493,66 @@ Extralegal enslavement asset prices are
 	<<set $trainingAssetPrice to 5>>
 <</if>>
 &nbsp;&nbsp;&nbsp;&nbsp;
-<span id="trainAssets">¤<<print $trainingAssetPrice*$trainingAssets>></span> in slave training assets.
-Slave training asset prices are
-<<if $trainingAssetPrice > 12>>@@color:yellowgreen;very high@@<<elseif $trainingAssetPrice > 10>>@@color:yellowgreen;high@@<<elseif $trainingAssetPrice == 10>>average<<elseif $trainingAssetPrice >= 8>>@@color:gold;low@@<<else>>@@color:gold;very low@@<</if>>.
-| <<link "Buy">>
-	<<if $trainingAssetPrice*500 < $corpCash>>
-		<<set $trainingAssets += 500>>
-		<<set $corpCash -= 500*$trainingAssetPrice>>
-		<<replace "#cashOnHand">>
-			¤<<print $corpCash>>
-		<</replace>>
-		<<replace "#trainAssets">>
-			¤<<print $trainingAssetPrice*$trainingAssets>>
-		<</replace>>
-		<<replace "#update">>
-		<</replace>>
-	<<else>>
-		<<replace "#purchasing">>
-			There are insufficient funds for additional purchases.
+<span id="trainAssets">¤<<print $trainingAssetPrice*$trainingAssets>> (<<print Math.floor($trainingAssets/500)>> unit<<if Math.floor($trainingAssets/500) > 1>>s<</if>>)</span> of slave training assets.
+Prices are 
+<<if $trainingAssetPrice > 10>>
+	@@color:yellowgreen;¤<<print $trainingAssetPrice*500>>ea@@
+<<elseif $trainingAssetPrice < 10>>
+	@@color:gold;¤<<print $trainingAssetPrice*500>>ea@@
+<<else>>
+	¤<<print $trainingAssetPrice*500>>ea
+<</if>>
+| Trade Qty <<textbox "_NumTraining" _NumTraining>><<script>>setTextboxMaxLength('_NumTraining', 5);<</script>>
+ : <<link "Buy">>
+	<<if Number.isInteger(Number.parseFloat(_NumTraining)) == false>>
+		<<replace "#trainingAssetsPurchasing">>
+		Please input a round number.
 		<</replace>>
-	<</if>>
-<</link>>
-| <<link "Massive investment">>
-	<<if $trainingAssetPrice*1000 < $corpCash>>
-		<<set $trainingAssets += (Math.trunc($corpCash/($trainingAssetPrice*500)))*500>>
-		<<set $corpCash -= (Math.trunc($corpCash/($trainingAssetPrice*500)))*($trainingAssetPrice*500)>>
-	 	<<replace "#cashOnHand">>
+	<<elseif _NumTraining*$trainingAssetPrice*500 < $corpCash>>
+		<<set $trainingAssets += _NumTraining*500>>
+		<<set $corpCash -= _NumTraining*500*$trainingAssetPrice>>
+		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
 		<<replace "#trainAssets">>
-			¤<<print $trainingAssetPrice*$trainingAssets>>
+			¤<<print $trainingAssetPrice*$trainingAssets>> (<<print Math.floor($trainingAssets/500)>> unit<<if $trainingAssets/500 > 1>>s<</if>>)
 		<</replace>>
+		<<replace "#trainingAssetsPurchasing">><</replace>>
+	<<elseif $corpCash > $trainingAssetPrice*500>>
+		<<replace "#trainingAssetsPurchasing">> The corp can only buy <<print Math.floor($corpCash/($trainingAssetPrice*500))>> more unit<<if Math.floor($corpCash/($trainingAssetPrice*500)) > 1 >>s<</if>> of this asset. <</replace>>
 	<<else>>
-		<<replace "#purchasing">>
-			There are insufficient funds for additional purchases.
-		<</replace>>
+	<<replace "#trainingAssetsPurchasing">>
+		There are insufficient funds for additional purchases.
+	<</replace>>
 	<</if>>
 <</link>>
 | <<link "Sell">>
-	<<if $trainingAssets >= 1000>>
-		<<set $trainingAssets -= 500>>
-		<<set $corpCash += 500*$trainingAssetPrice>>
+	<<if Number.isInteger(Number.parseFloat(_NumTraining)) == false>>
+		<<replace "#trainingAssetsPurchasing">>
+		Please input a round number.
+		<</replace>>
+	<<elseif $trainingAssets > 500 && (_NumTraining*500) < $trainingAssets>>
+		<<set $trainingAssets -= _NumTraining*500>>
+		<<set $corpCash += _NumTraining*500*$trainingAssetPrice>>
 		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
 		<<replace "#trainAssets">>
-			¤<<print $trainingAssetPrice*$trainingAssets>>
+			¤<<print $trainingAssetPrice*$trainingAssets>> (<<print Math.floor($trainingAssets/500)>> unit<<if Math.floor($trainingAssets/500) > 1>>s<</if>>)
+		<</replace>>
+		<<replace "#trainingAssetsPurchasing">>
 		<</replace>>
-		<<replace "#update">>
+	<<elseif $trainingAssets > 500>>
+		<<replace "#trainingAssetsPurchasing">>
+			The corp can only sell <<print Math.floor(($trainingAssets-500)/500)>> more unit<<if Math.floor(($trainingAssets-500)/500) > 1 >>s<</if>> of this asset.
 		<</replace>>
 	<<else>>
-		<<replace "#update">>
-			You cannot sell any more assets.
+		<<replace "#trainingAssetsPurchasing">>
+			The corp cannot sell any more of this asset.
 		<</replace>>
 	<</if>>
 <</link>>
+<span id="trainingAssetsPurchasing"></span>
 
 <br>
 <<if $surgicalAssetPrice > 10>>
@@ -547,61 +579,66 @@ Slave training asset prices are
 	<<set $surgicalAssetPrice to 5>>
 <</if>>
 &nbsp;&nbsp;&nbsp;&nbsp;
-<span id="surgAssets">¤<<print $surgicalAssetPrice*$surgicalAssets>></span> in surgical assets.
-Surgical asset prices are
-<<if $surgicalAssetPrice > 12>>@@color:yellowgreen;very high@@<<elseif $surgicalAssetPrice > 10>>@@color:yellowgreen;high@@<<elseif $surgicalAssetPrice == 10>>average<<elseif $surgicalAssetPrice >= 8>>@@color:gold;low@@<<else>>@@color:gold;very low@@<</if>>.
-| <<link "Buy">>
-	<<if $surgicalAssetPrice*500 < $corpCash>>
-		<<set $surgicalAssets += 500>>
-		<<set $corpCash -= 500*$surgicalAssetPrice>>
-		<<replace "#cashOnHand">>
-			¤<<print $corpCash>>
-		<</replace>>
-		<<replace "#surgAssets">>
-			¤<<print $surgicalAssetPrice*$surgicalAssets>>
-		<</replace>>
-		<<replace "#update">>
-		<</replace>>
-	<<else>>
-		<<replace "#purchasing">>
-			There are insufficient funds for additional purchases.
+<span id="surgAssets">¤<<print $surgicalAssetPrice*$surgicalAssets>> (<<print Math.floor($surgicalAssets/500)>> unit<<if Math.floor($surgicalAssets/500) > 1>>s<</if>>)</span> in surgical assets.
+Prices are 
+<<if $surgicalAssetPrice > 10>>
+	@@color:yellowgreen;¤<<print $surgicalAssetPrice*500>>ea@@
+<<elseif $surgicalAssetPrice < 10>>
+	@@color:gold;¤<<print $surgicalAssetPrice*500>>ea@@
+<<else>>
+	¤<<print $surgicalAssetPrice*500>>ea
+<</if>>
+| Trade Qty <<textbox "_NumSurgery" _NumSurgery>><<script>>setTextboxMaxLength('_NumSurgery', 5);<</script>>
+ : <<link "Buy">>
+	<<if Number.isInteger(Number.parseFloat(_NumSurgery)) == false>>
+		<<replace "#surgicalAssetsPurchasing">>
+		Please input a round number.
 		<</replace>>
-	<</if>>
-<</link>>
-| <<link "Massive investment">>
-	<<if $surgicalAssetPrice*1000 < $corpCash>>
-		<<set $surgicalAssets += (Math.trunc($corpCash/($surgicalAssetPrice*500)))*500>>
-		<<set $corpCash -= (Math.trunc($corpCash/($surgicalAssetPrice*500)))*($surgicalAssetPrice*500)>>
-	 	<<replace "#cashOnHand">>
+	<<elseif _NumSurgery*$surgicalAssetPrice*500 < $corpCash>>
+		<<set $surgicalAssets += _NumSurgery*500>>
+		<<set $corpCash -= _NumSurgery*500*$surgicalAssetPrice>>
+		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
 		<<replace "#surgAssets">>
-			¤<<print $surgicalAssetPrice*$surgicalAssets>>
+			¤<<print $surgicalAssetPrice*$surgicalAssets>> (<<print Math.floor($surgicalAssets/500)>> unit<<if $surgicalAssets/500 > 1>>s<</if>>)
 		<</replace>>
+		<<replace "#surgicalAssetsPurchasing">><</replace>>
+	<<elseif $corpCash > $surgicalAssetPrice*500>>
+		<<replace "#surgicalAssetsPurchasing">> The corp can only buy <<print Math.floor($corpCash/($surgicalAssetPrice*500))>> more unit<<if Math.floor($corpCash/($surgicalAssetPrice*500)) > 1 >>s<</if>> of this asset. <</replace>>
 	<<else>>
-		<<replace "#purchasing">>
-			There are insufficient funds for additional purchases.
-		<</replace>>
+	<<replace "#surgicalAssetsPurchasing">>
+		There are insufficient funds for additional purchases.
+	<</replace>>
 	<</if>>
 <</link>>
 | <<link "Sell">>
-	<<if $surgicalAssets >= 1000>>
-		<<set $surgicalAssets -= 500>>
-		<<set $corpCash += 500*$surgicalAssetPrice>>
+	<<if Number.isInteger(Number.parseFloat(_NumSurgery)) == false>>
+		<<replace "#surgicalAssetsPurchasing">>
+		Please input a round number.
+		<</replace>>
+	<<elseif $surgicalAssets >500 && (_NumSurgery*500) < $surgicalAssets>>
+		<<set $surgicalAssets -= _NumSurgery*500>>
+		<<set $corpCash += _NumSurgery*500*$surgicalAssetPrice>>
 		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
 		<<replace "#surgAssets">>
-			¤<<print $surgicalAssetPrice*$surgicalAssets>>
+			¤<<print $surgicalAssetPrice*$surgicalAssets>> (<<print Math.floor($surgicalAssets/500)>> unit<<if Math.floor($surgicalAssets/500) > 1>>s<</if>>)
+		<</replace>>
+		<<replace "#surgicalAssetsPurchasing">>
 		<</replace>>
-		<<replace "#update">>
+	<<elseif $surgicalAssets > 500>>
+		<<replace "#surgicalAssetsPurchasing">>
+			The corp can only sell <<print Math.floor(($surgicalAssets-500)/500)>> more unit<<if Math.floor(($surgicalAssets-500)/500) > 1 >>s<</if>> of this asset.
 		<</replace>>
 	<<else>>
-		<<replace "#update">>
-			You cannot sell any more assets.
+		<<replace "#surgicalAssetsPurchasing">>
+			The corp cannot sell any more of this asset.
 		<</replace>>
 	<</if>>
 <</link>>
+<span id="surgicalAssetsPurchasing"></span>
 
 <br>
 <<if $drugAssetPrice > 10>>
@@ -628,63 +665,67 @@ Surgical asset prices are
 	<<set $drugAssetPrice to 5>>
 <</if>>
 &nbsp;&nbsp;&nbsp;&nbsp;
-<span id="drAssets">¤<<print $drugAssetPrice*$drugAssets>></span> in pharmaceutical assets.
-Drug asset prices are
-<<if $drugAssetPrice > 12>>@@color:yellowgreen;very high@@<<elseif $drugAssetPrice > 10>>@@color:yellowgreen;high@@<<elseif $drugAssetPrice == 10>>average<<elseif $drugAssetPrice >= 8>>@@color:gold;low@@<<else>>@@color:gold;very low@@<</if>>.
-| <<link "Buy">>
-	<<if $drugAssetPrice*500 < $corpCash>>
-		<<set $drugAssets += 500>>
-		<<set $corpCash -= 500*$drugAssetPrice>>
+<span id="drugAssets">¤<<print $drugAssetPrice*$drugAssets>> (<<print Math.floor($drugAssets/500)>> unit<<if Math.floor($drugAssets/500) > 1>>s<</if>>)</span> in pharmaceutical assets.
+Prices are 
+<<if $drugAssetPrice > 10>>
+	@@color:yellowgreen;¤<<print $drugAssetPrice*500>>ea@@
+<<elseif $drugAssetPrice < 10>>
+	@@color:gold;¤<<print $drugAssetPrice*500>>ea@@
+<<else>>
+	¤<<print $drugAssetPrice*500>>ea
+<</if>>
+| Trade Qty <<textbox "_NumDrug" _NumDrug>><<script>>setTextboxMaxLength('_NumDrug', 5);<</script>>
+ : <<link "Buy">>
+	<<if Number.isInteger(Number.parseFloat(_NumDrug)) == false>>
+		<<replace "#drugAssetsPurchasing">>
+		Please input a round number.
+		<</replace>>
+	<<elseif _NumDrug*$drugAssetPrice*500 < $corpCash>>
+		<<set $drugAssets += _NumDrug*500>>
+		<<set $corpCash -= _NumDrug*500*$drugAssetPrice>>
 		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
-		<<replace "#drAssets">>
-			¤<<print $drugAssetPrice*$drugAssets>>
+		<<replace "#drugAssets">>
+			¤<<print $drugAssetPrice*$drugAssets>> (<<print Math.floor($drugAssets/500)>> unit<<if $drugAssets/500 > 1>>s<</if>>)
 		<</replace>>
-		<<replace "#update">>
+		<<replace "#drugAssetsPurchasing">><</replace>>
+	<<elseif $corpCash > $drugAssetPrice*500>>
+		<<replace "#drugAssetsPurchasing">> The corp can only buy <<print Math.floor($corpCash/($drugAssetPrice*500))>> more unit<<if Math.floor($corpCash/($drugAssetPrice*500)) > 1 >>s<</if>> of this asset. 
 		<</replace>>
 	<<else>>
-		<<replace "#purchasing">>
-			There are insufficient funds for additional purchases.
-		<</replace>>
+	<<replace "#drugAssetsPurchasing">>
+		There are insufficient funds for additional purchases.
+	<</replace>>
 	<</if>>
 <</link>>
-| <<link "Massive investment">>
-	<<if $drugAssetPrice*1000 < $corpCash>>
-		<<set $drugAssets += (Math.trunc($corpCash/($drugAssetPrice*500)))*500>>
-		<<set $corpCash -= (Math.trunc($corpCash/($drugAssetPrice*500)))*($drugAssetPrice*500)>>
-	 	<<replace "#cashOnHand">>
-			¤<<print $corpCash>>
-		<</replace>>
-		<<replace "#drAssets">>
-			¤<<print $drugAssetPrice*$drugAssets>>
-		<</replace>>
-	<<else>>
-		<<replace "#purchasing">>
-			There are insufficient funds for additional purchases.
+| <<link "Sell">>
+	<<if Number.isInteger(Number.parseFloat(_NumDrug)) == false>>
+		<<replace "#drugAssetsPurchasing">>
+		Please input a round number.
 		<</replace>>
-	<</if>>
-<</link>>
-| <<link "Sell">><<set $drugAssets -= 500>>
-	<<if $drugAssets >= 1000>>
-		<<set $drugAssets -= 500>>
-		<<set $corpCash += 500*$drugAssetPrice>>
+	<<elseif $drugAssets >500 && (_NumDrug*500) < $drugAssets>>
+		<<set $drugAssets -= _NumDrug*500>>
+		<<set $corpCash += _NumDrug*500*$drugAssetPrice>>
 		<<replace "#cashOnHand">>
 			¤<<print $corpCash>>
 		<</replace>>
-		<<replace "#drAssets">>
-			¤<<print $drugAssetPrice*$drugAssets>>
+		<<replace "#drugAssets">>
+			¤<<print $drugAssetPrice*$drugAssets>> (<<print Math.floor($drugAssets/500)>> unit<<if Math.floor($drugAssets/500) > 1>>s<</if>>)
 		<</replace>>
-		<<replace "#update">>
+		<<replace "#drugAssetsPurchasing">>
+		<</replace>>
+	<<elseif $drugAssets > 500>>
+		<<replace "#drugAssetsPurchasing">>
+			The corp can only sell <<print Math.floor(($drugAssets-500)/500)>> more unit<<if Math.floor(($drugAssets-500)/500) > 1 >>s<</if>> of this asset.
 		<</replace>>
 	<<else>>
-		<<replace "#update">>
-			You cannot sell any more assets.
+		<<replace "#drugAssetsPurchasing">>
+			The corp cannot sell any more of this asset.
 		<</replace>>
 	<</if>>
 <</link>>
-
-</span>
+<span id="drugAssetsPurchasing"></span>
 
 <span id="direction">
 
@@ -845,4 +886,4 @@ Drug asset prices are
 	<</if>>
 <</if>>
 
-</span>
+</span>
\ No newline at end of file
diff --git a/src/uncategorized/slaveAssignmentsReport.tw b/src/uncategorized/slaveAssignmentsReport.tw
index d409338f548..51b3e81e281 100644
--- a/src/uncategorized/slaveAssignmentsReport.tw
+++ b/src/uncategorized/slaveAssignmentsReport.tw
@@ -335,113 +335,242 @@
 
 
 /* Accordion 000-250-006 */
- <<if ($brothel > 0)>>
-    <<if $useAccordion eq 1>>
-        <button class="passage-brothel-report accordion">''$brothelNameCaps Report''</button>
+<<if ($brothel > 0)>>
+    <<if ($brothelSlaves eq 0) and ($Madam eq 0)>> /* Is there even anyone home? */
+        <div class="unStaffed" data-after="Mandatory sensitivity classes">''$brothelNameCaps'' is currently unstaffed</div>
     <<else>>
-        ''$brothelNameCaps Report''
-        <hr style="margin:0">
+        <div class="staffed">
+            <<if $useAccordion eq 1>>
+                <<if $brothelSlaves eq 1>>
+                    <<set _str1 to "There is one slave serving">>
+                <<else>>
+                    <<set _str1 to "There are " + $brothelSlaves + " serving">>
+                <</if>>
+                <<= '<button id="passage-brothel-report" class="accordion" data-after="' + _str1 + ' in ' + $brothelNameCaps + '">$brothelNameCaps Report</button>'>>
+            <<else>>
+                ''$brothelNameCaps Report''
+                <hr style="margin:0">
+            <</if>>
+            <<include "Brothel Report" "div">>
+        </div>
     <</if>>
-    <<include "Brothel Report" "div">>
 <</if>>
 
 <<if ($club > 0)>>
-    <<if $useAccordion eq 1>>
-        <button class="passage-club-report accordion">''$clubNameCaps Report''</button>
+    <<if ($clubSlaves eq 0) and ($DJ eq 0)>> /* Is there even anyone home? */
+        <div class="unStaffed" data-after="Who said disco is dead?">''$clubNameCaps'' is currently dark and silent</div>
     <<else>>
-        ''$clubNameCaps Report''
-        <hr style="margin:0">
+        <div class="staffed">
+            <<if $useAccordion eq 1>>
+                <<if $clubSlaves eq 1>>
+                    <<set _str1 to "There is one slave serving">>
+                <<else>>
+                    <<set _str1 to "There are " + $clubSlaves + " serving">>
+                <</if>>
+                <<= '<button id="passage-club-report" class="accordion" data-after="' + _str1 + ' in ' + $clubNameCaps + '">$clubNameCaps Report</button>'>>
+            <<else>>
+                ''$brothelNameCaps Report''
+                <hr style="margin:0">
+            <</if>>
+            <<include "Club Report" "div">>
+        </div>
     <</if>>
-    <<include "Club Report" "div">>
 <</if>>
 
 <<if ($arcade > 0)>>
-    <<if $useAccordion eq 1>>
-        <button class="passage-arcade-report accordion">''$arcadeNameCaps Report''</button>
+    <<if $arcadeSlaves eq 0>> /* Is there even anyone home? */
+        <div class="unStaffed" data-after="No glory (hole), no guts ...">''$arcadeNameCaps'' is currently empty</div>
     <<else>>
-        ''$arcadeNameCaps Report''
-        <hr style="margin:0">
+        <div class="staffed">
+            <<if $useAccordion eq 1>>
+                <<if $arcadeSlaves eq 1>>
+                    <<set _str1 to "There is one slave serving">>
+                <<else>>
+                    <<set _str1 to "There are " + $arcadeSlaves + " slaves serving">>
+                <</if>>
+                <<= '<button id="passage-arcade-report" class="accordion" data-after="' + _str1 + ' in ' + $arcadeNameCaps + '">$arcadeNameCaps Report</button>'>>
+            <<else>>
+                ''$arcadeNameCaps Report''
+                <hr style="margin:0">
+            <</if>>
+            <<include "Arcade Report" "div">>
+        </div>
     <</if>>
-	<<include "Arcade Report" "div">>
 <</if>>
 
 <<if ($dairy > 0)>>
-    <<if $useAccordion eq 1>>
-        <button class="passage-dairy-report accordion">''$dairyNameCaps Report''</button>
+    <<if ($dairySlaves eq 0) and ($Milkmaid eq 0)>> /* Is there even anyone home? */
+        <div class="unStaffed" data-after="Cows gone to pasture?">''$dairyNameCaps'' is empty</div>
     <<else>>
-        ''$dairyNameCaps Report''
-        <hr style="margin:0">
+        <div class="staffed">
+            <<if $useAccordion eq 1>>
+                <<if $dairySlaves eq 1>>
+                    <<set _str1 to "There is one">>
+                    <<set _plurals to "">>
+                <<else>>
+                    <<set _str1 to "There are " + $dairySlaves>>
+                    <<set _plurals to "s">>
+                <</if>>
+                <<if ($dairyRestraintsSetting > 1)>> 
+                    <<set _str2 to " bioreactor" + _plurals>> 
+                <<else>>
+                    <<set _str2 to " cow" + _plurals>> 
+                <</if>>
+                <<= '<button id="passage-dairy-report" class="accordion" data-after="' + _str1 + _str2 + ' in ' + $dairyNameCaps + '">$dairyNameCaps Report</button>'>>
+            <<else>>
+                ''$dairyNameCaps Report''
+                <hr style="margin:0">
+            <</if>>
+            <<include "Dairy Report" "div">>
+        </div>
     <</if>>
-    <<include "Dairy Report" "div">>
 <</if>>
 
 <<if ($servantsQuarters > 0)>>
-    <<if $useAccordion eq 1>>
-        <button class="passage-servants-quarters-report accordion">''$servantsQuartersNameCaps Quarters Report''</button>
+    <<if ($servantsQuartersSlaves eq 0) and ($Stewardess eq 0)>> /* Is there even anyone home? */
+        <div class="unStaffed" data-after="Those sheets aren't gonna fold themselves">''$servantsQuartersNameCaps'' is currently unstaffed</div>
     <<else>>
-        ''$servantsQuartersNameCaps Report''
-        <hr style="margin:0">
+        <div class="staffed">
+            <<if $useAccordion eq 1>>
+                <<if $servantsQuartersSlaves eq 1>>
+                    <<set _str1 to "There is slave serving">>
+                <<else>>
+                    <<set _str1 to "There are " + $servantsQuartersSlaves + " serving">>
+                <</if>>
+                <<= '<button id="passage-servants-quarters-report" class="accordion" data-after="' + _str1 + ' in ' + $servantsQuartersNameCaps + '">$servantsQuartersNameCaps Report</button>'>>
+            <<else>>
+                ''$servantsQuartersNameCaps Report''
+                <hr style="margin:0">
+            <</if>>
+            <<include "Servants' Quarters Report" "div">>
+        </div>
     <</if>>
-    <<include "Servants' Quarters Report" "div">>
 <</if>>
 
 <<if ($schoolroom > 0)>>
-    <<if $useAccordion eq 1>>
-        <button class="passage-schoolroom-report accordion">''$schoolroomNameCaps Report''</button>
+    <<if ($schoolroomSlaves eq 0) and ($Schoolteacher eq 0)>> /* Is there even anyone home? */ /* DEV: Is this the right camelcase for schooteacher? */
+        <div class="unStaffed" data-after="School's out for summer!">''$schoolroomNameCaps'' is empty</div>
     <<else>>
-        ''$schoolroomNameCaps Report''
-        <hr style="margin:0">
+        <div class="staffed">
+            <<if $useAccordion eq 1>>
+                <<if $schoolroomSlaves eq 1>>
+                    <<set _str1 to "There is one slave">>
+                <<else>>
+                    <<set _str1 to "There are " + $schoolroomSlaves + " slaves serving">>
+                <</if>>
+                <<= '<button id="passage-schoolroom-report" class="accordion" data-after="' + _str1 + ' in ' + $schoolroomNameCaps + '">$schoolroomNameCaps Report</button>'>>
+            <<else>>
+                ''$schoolroomNameCaps Report''
+                <hr style="margin:0">
+            <</if>>
+            <<include "Schoolroom Report" "div">>
+        </div>
     <</if>>
-	<<include "Schoolroom Report" "div">>
 <</if>>
 
 <<if ($spa > 0)>>
-    <<if $useAccordion eq 1>>
-        <button class="passage-spa-report accordion">''$spaNameCaps Report''</button>
+    <<if ($spaSlaves eq 0) and ($Attendant eq 0)>> /* Is there even anyone home? */
+        <div class="unStaffed" data-after="All work and no play ...">''$spaNameCaps'' is currently unstaffed</div>
     <<else>>
-        ''$spaNameCaps Report''
-        <hr style="margin:0">
+        <div class="staffed">
+            <<if $useAccordion eq 1>>
+                <<if $spaSlaves eq 1>>
+                    <<set _str1 to "There is one slave relaxing">>
+                <<else>>
+                    <<set _str1 to "There are " + $spaSlaves + " slaves relaxing">>
+                <</if>>
+                <<= '<button id="passage-spa-report" class="accordion" data-after="' + _str1 + ' in ' + $spaNameCaps + '">$spaNameCaps Report</button>'>>
+            <<else>>
+                ''$spaNameCaps Report''
+                <hr style="margin:0">
+            <</if>>
+            <<include "Spa Report" "div">>
+        </div>
     <</if>>
-	<<include "Spa Report" "div">>
 <</if>>
 
 <<if ($clinic > 0)>>
-    <<if $useAccordion eq 1>>
-        <button class="passage-clinic-report accordion">''$clinicNameCaps Report''</button>
+  <<if ($clinicSlaves eq 0) and ($Nurse eq 0)>> /* Is there even anyone home? */
+        <div class="unStaffed" data-after="What is the nature of the medical emergency?">''$clinicNameCaps'' is currently unstaffed</div>
     <<else>>
-        ''$clinicNameCaps Report''
-        <hr style="margin:0">
+        <div class="staffed">
+            <<if $useAccordion eq 1>>
+                <<if $clinicSlaves eq 1>>
+                    <<set _str1 to "There is one slave recovering">>
+                <<else>>
+                    <<set _str1 to "There are " + $brothelSlaves + " recovering">>
+                <</if>>
+                <<= '<button id="passage-clinic-report" class="accordion" data-after="' + _str1 + ' in ' + $clinicNameCaps + '">$clinicNameCaps Report</button>'>>
+            <<else>>
+                ''$clinicNameCaps Report''
+                <hr style="margin:0">
+            <</if>>
+            <<include "Clinic Report" "div">>
+        </div>
     <</if>>
-    <<include "Clinic Report" "div">>
 <</if>>
 
 <<if ($cellblock > 0)>>
-    <<if $useAccordion eq 1>>
-        <button class="passage-cellblock-report accordion">''$cellblockNameCaps Report''</button>
+    <<if ($cellblockSlaves eq 0) and ($Wardeness eq 0)>> /* Is there even anyone home? */ 
+        <div class="unStaffed" data-after="Just means you haven't caught them yet">''$cellblockNameCaps'' is empty</div>
     <<else>>
-        ''$cellblockNameCaps Report''
-        <hr style="margin:0">
+        <div class="staffed">
+            <<if $useAccordion eq 1>>
+                <<if $cellblockSlaves eq 1>>
+                    <<set _str1 to "There is one slave confined">>
+                <<else>>
+                    <<set _str1 to "There are " + $cellblockSlaves + " slaves confined">>
+                <</if>>
+                <<= '<button id="passage-cellblock-report" class="accordion" data-after="' + _str1 + ' in ' + $cellblockNameCaps + '">$cellblockNameCaps Report</button>'>>
+            <<else>>
+                ''$cellblockNameCaps Report''
+                <hr style="margin:0">
+            <</if>>
+            <<include "Cellblock Report" "div">>
+        </div>
     <</if>>
-    <<include "Cellblock Report" "div">>
 <</if>>
 <<if ($incubator > 0)>>
-	<<if $useAccordion == 1>>
-		<button class="passage-incubator-report accordion">''$incubatorNameCaps Report''</button>
-	<<else>>
-		''$incubatorNameCaps Report''
-		<hr style="margin:0">
-	<</if>>
-	<<include "Incubator Report" "div">>
+    <<if ($incubatorSlaves == 0)>>
+        <div class="unStaffed" data-after="The tanks stand dormant">''$incubatorNameCaps'' is empty</div>
+    <<else>>
+        <div class="staffed">
+            <<if $useAccordion == 1>>
+                <<if $incubatorSlaves == 1>>
+                    <<set _str1 to "There is one child aging">>
+                <<else>>
+                    <<set _str1 to "There are " + $incubatorSlaves + " children aging">>
+                <</if>>
+                <<= '<button id="passage-incubator-report" class="accordion" data-after="' + _str1 + ' in ' + $incubatorNameCaps + '">$incubatorNameCaps Report</button>'>>
+            <<else>>
+                ''$incubatorNameCaps Report''
+                <hr style="margin:0">
+            <</if>>
+            <<include "Incubator Report" "div">>
+        </div>
+    <</if>>
 <</if>>
 <<if ($masterSuite > 0)>>
-    <<if $useAccordion eq 1>>
-        <button class="passage-master-suite-report accordion">''$masterSuiteNameCaps Report''</button>
+    <<if ($masterSuiteSlaves eq 0) and ($Concubine eq 0)>> /* Is there even anyone home? */
+        <div class="unStaffed" data-after="You have the TV remote control to yourself for once!">''$masterSuiteNameCaps'' is empty</div>
     <<else>>
-        ''$masterSuiteNameCaps Report''
-        <hr style="margin:0">
+        <div class="staffed">
+            <<if $useAccordion eq 1>>
+                <<if $masterSuiteSlaves eq 1>>
+                    <<set _str1 to "There is one slave awaiting you">>
+                <<else>>
+                    <<set _str1 to "There are " + $masterSuiteSlaves + " slaves awaiting you">>
+                <</if>>
+                <<= '<button id="passage-mastersuite-report" class="accordion" data-after="' + _str1 + ' in ' + $masterSuiteNameCaps + '">$masterSuiteNameCaps Report</button>'>>
+            <<else>>
+                ''$masterSuiteNameCaps Report''
+                <hr style="margin:0">
+            <</if>>
+            <<include "Master Suite Report" "div">>
+        </div>
     <</if>>
-	<<include "Master Suite Report" "div">>
 <</if>>
+
 <br />
 <br />
 /* Accordion 000-250-006 */
-- 
GitLab