From 95da61d746a2ee7e16ce3c8b1b025a2d0f767b07 Mon Sep 17 00:00:00 2001
From: ezsh <ezsh.junk@gmail.com>
Date: Sat, 19 Jan 2019 01:52:37 +0100
Subject: [PATCH] Refactor slave buying links into a widget and change their
 layout

Refactor identical link stuctures from markets and schools into a couple
of widgets and move the decline link to the top as that prevents
accidental clicking the buy link when browsing a market and the decline
links is the only one among them that is always available, so the new
layout creates less text jumping.
---
 src/pregmod/theCattleRanch.tw                | 18 +------
 src/pregmod/theHippolytaAcademy.tw           | 18 +------
 src/pregmod/wetwareCPUs.tw                   | 18 +------
 src/uncategorized/corporateMarket.tw         | 15 +-----
 src/uncategorized/growthResearchInstitute.tw | 19 +------
 src/uncategorized/lecoleDesEnculees.tw       | 18 +------
 src/uncategorized/slaveMarkets.tw            | 21 +-------
 src/uncategorized/stClaverPreparatory.tw     | 18 +------
 src/uncategorized/theFutanariSisters.tw      | 18 +------
 src/uncategorized/theGymnasiumAcademy.tw     | 18 +------
 src/uncategorized/theSlavegirlSchool.tw      | 18 +------
 src/utility/slaveCreationWidgets.tw          | 56 ++++++++++++++++++++
 12 files changed, 68 insertions(+), 187 deletions(-)

diff --git a/src/pregmod/theCattleRanch.tw b/src/pregmod/theCattleRanch.tw
index df5d538c5b4..c3a781b99f2 100644
--- a/src/pregmod/theCattleRanch.tw
+++ b/src/pregmod/theCattleRanch.tw
@@ -23,20 +23,4 @@
 <br><br>The price is <<print cashFormat($slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>>
 
 <<setLocalPronouns $activeSlave>>
-<<if $cash >= $slaveCost>>
-	<br>[["Buy " + $him + " and check out other cows to order"|The Cattle Ranch][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $TCR.schoolSale = 0, $TCR.studentsBought += 1, $newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]]
-	<<if $newSlaves.length == 0>>
-		<br>[["Buy " + $his + " slave contract"|New Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $TCR.schoolSale = 0, $TCR.studentsBought += 1, $nextButton = "Continue", $nextLink = "AS Dump", $returnTo = "Main"]]
-	<<else>>
-		<br>[["Buy " + $his + " and finish your order of cattle"|Bulk Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $TCR.schoolSale = 0, $TCR.studentsBought += 1, $newSlaves.push($activeSlave)]]
-	<</if>>
-<<else>>
-	//You lack the necessary funds to buy this slave.//
-<</if>>
-<br>[["Decline to purchase " + $him + " and check out another cow"|The Cattle Ranch][$slavesSeen += 1]]
-<<if $newSlaves.length > 0>>
-	<br>[[Finish your order of cattle|Bulk Slave Intro]]
-<</if>>
-
-<br><br>
-<<set $saleDescription = 1>><<include "Long Slave Description">>
\ No newline at end of file
+<<buyingFromSchoolControls $TCR "cow" "cattle">>
diff --git a/src/pregmod/theHippolytaAcademy.tw b/src/pregmod/theHippolytaAcademy.tw
index 64e6a41fbdb..e98bbd741df 100644
--- a/src/pregmod/theHippolytaAcademy.tw
+++ b/src/pregmod/theHippolytaAcademy.tw
@@ -32,20 +32,4 @@ The Hippolyta Academy is one of the most famous slave bodyguarding schools in al
 <br><br>The price is <<print cashFormat($slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>>
 
 <<setLocalPronouns $activeSlave>>
-<<if $cash >= $slaveCost>>
-	<br>[["Buy " + $him + " and check out other slaves to order"|The Hippolyta Academy][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $HA.schoolSale = 0, $HA.studentsBought += 1, $newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]]
-	<<if $newSlaves.length == 0>>
-		<br>[["Buy " + $his + " slave contract"|New Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $HA.schoolSale = 0, $HA.studentsBought += 1, $nextButton = "Continue", $nextLink = "AS Dump", $returnTo = "Main"]]
-	<<else>>
-		<br>[["Buy " + $him + " and finish your order of slaves"|Bulk Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $HA.schoolSale = 0, $HA.studentsBought += 1, $newSlaves.push($activeSlave)]]
-	<</if>>
-<<else>>
-	//You lack the necessary funds to buy this slave.//
-<</if>>
-<br>[["Decline to purchase " + $him + " and check out another slave"|The Hippolyta Academy][$slavesSeen += 1]]
-<<if $newSlaves.length > 0>>
-	<br>[[Finish your order of slaves|Bulk Slave Intro]]
-<</if>>
-
-<br><br>
-<<set $saleDescription = 1>><<include "Long Slave Description">>
+<<buyingFromSchoolControls $HA "slave" "slaves">>
diff --git a/src/pregmod/wetwareCPUs.tw b/src/pregmod/wetwareCPUs.tw
index 2ca8c4f05ed..897709070d0 100644
--- a/src/pregmod/wetwareCPUs.tw
+++ b/src/pregmod/wetwareCPUs.tw
@@ -18,20 +18,4 @@
 <br><br>The price is <<print cashFormat($slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>>
 
 <<setLocalPronouns $activeSlave>>
-<<if $cash >= $slaveCost>>
-	<br>[["Buy " + $him + " and check out other slaves to order"|Wetware CPUs][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]]
-	<<if $newSlaves.length == 0>>
-		<br>[["Buy " + $his + " slave contract"|New Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $nextButton = "Continue", $nextLink = "AS Dump", $returnTo = "Main"]]
-	<<else>>
-		<br>[["Buy " + $him + " and finish your order of slaves"|Bulk Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $newSlaves.push($activeSlave)]]
-	<</if>>
-<<else>>
-	//You lack the necessary funds to buy this slave.//
-<</if>>
-<br>[["Decline to purchase " + $him + " and check out another slave"|Wetware CPUs][$slavesSeen += 1]]
-<<if $newSlaves.length > 0>>
-	<br>[[Finish your order of slaves|Bulk Slave Intro]]
-<</if>>
-
-<br><br>
-<<set $saleDescription = 1>><<include "Long Slave Description">>
+<<buyingFromMarketControls>>
diff --git a/src/uncategorized/corporateMarket.tw b/src/uncategorized/corporateMarket.tw
index 019fcb19cdb..45018c9a56e 100644
--- a/src/uncategorized/corporateMarket.tw
+++ b/src/uncategorized/corporateMarket.tw
@@ -82,22 +82,11 @@ while you browse.
 	<<set $slaveCost *= 0.9>>
 <</if>>
 
-<<setLocalPronouns $activeSlave>>
 <<set $slaveCost = 500*Math.trunc($slaveCost/500)>>
 The offered price is <<print cashFormat($slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>>
 <br>
-<<if $cash >= $slaveCost>>
-	[["Buy " + $his + " slave contract"|New Slave Intro][cashX(forceNeg($slaveCost), "slaveTransfer", $activeSlave),$nextButton = "Continue",$nextLink = "AS Dump",$returnTo = "Main"]]
-<<else>>
-	//You lack the necessary funds to buy this slave.//
-<</if>>
-<br>
-[["Decline to purchase " + $him + " and check out another slave"|Corporate Market][$slavesSeen += 1]]
-
-<br><br>
-<<set $saleDescription = 1, $applyLaw = 1>><<include "Long Slave Description">>
-
-<br><br>
+<<setLocalPronouns $activeSlave>>
+<<buyingFromMarketControls>>
 
 <<link "End corporate slave sales here and return this sector to standard markets">>
 	<<set $corpMarket = 0>>
diff --git a/src/uncategorized/growthResearchInstitute.tw b/src/uncategorized/growthResearchInstitute.tw
index 7d07b9231ad..98dda618e00 100644
--- a/src/uncategorized/growthResearchInstitute.tw
+++ b/src/uncategorized/growthResearchInstitute.tw
@@ -24,21 +24,4 @@
 <br><br>The price is <<print cashFormat($slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>>
 
 <<setLocalPronouns $activeSlave>>
-<<if $cash >= $slaveCost>>
-	<br>[["Buy " + $him + " and check out other slaves to order"|Growth Research Institute][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $GRI.schoolSale = 0, $GRI.studentsBought += 1, $newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]]
-	<<if $newSlaves.length == 0>>
-		<br>[["Buy " + $his + " slave contract"|New Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $GRI.schoolSale = 0, $GRI.studentsBought += 1, $nextButton = "Continue", $nextLink = "AS Dump", $returnTo = "Main"]]
-	<<else>>
-		<br>[[["Buy " + $him + " and finish your order of slaves"|Bulk Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $GRI.schoolSale = 0, $GRI.studentsBought += 1, $newSlaves.push($activeSlave)]]
-	<</if>>
-<<else>>
-	//You lack the necessary funds to buy this slave.//
-<</if>>
-<br>[["Decline to purchase " + $him + " and check out another slave"|Growth Research Institute][$slavesSeen += 1]]
-
-<<if $newSlaves.length > 0>>
-	<br>[[Finish your order of slaves|Bulk Slave Intro]]
-<</if>>
-
-<br><br>
-<<set $saleDescription = 1>><<include "Long Slave Description">>
+<<buyingFromSchoolControls $GRI "slave" "slaves">>
diff --git a/src/uncategorized/lecoleDesEnculees.tw b/src/uncategorized/lecoleDesEnculees.tw
index c455ccaadab..9ae5f97efae 100644
--- a/src/uncategorized/lecoleDesEnculees.tw
+++ b/src/uncategorized/lecoleDesEnculees.tw
@@ -23,20 +23,4 @@
 <br><br>The price is <<print cashFormat($slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>>
 
 <<setLocalPronouns $activeSlave>>
-<<if $cash >= $slaveCost>>
-	<br>[["Buy " + $him + " and check out other slaves to order"|L'École des Enculées][cashX(forceNeg($slaveCost), "slaveTransaction"), $LDE.schoolSale = 0, $LDE.studentsBought += 1, $newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]]
-	<<if $newSlaves.length == 0>>
-		<br>[["Buy " + $his + " slave contract"|New Slave Intro][cashX(forceNeg($slaveCost), "slaveTransaction"), $LDE.schoolSale = 0, $LDE.studentsBought += 1, $nextButton = "Continue", $nextLink = "AS Dump", $returnTo = "Main"]]
-	<<else>>
-		<br>[["Buy " + $him + " and finish your order of slaves"|Bulk Slave Intro][cashX(forceNeg($slaveCost), "slaveTransaction"), $LDE.schoolSale = 0, $LDE.studentsBought += 1, $newSlaves.push($activeSlave)]]
-	<</if>>
-<<else>>
-	//You lack the necessary funds to buy this slave.//
-<</if>>
-<br>[["Decline to purchase " + $him + " and check out another slave"|L'École des Enculées][$slavesSeen += 1]]
-<<if $newSlaves.length > 0>>
-	<br>[[Finish your order of slaves|Bulk Slave Intro]]
-<</if>>
-
-<br><br>
-<<set $saleDescription = 1>><<include "Long Slave Description">>
+<<buyingFromSchoolControls $LDE "slave" "slaves">>
diff --git a/src/uncategorized/slaveMarkets.tw b/src/uncategorized/slaveMarkets.tw
index c1ccf6a13e8..27f194b12bd 100644
--- a/src/uncategorized/slaveMarkets.tw
+++ b/src/uncategorized/slaveMarkets.tw
@@ -195,23 +195,4 @@ You visit the slave markets off the arcology plaza. It's always preferable to ex
 The offered price is <<print cashFormat($slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>>
 
 <<setLocalPronouns $activeSlave>>
-<<if $cash >= $slaveCost>>
-	<br>[["Buy " + $him + " and check out other slaves to order"|Slave Markets][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]]
-	<<if $newSlaves.length == 0>>
-		<br>[["Buy " + $his + " slave contract"|New Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave),$nextButton = "Continue",$nextLink = "AS Dump",$returnTo = "Main"]]
-	<<else>>
-		<br>[["Buy " + $him + " and finish your order of slaves"|Bulk Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $newSlaves.push($activeSlave)]]
-	<</if>>
-<<else>>
-	//You lack the necessary funds to buy this slave.//
-<</if>>
-<br>[["Decline to purchase " + $him + " and check out another slave"|Slave Markets][$slavesSeen += 1]]
-<<if $newSlaves.length > 0>>
-	<br>[[Finish your order of slaves|Bulk Slave Intro]]
-<</if>>
-
-<br><br>
-<<if $slaveMarket != "indentures" && $slaveMarket != "neighbor" && $slaveMarket != "heap" && $slaveMarket != "wetware">>
-	<<set $applyLaw = 1>>
-<</if>>
-<<set $saleDescription = 1>><<include "Long Slave Description">>
+<<buyingFromMarketControls>>
diff --git a/src/uncategorized/stClaverPreparatory.tw b/src/uncategorized/stClaverPreparatory.tw
index 140fd159c10..60af457651a 100644
--- a/src/uncategorized/stClaverPreparatory.tw
+++ b/src/uncategorized/stClaverPreparatory.tw
@@ -23,20 +23,4 @@
 <br><br>The price is <<print cashFormat($slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>>
 
 <<setLocalPronouns $activeSlave>>
-<<if $cash >= $slaveCost>>
-	<br>[["Buy " + $him + " and check out other slaves to order"|St. Claver Preparatory][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $SCP.schoolSale = 0, $SCP.studentsBought += 1, $newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]]
-	<<if $newSlaves.length == 0>>
-		<br>[["Buy " + $his + " slave contract"|New Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $SCP.schoolSale = 0, $SCP.studentsBought += 1, $nextButton = "Continue", $nextLink = "AS Dump", $returnTo = "Main"]]
-	<<else>>
-		<br>[["Buy " + $him + " and finish your order of slaves"|Bulk Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $SCP.schoolSale = 0, $SCP.studentsBought += 1, $newSlaves.push($activeSlave)]]
-	<</if>>
-<<else>>
-	//You lack the necessary funds to buy this slave.//
-<</if>>
-<br>[["Decline to purchase " + $him + " and check out another slave"|St. Claver Preparatory][$slavesSeen += 1]]
-<<if $newSlaves.length > 0>>
-	<br>[[Finish your order of slaves|Bulk Slave Intro]]
-<</if>>
-
-<br><br>
-<<set $saleDescription = 1>><<include "Long Slave Description">>
+<<buyingFromSchoolControls $SCP "slave" "slaves">>
diff --git a/src/uncategorized/theFutanariSisters.tw b/src/uncategorized/theFutanariSisters.tw
index 07b8e4679e6..b2780126275 100644
--- a/src/uncategorized/theFutanariSisters.tw
+++ b/src/uncategorized/theFutanariSisters.tw
@@ -118,20 +118,4 @@ The Sisters offer a member selected for sale into slavery for inspection via vid
 The price is <<print cashFormat($slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>>
 
 <<setLocalPronouns $activeSlave>>
-<<if $cash >= $slaveCost>>
-	<br>[["Buy " + $him + " and check out other slaves to order"|The Futanari Sisters][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $TFS.schoolSale = 0, $TFS.studentsBought += 1, $newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]]
-	<<if $newSlaves.length == 0>>
-		<br>[["Buy " + $his + " slave contract"|New Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $TFS.schoolSale = 0, $TFS.studentsBought += 1, $nextButton = "Continue", $nextLink = "AS Dump", $returnTo = "Main"]]
-	<<else>>
-		<br>[["Buy " + $him + " and finish your order of slaves"|Bulk Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $TFS.schoolSale = 0, $TFS.studentsBought += 1, $newSlaves.push($activeSlave)]]
-	<</if>>
-<<else>>
-	//You lack the necessary funds to buy this slave.//
-<</if>>
-<br>[["Decline to purchase " + $him + " and check out another slave"|The Futanari Sisters][$slavesSeen += 1]]
-<<if $newSlaves.length > 0>>
-	<br>[[Finish your order of slaves|Bulk Slave Intro]]
-<</if>>
-
-<br><br>
-<<set $saleDescription = 1>><<include "Long Slave Description">>
+<<buyingFromSchoolControls $TFS "slave" "slaves">>
diff --git a/src/uncategorized/theGymnasiumAcademy.tw b/src/uncategorized/theGymnasiumAcademy.tw
index 6af965cc830..7485964441d 100644
--- a/src/uncategorized/theGymnasiumAcademy.tw
+++ b/src/uncategorized/theGymnasiumAcademy.tw
@@ -23,20 +23,4 @@
 <br><br>The price is <<print cashFormat($slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>>
 
 <<setLocalPronouns $activeSlave>>
-<<if $cash >= $slaveCost>>
-	<br>[["Buy " + $him + " and check out other slaves to order"|The Gymnasium-Academy][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $TGA.schoolSale = 0, $TGA.studentsBought += 1, $newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]]
-	<<if $newSlaves.length == 0>>
-		<br>[["Buy " + $his + " slave contract"|New Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $TGA.schoolSale = 0, $TGA.studentsBought += 1, $nextButton = "Continue", $nextLink = "AS Dump", $returnTo = "Main"]]
-	<<else>>
-		<br>[["Buy " + $him + " and finish your order of slaves"|Bulk Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $TGA.schoolSale = 0, $TGA.studentsBought += 1, $newSlaves.push($activeSlave)]]
-	<</if>>
-<<else>>
-	//You lack the necessary funds to buy this slave.//
-<</if>>
-<br>[["Decline to purchase " + $him + " and check out another slave"|The Gymnasium-Academy][$slavesSeen += 1]]
-<<if $newSlaves.length > 0>>
-	<br>[[Finish your order of slaves|Bulk Slave Intro]]
-<</if>>
-
-<br><br>
-<<set $saleDescription = 1>><<include "Long Slave Description">>
+<<buyingFromSchoolControls $TGA "slave" "slaves">>
diff --git a/src/uncategorized/theSlavegirlSchool.tw b/src/uncategorized/theSlavegirlSchool.tw
index d356e2914f1..f0f4391de8e 100644
--- a/src/uncategorized/theSlavegirlSchool.tw
+++ b/src/uncategorized/theSlavegirlSchool.tw
@@ -23,20 +23,4 @@
 <br><br>The price is <<print cashFormat($slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>>
 
 <<setLocalPronouns $activeSlave>>
-<<if $cash >= $slaveCost>>
-	<br>[["Buy " + $him + " and check out other slaves to order"|The Slavegirl School][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $TSS.schoolSale = 0, $TSS.studentsBought += 1, $newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]]
-	<<if $newSlaves.length == 0>>
-		<br>[["Buy " + $his + " slave contract"|New Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $TSS.schoolSale = 0, $TSS.studentsBought += 1, $nextButton = "Continue", $nextLink = "AS Dump", $returnTo = "Main"]]
-	<<else>>
-		<br>[["Buy " + $him + " and finish your order of slaves"|Bulk Slave Intro][$cashX(forceNeg($slaveCost), "slaveTransaction", $activeSlave), $TSS.schoolSale = 0, $TSS.studentsBought += 1, $newSlaves.push($activeSlave)]]
-	<</if>>
-<<else>>
-	//You lack the necessary funds to buy this slave.//
-<</if>>
-<br>[["Decline to purchase " + $him + " and check out another slave"|The Slavegirl School][$slavesSeen += 1]]
-<<if $newSlaves.length > 0>>
-	<br>[[Finish your order of slaves|Bulk Slave Intro]]
-<</if>>
-
-<br><br>
-<<set $saleDescription = 1>><<include "Long Slave Description">>
+<<buyingFromSchoolControls $TSS "slave" "slaves">>
diff --git a/src/utility/slaveCreationWidgets.tw b/src/utility/slaveCreationWidgets.tw
index c90d1680a1d..40f92d0f249 100644
--- a/src/utility/slaveCreationWidgets.tw
+++ b/src/utility/slaveCreationWidgets.tw
@@ -4783,3 +4783,59 @@
 		/* Closes Entertain */
 		<</switch>>
 <</widget>>
+
+/%
+ % Shows controls for buying and advancing the queue for buying slaves from a school
+ % Arguments: none
+ % Call as <<buyingFromMarketControls>>
+ %/
+<<widget "buyingFromMarketControls">>
+<br>[["Decline to purchase " + $him + " and check out another slave"|passage()][$slavesSeen += 1]]
+<<if $cash >= $slaveCost>>
+	<br>[["Buy " + $him + " and check out other slaves to order"|passage()][cashX(forceNeg($slaveCost), "slaveTransfer", $activeSlave),$newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]]
+	<<if $newSlaves.length == 0>>
+		<br>[["Buy " + $his + " slave contract"|New Slave Intro][cashX(forceNeg($slaveCost), "slaveTransfer", $activeSlave),$nextButton = "Continue",$nextLink = "AS Dump",$returnTo = "Main"]]
+	<<else>>
+		<br>[["Buy " + $him + " and finish your order of slaves"|Bulk Slave Intro][cashX(forceNeg($slaveCost), "slaveTransfer", $activeSlave), $newSlaves.push($activeSlave)]]
+	<</if>>
+<<else>>
+	<br>//You lack the necessary funds to buy this slave.//
+<</if>>
+<<if $newSlaves.length > 0>>
+	<br>[[Finish your order of slaves|Bulk Slave Intro]]
+<</if>>
+<br><br>
+<<if $slaveMarket != "indentures" && $slaveMarket != "neighbor" && $slaveMarket != "heap" && $slaveMarket != "wetware">>
+	<<set $applyLaw = 1>>
+<</if>>
+<<set $saleDescription = 1>><<include "Long Slave Description">>
+<</widget>>
+
+/%
+ % Shows controls for buying and advancing the queue for buying slaves from a school
+ % Arguments:
+ % 0: school
+ % 1: name for a single slave ("slave", "cow", etc.)
+ % 2: name for a bunch of them ("slaves", "cattle", etc.)
+ % Call as <<buyingFromSchoolControls $TCR "cow" "cattle">>
+ %/
+<<widget "buyingFromSchoolControls">>
+<br>[["Decline to purchase " + $him + " and check out another " + $args[1]|passage()][$slavesSeen += 1]]
+<<if $cash >= $slaveCost>>
+	<<set _schoolToBuyFrom = $args[0]>>
+	<br>[["Buy " + $him + " and check out other " + $args[2] + "s to order"|passage()][cashX(forceNeg($slaveCost), "slaveTransfer", $activeSlave), _schoolToBuyFrom.schoolSale = 0, _schoolToBuyFrom.studentsBought += 1, $newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]]
+	<<if $newSlaves.length == 0>>
+		<br>[["Buy " + $his + " slave contract"|New Slave Intro][cashX(forceNeg($slaveCost), "slaveTransfer", $activeSlave), _schoolToBuyFrom.schoolSale = 0, _schoolToBuyFrom.studentsBought += 1, $nextButton = "Continue", $nextLink = "AS Dump", $returnTo = "Main"]]
+	<<else>>
+		<br>[["Buy " + $him + " and finish your order of " + $args[3]|Bulk Slave Intro][cashX(forceNeg($slaveCost), "slaveTransfer", $activeSlave), _schoolToBuyFrom.schoolSale = 0, _schoolToBuyFrom.studentsBought += 1, $newSlaves.push($activeSlave)]]
+	<</if>>
+<<else>>
+	<br>//You lack the necessary funds to buy this $args[1].//
+<</if>>
+<<if $newSlaves.length > 0>>
+	<br>[["Finish your order of " + $args[2]|"Bulk Slave Intro"]]
+<</if>>
+
+<br><br>
+<<set $saleDescription = 1>><<include "Long Slave Description">>
+<</widget>>
-- 
GitLab