From 250ddb6b4ce38e03380998ef6e868e82b4d6e7ec Mon Sep 17 00:00:00 2001
From: Jones <Jones>
Date: Wed, 20 Nov 2019 23:28:18 +0100
Subject: [PATCH] Groundwork

brothel/whoring converted to make use of supply and demand
---
 src/endWeek/saWhore.js                      | 179 +--------
 src/init/storyInit.tw                       |   8 +-
 src/js/economyJS.js                         | 421 ++++++++++++++++++--
 src/uncategorized/brothelReport.tw          |  66 +--
 src/uncategorized/clubReport.tw             |   2 +-
 src/uncategorized/endWeek.tw                |   2 +-
 src/uncategorized/slaveAssignmentsReport.tw | 185 ++++++++-
 7 files changed, 604 insertions(+), 259 deletions(-)

diff --git a/src/endWeek/saWhore.js b/src/endWeek/saWhore.js
index e9f2ce3b42a..0dc511e0aa3 100644
--- a/src/endWeek/saWhore.js
+++ b/src/endWeek/saWhore.js
@@ -10,8 +10,6 @@ window.saWhore = (function saWhore() {
 	let FuckResult;
 	let cash;
 
-	let beautyMultiplier;
-	let beautyCorrection;
 	let cervixPump;
 	let he, him, his, hers, himself, girl, loli, He, His;
 
@@ -85,155 +83,9 @@ window.saWhore = (function saWhore() {
 	 * @param {App.Entity.SlaveState} slave
 	 */
 	function updateNonSlaveVariables(slave) {
-		let BL = V.BrothiIDs.length;
-
-		// FResult setting
-		FuckResult = FResult(slave);
-		// slave needs release
-		if ((slave.releaseRules === "restrictive" || slave.releaseRules === "chastity") && slave.standardReward !== "orgasm" && slave.energy >= 20) {
-			FuckResult += 2;
-		}
-		if (V.ACitizens > (V.ASlaves * 4)) {
-			FuckResult = Math.trunc(FuckResult * 1.1);
-		} else if (V.ACitizens > (V.ASlaves * 2)) {
-			FuckResult = Math.trunc(FuckResult * 1);
-		} else if (V.ACitizens > V.ASlaves) {
-			FuckResult = Math.trunc(FuckResult * 0.95);
-		} else if (V.ACitizens > (V.ASlaves * 0.5)) {
-			FuckResult = Math.trunc(FuckResult * 0.9);
-		} else {
-			FuckResult = Math.trunc(FuckResult * 0.85);
-		}
-		if (canDoVaginal(slave) && slave.vagina === 0) {
-			FuckResult += 5;
-		}
-		if (canDoAnal(slave) && slave.anus === 0) {
-			FuckResult += 10;
-		}
-
-		// Beauty setting
-		beauty = Beauty(slave);
-		if (V.ACitizens > (V.ASlaves * 4)) {
-			beauty = Math.trunc(beauty * 1.1);
-		} else if (V.ACitizens > (V.ASlaves * 2)) {
-			beauty = Math.trunc(beauty * 1);
-		} else if (V.ACitizens > V.ASlaves) {
-			beauty = Math.trunc(beauty * 0.95);
-		} else if (V.ACitizens > (V.ASlaves * 0.5)) {
-			beauty = Math.trunc(beauty * 0.9);
-		} else {
-			beauty = Math.trunc(beauty * 0.85);
-		}
-		if (slave.sexualFlaw === "neglectful") {
-			beauty = Math.trunc(beauty * 1.1);
-		}
-		if (slave.assignment === "be the Madam") {
-			if (BL + V.slavesGettingHelp > 0) {
-				beauty = Math.trunc(beauty * ((10 - BL - V.slavesGettingHelp) / 10));
-			}
-		}
-		if (slave.minorInjury !== 0) {
-			beauty -= 1;
-		}
-
-		// Beauty multipliers
-		beautyMultiplier = 1;
-		if (V.brothel > 0) {
-			if ((V.universalRulesFacilityWork === 1 && slave.assignment === "whore" && V.brothelSpots > 0) || (slave.assignment === "work in the brothel")) {
-				if (slave.assignment === "whore") {
-					V.brothelSpots -= 1;
-				}
-				// ads
-				if (V.brothelAdsSpending !== 0) {
-					if (V.brothelAdsStacked === 1) {
-						if (isStacked(slave)) {
-							beautyMultiplier += 0.05;
-						}
-					} else if (V.brothelAdsStacked === -1) {
-						if (isSlim(slave)) {
-							beautyMultiplier += 0.05;
-						}
-					}
-					if (V.brothelAdsPreg === 1) {
-						if (slave.bellyPreg >= 5000 || slave.bellyImplant >= 5000) {
-							beautyMultiplier += 0.05;
-						}
-					} else if (V.brothelAdsPreg === -1) {
-						if (slave.belly < 100 && slave.weight < 30 && !setup.fakeBellies.includes(slave.bellyAccessory) && slave.bellyImplant <= 0) {
-							beautyMultiplier += 0.05;
-						}
-					}
-					if (V.brothelAdsModded === 1) {
-						if ((V.modScore > 15) || (V.piercingScore > 8 && V.tatScore > 5)) {
-							beautyMultiplier += 0.05;
-						}
-					} else if (V.brothelAdsModded === -1) {
-						if (slave.corsetPiercing === 0 && V.piercingScore < 3 && V.tatScore < 2) {
-							beautyMultiplier += 0.05;
-						}
-					}
-					if (V.brothelAdsImplanted === 1) {
-						if (slave.boobsImplant > 0 && slave.buttImplant > 0 && slave.waist < -10 && slave.lipsImplant > 0) {
-							beautyMultiplier += 0.05;
-						}
-					} else if (V.brothelAdsImplanted === -1) {
-						if (slave.boobsImplant === 0 && slave.buttImplant === 0 && slave.waist >= -95 && slave.lipsImplant === 0 && slave.bellyImplant === -1 && slave.faceImplant < 30) {
-							beautyMultiplier += 0.05;
-						}
-					}
-					if (V.brothelAdsOld === 1) {
-						if (slave.physicalAge >= 30) {
-							beautyMultiplier += 0.05;
-						}
-					} else if (V.brothelAdsOld === -1) {
-						if (slave.physical < 30 && slave.physical >= 18) {
-							beautyMultiplier += 0.05;
-						}
-					} else if (V.brothelAdsOld === -2) {
-						if (slave.physical <= 18 && slave.physical >= 13) {
-							beautyMultiplier += 0.05;
-						}
-					} else if (V.brothelAdsOld === -3) {
-						if (slave.physical < 13) {
-							beautyMultiplier += 0.05;
-						}
-					}
-					if (V.brothelAdsXX === 1) {
-						if (slave.dick === 0 && slave.scrotum === 0) {
-							beautyMultiplier += 0.05;
-						}
-					} else if (V.brothelAdsXX === -1) {
-						if (slave.dick > 0) {
-							beautyMultiplier += 0.05;
-						}
-					}
-				}
-				if (V.Madam !== 0) {
-					if (V.madamCashBonus > 0) {
-						if (!canHear(slave)) {
-							beautyMultiplier += V.madamCashBonus * 0.5;
-						} else {
-							beautyMultiplier += V.madamCashBonus;
-						}
-					}
-				}
-			}
-		}
-
-		// setting and adjustments
-		beauty = Math.trunc(beauty * beautyMultiplier);
-		if ((slave.hears === -1 && slave.earwear !== "hearing aids") || (slave.hears === 0 && slave.earwear === "muffling ear plugs") ||(slave.hears === -2)) {
-			if (!canHear(slave)) {
-				beauty *= 0.75;
-			} else {
-				beauty *= 0.90;
-			}
-		}
-		if (beauty > 210) {
-			beautyCorrection = beauty / 210;
-			beauty = 210;
-			FuckResult = Math.trunc(beautyCorrection * FuckResult);
-		}
+		// FuckResult and FuckAmount setting
+		FuckResult = slave.sexQuality;
+		beauty = slave.sexAmount;
 		T.incomeStats.customers = beauty;
 	}
 
@@ -404,9 +256,6 @@ window.saWhore = (function saWhore() {
 			r += `, so many that ${he} occasionally had sex with multiple customers at once`;
 		}
 		r += `. They paid ${cashFormat(FuckResult)} on average`;
-		if (beautyCorrection > 1) {
-			r += `, including a premium for being in extremely high demand`;
-		}
 		r += `.`;
 	}
 
@@ -561,7 +410,7 @@ window.saWhore = (function saWhore() {
 					slave.vagina = 1;
 				}
 			} else if (slave.vagina < 3) {
-				if (jsRandom(1, 100) > ((170 - slave.sexAmount) + (slave.vagina * 10) + (slave.skill.vaginal / 3))) {
+				if (jsRandom(1, 100) > ((170 - beauty) + (slave.vagina * 10) + (slave.skill.vaginal / 3))) {
 					r += ` <span class="lime">${His} pussy gets loosened by the intense use.</span>`;
 					slave.vagina += 1;
 				}
@@ -586,17 +435,17 @@ window.saWhore = (function saWhore() {
 				}
 			} else if (slave.anus < 3) {
 				if (slave.vagina < 0) {
-					if (jsRandom(1, 100) > ((150 - slave.sexAmount) + (slave.anus * 10) + (slave.skill.anal / 6))) {
+					if (jsRandom(1, 100) > ((150 - beauty) + (slave.anus * 10) + (slave.skill.anal / 6))) {
 						r += ` <span class="lime">${His} asshole sees constant use in place of a pussy and loosens.</span>`;
 						slave.anus += 1;
 					}
 				} else if (!canDoVaginal(slave)) {
-					if (jsRandom(1, 100) > ((150 - slave.sexAmount) + (slave.anus * 10) + (slave.skill.anal / 6))) {
+					if (jsRandom(1, 100) > ((150 - beauty) + (slave.anus * 10) + (slave.skill.anal / 6))) {
 						r += ` <span class="lime">${His} asshole sees constant use in place of ${his} protected pussy and loosens.</span>`;
 						slave.anus += 1;
 					}
 				} else {
-					if (jsRandom(1, 100) > ((160 - slave.sexAmount) + (slave.anus * 10) + (slave.skill.anal / 6))) {
+					if (jsRandom(1, 100) > ((160 - beauty) + (slave.anus * 10) + (slave.skill.anal / 6))) {
 						r += ` <span class="lime">${His} asshole loosens with constant use.</span>`;
 						slave.anus += 1;
 					}
@@ -1409,11 +1258,19 @@ window.saWhore = (function saWhore() {
 	 * @param {App.Entity.SlaveState} slave
 	 */
 	function addCash(slave) {
-		cash = Math.trunc((beauty * FuckResult) * (1 + (0.002 * slave.skill.whoring)));
+		let whoreScore = s.sexAmount * s.sexQuality; // The standard amount of money the whore is expected to make in a week
+		if (whoreScore > 9600 && s.skill.whore > 80) { // whoreScore threshold updated to reflect tier specific bonus/penalty
+			cash = whoreScore * V.whorePriceAdjustment[3]; // final price adjustment for supply and demand
+		} else if (whoreScore > 5250 && s.skill.whore > 50) {
+			cash = whoreScore * V.whorePriceAdjustment[2];
+		} else if (whoreScore > 1800) {
+			cash = whoreScore * V.whorePriceAdjustment[1];
+		} else {
+			cash = whoreScore * V.whorePriceAdjustment[0];
+		}
 		if (slave.assignment === "work in the brothel") {
 			cashX(cash, "whoreBrothel", slave);
 		} else if (slave.assignment === "be the Madam") {
-			cash = cash*1.5; /* Madam is a popular lady if you can get her */
 			cashX(cash, "whoreBrothel", slave);
 		} else if (slave.assignment === "whore") {
 			cashX(cash, "whore", slave);
@@ -1664,7 +1521,7 @@ window.saWhore = (function saWhore() {
 						break;
 					case "humiliation":
 						r += ` ${He} enjoys the humiliation of being a whore, and got a bit of sexual satisfaction from every sex act ${he} performed this week.`;
-						slave.need -= slave.sexAmount;
+						slave.need -= beauty;
 				}
 			}
 		}
diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw
index 23543775e38..1c3bda72e96 100644
--- a/src/init/storyInit.tw
+++ b/src/init/storyInit.tw
@@ -1128,9 +1128,15 @@ You should have received a copy of the GNU General Public License along with thi
 <<set $slaveCostRandom = 0>>
 <<set $deltaDemand = 0>>
 <<set $deltaSupply = 0>>
-<<set $NPCSexSupply = {lowerClass: 3000}>>
+<<set $NPCSexSupply = {lowerClass: 3000, middleClass: 3000, upperClass: 3000, topClass: 3000}>>
 <<set $sexSubsidiesLC = 0>>
+<<set $sexSubsidiesMC = 0>>
+<<set $sexSubsidiesUC = 0>>
+<<set $sexSubsidiesTC = 0>>
 <<set $sexSupplyBarriersLC = 0>>
+<<set $sexSupplyBarriersMC = 0>>
+<<set $sexSupplyBarriersUC = 0>>
+<<set $sexSupplyBarriersTC = 0>>
 <<set $minimumSlaveCost = 2500>>
 <<set $facilityCost = 100>>
 <<set $enduringRep = 1000>>
diff --git a/src/js/economyJS.js b/src/js/economyJS.js
index 5752692576a..f1bab4aa9c5 100644
--- a/src/js/economyJS.js
+++ b/src/js/economyJS.js
@@ -878,8 +878,8 @@ window.menialSlaveCost = function(q = 0) {
 	return (Math.trunc(baseCost + demand / 400 - supply / 400 + q / 400) + random);
 };
 
-window.NPCSexSupply = function(LC) {
-	const NPCSexSupply = {lowerClass: V.NPCSexSupply.lowerClass};
+window.NPCSexSupply = function(LC, MC, UC, TC) {
+	const NPCSexSupply = {lowerClass: V.NPCSexSupply.lowerClass, middleClass: V.NPCSexSupply.middleClass, upperClass: V.NPCSexSupply.upperClass, topClass: V.NPCSexSupply.topClass};
 
 	// Lower class calculations
 	LC += V.sexSubsidiesLC / 10 - V.sexSupplyBarriersLC / 20;
@@ -891,15 +891,56 @@ window.NPCSexSupply = function(LC) {
 		}
 	}
 
+	// Middle class calculations
+	MC += V.sexSubsidiesMC / 10 - V.sexSupplyBarriersMC / 20;
+	if (MC >= 0.5) {
+		NPCSexSupply.middleClass += Math.max(Math.trunc(NPCSexSupply.lowerClass * ((MC - 0.5) * (0.2 - V.sexSupplyBarriersMC / 25))), (50 * (1 - V.sexSupplyBarriersMC / 5))); // Max growth of 10% per week, unless it is really low, than a flat 50
+	} else if (MC < 0.5) {
+		if (NPCSexSupply.middleClass > V.middleClass * (3 - V.sexSupplyBarriersMC / 2)) { // Natural market share of competitors is at least 30%
+			NPCSexSupply.middleClass -= Math.trunc(NPCSexSupply.middleClass * ((0.5 - MC) / 5)); // Max reduction of 10% per week
+		}
+	}
+
+	// upper class calculations
+	UC += V.sexSubsidiesUC / 10 - V.sexSupplyBarriersUC / 20;
+	if (UC >= 0.5) {
+		NPCSexSupply.upperClass += Math.max(Math.trunc(NPCSexSupply.upperClass * ((UC - 0.5) * (0.2 - V.sexSupplyBarriersUC / 25))), (50 * (1 - V.sexSupplyBarriersUC / 5))); // Max growth of 10% per week, unless it is really low, than a flat 50
+	} else if (UC < 0.5) {
+		if (NPCSexSupply.upperClass > V.upperClass * (3 - V.sexSupplyBarriersUC / 2)) { // Natural market share of competitors is at least 30%
+			NPCSexSupply.upperClass -= Math.trunc(NPCSexSupply.upperClass * ((0.5 - UC) / 5)); // Max reduction of 10% per week
+		}
+	}
+
+	// top class calculations
+	TC += V.sexSubsidiesTC / 10 - V.sexSupplyBarriersTC / 20;
+	if (TC >= 0.5) {
+		NPCSexSupply.topClass += Math.max(Math.trunc(NPCSexSupply.topClass * ((TC - 0.5) * (0.2 - V.sexSupplyBarriersTC / 25))), (50 * (1 - V.sexSupplyBarriersTC / 5))); // Max growth of 10% per week, unless it is really low, than a flat 50
+	} else if (TC < 0.5) {
+		if (NPCSexSupply.topClass > V.topClass * (3 - V.sexSupplyBarriersTC / 2)) { // Natural market share of competitors is at least 30%
+			NPCSexSupply.topClass -= Math.trunc(NPCSexSupply.topClass * ((0.5 - TC) / 5)); // Max reduction of 10% per week
+		}
+	}
+
 	return NPCSexSupply;
 };
 
 // The function for calculating and storing a slave's sexual interaction with citizens/'the outside'
 window.slaveJobValues = function() {
-	const slaveJobValues = {arcade: 0, club: 0, clubSP: 0}; let clubSpots = 0; const toTheClubTotal = 0;
+	const slaveJobValues = {
+		arcade: 0,
+		club: 0,
+		clubSP: 0,
+		brothel: [0, 0, 0, 0] // A list of values for each tier of whore (low, middle, upper, top)
+	};
+	let clubSpots;
+	let brothelSpots;
+	let toTheClubTotal = 0;
+	let toTheBrothelTotal = 0;
 	const AL = V.ArcadeiIDs.length;
 	const CL = V.ClubiIDs.length;
-	V.slavesGettingHelp = 0;
+	const BL = V.BrothiIDs.length;
+	V.clubSlavesGettingHelp = 0;
+	V.brothelSlavesGettingHelp = 0;
 
 	// This section is for specific slaves or non-unique slaves adding their values to the whole
 	// Accounting for Fuckdolls
@@ -913,23 +954,18 @@ window.slaveJobValues = function() {
 	});
 	if (V.DJ !== 0) {
 		if (!canTalk(V.DJ)) {
-			// <strong><u><span class="pink">$DJ.slaveName</span></u></strong> can't speak <span class="yellow">and cannot serve as your DJ any more.</span><br>
 			V.DJ = 0;
 			V.unDJ = 1;
 		} else if (V.DJ.preg > 37 && V.DJ.broodmother === 2) {
-			// <strong><u><span class="pink">$DJ.slaveName</span></u></strong> spends so much time giving birth and laboring that <span class="yellow">$he cannot effectively serve as your DJ any longer.</span>
 			V.DJ = 0;
 			V.unDJ = 2;
 		} else if (V.DJ.fetish === "mindbroken") {
-			// <strong><u><span class="pink">$DJ.slaveName</span></u></strong> is mindbroken <span class="yellow">and cannot serve as your DJ any more.</span><br>
 			V.DJ = 0;
 			V.unDJ = 3;
 		} else if (!canWalk(V.DJ)) {
-			// <strong><u><span class="pink">$DJ.slaveName</span></u></strong> is no longer independently mobile <span class="yellow">and cannot serve as your DJ any more.</span><br>
 			V.DJ = 0;
 			V.unDJ = 4;
 		} else if (!canHear(V.DJ)) {
-			// <strong><u><span class="pink">$DJ.slaveName</span></u></strong> can no longer hear <span class="yellow">and cannot serve as your DJ any more.</span><br>
 			V.DJ = 0;
 			V.unDJ = 5;
 		}
@@ -943,9 +979,7 @@ window.slaveJobValues = function() {
 		if (V.DJ.eyes <= -2) {
 			V.DJRepBonus += 0.15;
 		}
-		if (V.DJ.skill.entertainment <= 10) {
-			// Though $DJ.slaveName does $his best to lead on the club, with $his lack of skill $he can do little.
-		} else if (V.DJ.skill.entertainment <= 30) {
+		if ( V.DJ.skill.entertainment > 10 && V.DJ.skill.entertainment <= 30) {
 			V.DJRepBonus += 0.05;
 			// $DJ.slaveName's basic skills marginally <span class="green">improve</span> the atmosphere in $clubName.
 		} else if (V.DJ.skill.entertainment <= 60) {
@@ -987,6 +1021,122 @@ window.slaveJobValues = function() {
 		clubSpots = V.club - CL;
 	}
 
+	// Accounting for the Madam
+	V.Madam = V.slaves.find(s => {
+		return s.assignment === "be the Madam";
+	});
+	if (V.Madam !== 0) {
+		if (!canTalk(V.Madam)) {
+			V.Madam = 0;
+			V.unMadam = 1;
+		} else if (V.Madam.preg > 37 && V.Madam.broodmother === 2) {
+			V.Madam = 0;
+			V.unMadam = 2;
+		} else if (V.Madam.fetish === "mindbroken") {
+			V.Madam = 0;
+			V.unMadam = 3;
+		} else if (!canWalk(V.Madam)) {
+			V.Madam = 0;
+			V.unMadam = 4;
+		} else if (!canSee(V.Madam)) {
+			V.Madam = 0;
+			V.unMadam = 5;
+		} else if (!canHear(V.Madam)) {
+			V.Madam = 0;
+			V.unMadam = 6;
+		}
+	}
+	if (V.Madam !== 0) {
+		V.MadamCashBonus = 0;
+		if (V.Madam.relationship === -3 && V.Madam.devotion > 50) {
+		// As your loving $wife, $he does $his best to attract attention to your brothel.
+		V.MadamCashBonus += 0.25;
+		}
+		if (V.Madam.skill.whoring > 10 && V.Madam.skill.whoring <= 30) {
+			// V.Madam.slaveName's basic skills marginally @@.yellowgreen;improve@@ business at $brothelName.
+			V.MadamCashBonus += 0.05;
+		} else if (V.Madam.skill.whoring <= 60) {
+			// V.Madam.slaveName's skills @@.yellowgreen;improve@@ business at $brothelName.
+			V.MadamCashBonus += 0.1;
+		} else if (V.Madam.skill.whoring < 100) {
+			// V.Madam.slaveName's skills greatly @@.yellowgreen;improve@@ business at $brothelName.
+			V.MadamCashBonus += 0.15;
+		} else {
+			// V.Madam.slaveName's mastery immensely @@.yellowgreen;improves@@ business at $brothelName.
+			V.MadamCashBonus += 0.20;
+		}
+		if (V.Madam.actualAge > 35) {
+			// $His age and experience also contribute.
+			V.MadamCashBonus += 0.05;
+		} else if ($AgePenalty === 0) {
+			V.MadamCashBonus += 0.05;
+		}
+		if (V.setup.madamCareers.includes(V.Madam.career)) {
+			// $He has experience from $his life before $he was a slave that helps $him in the seedy business of selling other people's bodies for sex.
+			V.MadamCashBonus += 0.05;
+		} else if (V.Madam.skill.madam >= $masteredXP) {
+			// $He has experience from working for you that helps $him in the seedy business of selling other people's bodies for sex.
+			V.MadamCashBonus += 0.05;
+		} else {
+			V.Madam.skill.madam += jsRandom(1, Math.ceil((V.Madam.intelligence + V.Madam.intelligenceImplant) / 15) + 8);
+		}
+		if (V.Madam.intelligence+V.Madam.intelligenceImplant > 15) {
+			// $He is a clever manager.
+			V.MadamCashBonus += 0.05 * Math.floor((V.Madam.intelligence + V.Madam.intelligenceImplant) / 32);
+		}
+		if (V.Madam.dick > 2 && canPenetrate(V.Madam)) {
+			// $His turgid dick helps $him manage the bitches.
+			V.MadamCashBonus += 0.05;
+		}
+		for (let dI = 0; dI < BL; dI++) {
+			let i = V.slaveIndices[V.BrothiIDs[dI]];
+			if (V.Madam.relationshipTarget === V.slaves[i].ID) {
+				V.MadamCashBonus -= 0.05;
+			} else if (V.familyTesting === 1 && areRelated(V.Madam, V.slaves[i]) > 0) {
+				V.MadamCashBonus += 0.05;
+			} else if( V.Madam.relationTarget === V.slaves[i].ID && $familyTesting === 0) {
+				V.MadamCashBonus += 0.05;
+			}
+			if (V.slaves[i].prestigeDesc === "$He is a famed Free Cities whore, and commands top prices.") {
+				V.MadamCashBonus += 0.15;
+			} else if (V.slaves[i].prestigeDesc === "$He is a famed Free Cities slut, and can please anyone.") {
+				V.MadamCashBonus += 0.15;
+			} else if (V.slaves[i].prestigeDesc === "$He is remembered for winning best in show as a dairy cow.") {
+				if ($arcologies[0].FSPhysicalIdealist !== "unset") {
+					if (V.slaves[i].muscles > 60 && V.slaves[i].weight < 30 && V.slaves[i].lactation > 0 && V.slaves[i].boobs-V.slaves[i].boobsImplant > 6000) {
+						V.MadamCashBonus += 0.15;
+					}
+				} else if (V.slaves[i].lactation > 0 && V.slaves[i].boobs-V.slaves[i].boobsImplant > 6000) {
+					V.MadamCashBonus += 0.10;
+				}
+			} else if (V.slaves[i].prestigeDesc === "$He is remembered for winning best in show as a cockmilker.") {
+				if (V.arcologies[0].FSGenderFundamentalist !== "unset") {
+					if (V.slaves[i].balls === 0 && V.slaves[i].dick === 0 && V.slaves[i].vagina > -1) { /* this needs review - doesn't fit right. An XY slave would be expected to be masculine. */
+						V.MadamCashBonus += 0.20;
+					}
+				} else if ((V.slaves[i].balls > 5 && V.slaves[i].dick !== 0) || (V.slaves[i].balls > 4 && V.slaves[i].dick !== 0 && V.slaves[i].prostate > 1)) {
+					V.MadamCashBonus += 0.15;
+				}
+			} else if (V.slaves[i].prestigeDesc === "$He is remembered for winning best in show as a breeder.") {
+				if (canGetPregnant(V.slaves[i])) {
+					V.MadamCashBonus += 0.15;
+				} else if (isPreg(V.slaves[i])) {
+					if (V.slaves[i].bellyPreg > 5000) {
+						V.madamCashBonus += 0.05;
+					} else {
+						V.MadamCashBonus += 0.10;
+					}
+				}
+			}
+		}
+	}
+
+
+	// Checking for space in the brothel
+	if (V.brothel > 0 && BL < V.club) {
+		brothelSpots = V.brothel - BL;
+	}
+
 	// Glory hole slaves adding to 'arcade'
 	V.JobIDArray["work a glory hole"].forEach(ID => {
 		const s = V.slaves[V.slaveIndices[ID]];
@@ -994,25 +1144,31 @@ window.slaveJobValues = function() {
 		slaveJobValues.arcade += s.sexAmount;
 	});
 
+	// Arcade slaves adding to 'arcade'
+	V.ArcadeiIDs.forEach(ID => {
+		const s = V.slaves[V.slaveIndices[ID]];
+		s.sexAmount = (jsRandom(200, 240) + (20 * (4 - (s.anus - 2 * V.arcadeUpgradeInjectors))) + (10 * (4 - (s.vagina - 2 * V.arcadeUpgradeInjectors))) + Math.trunc(s.health / 5));
+		slaveJobValues.arcade += s.sexAmount;
+	})
+
 	// Public sluts adding to 'club'
 	V.JobIDArray["serve the public"].forEach(ID => {
 		SJVClub(V.slaves[V.slaveIndices[ID]]);
 	});
 
-	// This loops through every slave, checks their assignment and applies the appropriate value to both slave and the aggregate
-	// The slave value sees use during individual end of the week evaluation
-	// The aggregate is used for determining macro variables like 'prices' for slave goods and services to then be used in end week calculations
-	V.slaves.forEach(s => {
-		// Arcade slaves adding to 'arcade'
-		if (s.assignment === "be confined in the arcade") {
-			s.sexAmount = (jsRandom(200, 240) + (20 * (4 - (s.anus - 2 * V.arcadeUpgradeInjectors))) + (10 * (4 - (s.vagina - 2 * V.arcadeUpgradeInjectors))) + Math.trunc(s.health / 5));
-			slaveJobValues.arcade += s.sexAmount;
-		}
+	// Club sluts adding to 'club'
+	V.ClubiIDs.forEach(ID => {
+		SJVClub(V.slaves[V.slaveIndices[ID]]);
+	});
 
-		// Club and public sluts adding to 'club'. Also recruiters assigned as sexual ambassador to another arcology.
-		if (s.assignment === "serve in the club" || (s.assignment === "recruit girls" && V.recruiterTarget === "other arcologies")) {
-			SJVClub(s);
-		}
+	// Street whores adding to 'brothel'
+	V.JobIDArray["whore"].forEach(ID => {
+		SJVBrothel(V.slaves[V.slaveIndices[ID]]);
+	});
+
+	// Brothel whores adding to 'brothel'
+	V.BrothiIDs.forEach(ID => {
+		SJVBrothel(V.slaves[V.slaveIndices[ID]]);
 	});
 
 	function SJVClub(s) {
@@ -1030,7 +1186,8 @@ window.slaveJobValues = function() {
 		if (((V.universalRulesFacilityWork === 1) && (s.assignment === "serve the public") && (clubSpots > 0)) || (s.assignment === "serve in the club")) {
 			if (s.assignment === "serve the public") {
 				toTheClub = 1;
-				V.slavesGettingHelp += 1;
+				toTheClubTotal += 1;
+				V.clubSlavesGettingHelp += 1;
 			}
 			if (V.clubAdsSpending !== 0) {
 				if (V.clubAdsStacked === 1) {
@@ -1190,11 +1347,9 @@ window.slaveJobValues = function() {
 			s.sexQuality += 2;
 		} else if (s.devotion > 50) {
 			s.sexQuality += 1;
-		} else if (s.devotion > 20) {
-			// Nothing happens
-		} else if (s.trust < -20) {
+		} else if (s.trust > -20 && s.trust <= 20) {
 			s.sexQuality -= 1;
-		} else {
+		} else if (s.trust < -20) {
 			s.sexQuality -= 2;
 		}
 		if (s.assignment === "serve in the club") {
@@ -1208,6 +1363,212 @@ window.slaveJobValues = function() {
 		}
 	}
 
+	function SJVBrothel(s) {
+		let whoreScore;
+		let toTheBrothel = 0;
+		let beautyMultiplier = 1;
+		s.minorInjury = 0;
+
+		// Beauty multipliers
+		if (s.sexualFlaw === "neglectful") {
+			beautyMultiplier += 0.1;
+		}
+		if ((slave.hears === -1 && slave.earwear !== "hearing aids") || (slave.hears === 0 && slave.earwear === "muffling ear plugs") ||(slave.hears === -2)) {
+			if (!canHear(slave)) {
+				beautyMultiplier -= 0.25;
+			} else {
+				beautyMultiplier -= 0.10;
+			}
+		}
+		if (V.brothel > 0) {
+			if ((V.universalRulesFacilityWork === 1 && s.assignment === "whore" && brothelSpots > 0) || (s.assignment === "work in the brothel")) {
+				if (s.assignment === "whore") {
+					toTheBrothel = 1;
+					toTheBrothelTotal += 1;
+					V.brothelSlavesGettingHelp += 1;
+				}
+				// ads
+				if (V.brothelAdsSpending !== 0) {
+					if (V.brothelAdsStacked === 1) {
+						if (isStacked(s)) {
+							beautyMultiplier += 0.05;
+						}
+					} else if (V.brothelAdsStacked === -1) {
+						if (isSlim(s)) {
+							beautyMultiplier += 0.05;
+						}
+					}
+					if (V.brothelAdsPreg === 1) {
+						if (s.bellyPreg >= 5000 || s.bellyImplant >= 5000) {
+							beautyMultiplier += 0.05;
+						}
+					} else if (V.brothelAdsPreg === -1) {
+						if (s.belly < 100 && s.weight < 30 && !setup.fakeBellies.includes(s.bellyAccessory) && s.bellyImplant <= 0) {
+							beautyMultiplier += 0.05;
+						}
+					}
+					if (V.brothelAdsModded === 1) {
+						if ((V.modScore > 15) || (V.piercingScore > 8 && V.tatScore > 5)) {
+							beautyMultiplier += 0.05;
+						}
+					} else if (V.brothelAdsModded === -1) {
+						if (s.corsetPiercing === 0 && V.piercingScore < 3 && V.tatScore < 2) {
+							beautyMultiplier += 0.05;
+						}
+					}
+					if (V.brothelAdsImplanted === 1) {
+						if (s.boobsImplant > 0 && s.buttImplant > 0 && s.waist < -10 && s.lipsImplant > 0) {
+							beautyMultiplier += 0.05;
+						}
+					} else if (V.brothelAdsImplanted === -1) {
+						if (s.boobsImplant === 0 && s.buttImplant === 0 && s.waist >= -95 && s.lipsImplant === 0 && s.bellyImplant === -1 && s.faceImplant < 30) {
+							beautyMultiplier += 0.05;
+						}
+					}
+					if (V.brothelAdsOld === 1) {
+						if (s.physicalAge >= 30) {
+							beautyMultiplier += 0.05;
+						}
+					} else if (V.brothelAdsOld === -1) {
+						if (s.physical < 30 && s.physical >= 18) {
+							beautyMultiplier += 0.05;
+						}
+					} else if (V.brothelAdsOld === -2) {
+						if (s.physical <= 18 && s.physical >= 13) {
+							beautyMultiplier += 0.05;
+						}
+					} else if (V.brothelAdsOld === -3) {
+						if (s.physical < 13) {
+							beautyMultiplier += 0.05;
+						}
+					}
+					if (V.brothelAdsXX === 1) {
+						if (s.dick === 0 && s.scrotum === 0) {
+							beautyMultiplier += 0.05;
+						}
+					} else if (V.brothelAdsXX === -1) {
+						if (s.dick > 0) {
+							beautyMultiplier += 0.05;
+						}
+					}
+				}
+				if (V.Madam !== 0) {
+					if (V.madamCashBonus > 0) {
+						if (!canHear(s)) {
+							beautyMultiplier += V.madamCashBonus * 0.5;
+						} else {
+							beautyMultiplier += V.madamCashBonus;
+						}
+					}
+				}
+			}
+		}
+
+		// Injuries
+		if (s.assignment === "whore" && !toTheBrothel) {
+			if (s.curatives < 1 && s.inflationType !== "curative") {
+				if (s.health < -50) {
+					s.health -= 13;
+					s.minorInjury = 1;
+				} else if (s.health < -20 && jsRandom(1, 100) > 50) {
+					s.health -= 10;
+					s.minorInjury = 1;
+				} else {
+					let canA = canDoAnal(s);
+					let canV = canDoVaginal(s);
+					let skilltarget = (100 + ((s.skill.anal - 100)*canA*(1.5 - 0.5*canV) + (s.skill.vaginal - 100)*canV*(1.5 - 0.5*canA) + (s.skill.oral - 100)*(3 - 1.5*canA - 1.5*canV + canA*canV))*3/10);
+					// Complicated, I know - but it should automatically account for what acts are possible to scale the injury risk smoothly between 90% when totally unskilled
+					// and 0% when perfectly skilled in the relevant method or methods.
+
+					if (jsRandom(1, 100) > skilltarget) {
+						s.health -= 10 - 7*canA*canV; // Any limitations means an injury inflicts the harsher 10 instead of 3
+						s.minorInjury = 1;
+					}
+				}
+			}
+			if (s.minorInjury === 1) {
+				let injuryChance;
+				beautyMultiplier -= 0.05;
+				if (canDoAnal(s)) {
+					injuryChance = jsRandom(1, 100);
+				} else {
+					injuryChance = jsRandom(1, 80);
+				}
+				if (injuryChance > 80) {
+					s.minorInjury = "sore ass";
+				} else if (injuryChance > 60) {
+					s.minorInjury = "black eye";
+				} else if (injuryChance > 40) {
+					s.minorInjury = "split lip";
+				} else if (injuryChance > 20) {
+					s.minorInjury = "bad bruise";
+				} else {
+					s.minorInjury = "sore muscle";
+				}
+			}
+		}
+
+		// The amount of sexual acts
+		s.sexAmount = Beauty(s);
+
+		if (s.assignment === "be the Madam") {
+			if ((BL + toTheBrothelTotal > 0) && (CL + toTheBrothelTotal < 10)) {
+				s.sexAmount *= ((10 - CL - toTheBrothelTotal) / 10) * 1.5;
+			}
+		}
+		s.sexAmount = Math.trunc(s.sexAmount * beautyMultiplier * (1 + (0.002 * s.skill.whoring)));
+
+		// The quality/value of each sexual act
+		s.sexQuality = FResult(s);
+		if ((s.releaseRules === "restrictive" || s.releaseRules === "chastity") && s.standardReward !== "orgasm" && s.energy >= 20) {
+			s.sexQuality += 2;
+		}
+		if (canDoAnal(s) && s.anus === 0) {
+			s.sexQuality += 5; // This was at 10, not sure what the reasoning behind that was
+		}
+		if (canDoVaginal(s) && s.vagina === 0) {
+			s.sexQuality += 5;
+		}
+		if (s.devotion > 95 || s.energy > 95) {
+			s.sexQuality += 2;
+		} else if (s.devotion > 50) {
+			s.sexQuality += 1;
+		} else if (s.trust > -20 && s.trust <= 20) {
+			s.sexQuality -= 1;
+		} else if (s.trust < -20) {
+			s.sexQuality -= 2;
+		}
+		if (s.assignment === "work in the brothel") {
+			s.sexQuality += 2;
+		} else if (toTheBrothel === 1) {
+			s.sexQuality += 2;
+			brothelSpots -= 1;
+		}
+
+		// Figuring out which type of customer the slave services (should probably be refined)
+		whoreScore = s.sexAmount * s.sexQuality; // The standard amount of money the whore is expected to make in a week
+		if (whoreScore > 8000 && s.skill.whore > 80) {
+			whoreScore = Math.trunc(whoreScore * 1.2); //  20% bonus to score for being of the heighest tier
+			s.sexAmount = jsRandom(30, 40); // Bringing sex amount into the desired range
+			s.sexQuality = Math.trunc(whoreScore / s.sexAmount); // Adjusting the price to the correct sex amount
+			slaveJobValues.brothel[3] += whoreScore; // Registering the job value in the right slot
+		} else if (whoreScore > 5000 && s.skill.whore > 50) {
+			whoreScore = Math.trunc(whoreScore * 1.05);
+			s.sexAmount = jsRandom(40, 55);
+			s.sexQuality = Math.trunc(whoreScore / s.sexAmount);
+			slaveJobValues.brothel[2] += whoreScore;
+		} else if (whoreScore > 2000) {
+			whoreScore = Math.trunc(whoreScore * 0.9);
+			s.sexAmount = jsRandom(55, 75);
+			s.sexQuality = Math.trunc(whoreScore / s.sexAmount);
+			slaveJobValues.brothel[1] += whoreScore;
+		} else {
+			whoreScore = Math.trunc(whoreScore * 0.75);
+			s.sexAmount = jsRandom(75, 100);
+			s.sexQuality = Math.trunc(whoreScore / s.sexAmount);
+			slaveJobValues.brothel[0] += whoreScore;
+		}
+	}
 	// Saturation penalty for public servants. Even the most beautiful slaves lose some of their shine if they have too much competition.
 	if (slaveJobValues.club > 0) {
 		slaveJobValues.clubSP = (Math.pow(slaveJobValues.club / 1000, 0.95) * 1000) / slaveJobValues.club;
diff --git a/src/uncategorized/brothelReport.tw b/src/uncategorized/brothelReport.tw
index c11deb30172..b49229f6017 100644
--- a/src/uncategorized/brothelReport.tw
+++ b/src/uncategorized/brothelReport.tw
@@ -4,7 +4,7 @@
 </span>
 
 <<SlaveIDSort $BrothiIDs>>
-<<set _DL = $BrothiIDs.length, _SL = $slaves.length, $legendaryWhoreID = 0, $madamCashBonus = 0, _FLsFetish = 0, _profits = 0>>
+<<set _DL = $BrothiIDs.length, _SL = $slaves.length, $legendaryWhoreID = 0, _FLsFetish = 0, _profits = 0>>
 <<set $legendaryWombID = 0>>
 <<set _modded = 0, _old = 0, _pure = 0, _slim = 0, _implanted = 0, _stacked = 0, _unmodded = 0, _XX = 0, _XY = 0, _young = 0, _pregYes = 0, _pregNo = 0, _minBonus = 50, _maxBonus = 150>>
 
@@ -50,7 +50,6 @@
 	&nbsp;&nbsp;&nbsp;&nbsp;<<= SlaveFullName($Madam)>> is serving as the Madam.
 	<<if $Madam.relationship == -3 && $Madam.devotion > 50>>
 		As your loving $wife, $he does $his best to attract attention to your brothel.
-		<<set $madamCashBonus += 0.25>>
 	<</if>>
 	<<if (_FLsFetish == 1)>>
 		$He isn't above sampling the merchandise $himself; before long it's obvious to $his girls that $he @@.lightcoral;really likes fucking them.@@
@@ -61,39 +60,26 @@
 		Though $Madam.slaveName does $his best to manage the brothel, with $his lack of skill $he can do little.
 	<<elseif ($Madam.skill.whoring <= 30)>>
 		$Madam.slaveName's basic skills marginally @@.yellowgreen;improve@@ business at $brothelName.
-		<<set $madamCashBonus += 0.05>>
 	<<elseif ($Madam.skill.whoring <= 60)>>
 		$Madam.slaveName's skills @@.yellowgreen;improve@@ business at $brothelName.
-		<<set $madamCashBonus += 0.1>>
 	<<elseif ($Madam.skill.whoring < 100)>>
 		$Madam.slaveName's skills greatly @@.yellowgreen;improve@@ business at $brothelName.
-		<<set $madamCashBonus += 0.15>>
 	<<else>>
 		$Madam.slaveName's mastery immensely @@.yellowgreen;improves@@ business at $brothelName.
-		<<set $madamCashBonus += 0.20>>
 	<</if>>
 	<<if ($Madam.actualAge > 35)>>
 		$His age and experience also contribute.
-		<<set $madamCashBonus += 0.05>>
-	<<elseif $AgePenalty == 0>>
-		<<set $madamCashBonus += 0.05>>
 	<</if>>
 	<<if setup.madamCareers.includes($Madam.career)>>
 		$He has experience from $his life before $he was a slave that helps $him in the seedy business of selling other people's bodies for sex.
-		<<set $madamCashBonus += 0.05>>
 	<<elseif $Madam.skill.madam >= $masteredXP>>
 		$He has experience from working for you that helps $him in the seedy business of selling other people's bodies for sex.
-		<<set $madamCashBonus += 0.05>>
-	<<else>>
-		<<set $slaves[_FLs].skill.madam += random(1,Math.ceil(($Madam.intelligence+$Madam.intelligenceImplant)/15) + 8)>>
 	<</if>>
 	<<if ($Madam.intelligence+$Madam.intelligenceImplant > 15)>>
 		$He is a clever manager.
-		<<set $madamCashBonus += 0.05*Math.floor(($Madam.intelligence+$Madam.intelligenceImplant)/32)>>
 	<</if>>
 	<<if ($Madam.dick > 2) && (canPenetrate($Madam))>>
 		$His turgid dick helps $him manage the bitches.
-		<<set $madamCashBonus += 0.05>>
 	<</if>>
 	<<for _dI = 0; _dI < _DL; _dI++>>
 		<<set $i = $slaveIndices[$BrothiIDs[_dI]]>>
@@ -116,37 +102,33 @@
 		<<elseif $Madam.relationshipTarget == $slaves[$i].ID>>
 			<<setLocalPronouns $slaves[$i] 2>>
 			$He dotes over $his <<print relationshipTerm($Madam)>>, $slaves[$i].slaveName, making sure _he2 is safe, but unfortunately driving potential customers away from _him2.
-			<<set $slaves[$i].devotion++, $madamCashBonus -= 0.05>>
+			<<set $slaves[$i].devotion++>>
 		<<elseif $familyTesting == 1 && areRelated($Madam, $slaves[$i]) > 0>>
 			<<setLocalPronouns $slaves[$i] 2>>
 			$He pays special attention to $his <<print relativeTerm($Madam,$slaves[$i])>>, $slaves[$i].slaveName, making sure _he2 is treated well and showing off _his2 skills.
-			<<set $slaves[$i].trust++, $madamCashBonus += 0.05>>
+			<<set $slaves[$i].trust++>>
 		<<elseif $Madam.relationTarget == $slaves[$i].ID && $familyTesting == 0>>
 			<<setLocalPronouns $slaves[$i] 2>>
 			$He pays special attention to $his $slaves[$i].relation, $slaves[$i].slaveName, making sure _he2 is treated well and showing off _his2 skills.
-			<<set $slaves[$i].trust++, $madamCashBonus += 0.05>>
+			<<set $slaves[$i].trust++>>
 		<</if>>
 		<<if $slaves[$i].prestigeDesc == "$He is a famed Free Cities whore, and commands top prices.">>
 			<<setLocalPronouns $slaves[$i] 2>>
 			$He makes sure to promote $slaves[$i].slaveName, the famed whore, in order to capitalize on _his2 popularity.
-			<<set $madamCashBonus += 0.15>>
 		<<elseif $slaves[$i].prestigeDesc == "$He is a famed Free Cities slut, and can please anyone.">>
 			<<setLocalPronouns $slaves[$i] 2>>
 			$He makes sure to promote $slaves[$i].slaveName, the famed entertainer, in order to capitalize on _his2 popularity.
-			<<set $madamCashBonus += 0.15>>
 		<<elseif $slaves[$i].prestigeDesc == "$He is remembered for winning best in show as a dairy cow.">>
 			<<setLocalPronouns $slaves[$i] 2>>
 			<<if ($arcologies[0].FSPhysicalIdealist != "unset")>>
 				<<if ($slaves[$i].muscles > 60) && ($slaves[$i].weight < 30) && ($slaves[$i].lactation > 0) && (($slaves[$i].boobs-$slaves[$i].boobsImplant) > 6000)>>
 					$He shows off how even a cow like $slaves[$i].slaveName can achieve physical perfection.
-					<<set $madamCashBonus += 0.15>>
 				<<else>>
-					A<<if ($slaves[$i].muscles < 30)>>n unmuscled,<</if>><<if ($slaves[$i].weight > 30)>> fat,<</if>> 'prestigious' <<if ($slaves[$i].lactation > 0)>>cow<<elseif (($slaves[$i].boobs-$slaves[$i].boobsImplant) > 6000)>>mass of titflesh<<else>>slave<</if>> like $slaves[$i].slaveName is woefully out of fashion, so $Milkmaid.slaveName tries to draw attention away from _him2.
+					A<<if ($slaves[$i].muscles < 30)>>n unmuscled,<</if>><<if ($slaves[$i].weight > 30)>> fat,<</if>> 'prestigious' <<if ($slaves[$i].lactation > 0)>>cow<<elseif (($slaves[$i].boobs-$slaves[$i].boobsImplant) > 6000)>>mass of titflesh<<else>>slave<</if>> like $slaves[$i].slaveName is woefully out of fashion, so $Madam.slaveName tries to draw attention away from _him2.
 				<</if>>
 			<<else>>
 				<<if ($slaves[$i].lactation > 0) && (($slaves[$i].boobs-$slaves[$i].boobsImplant) > 6000)>>
 					$He makes sure to massage $slaves[$i].slaveName's huge breasts to get the milk flowing before enticing clients to suckle and play with _him2.
-					<<set $madamCashBonus += 0.10>>
 				<<else>>
 					$He would like to show off $slaves[$i].slaveName's huge udders, but $slaves[$i].slaveName <<if ($slaves[$i].lactation == 0)>>isn't producing milk anymore<<else>>doesn't exactly have huge udders anymore<</if>>.
 				<</if>>
@@ -156,14 +138,12 @@
 			<<if $arcologies[0].FSGenderFundamentalist != "unset">> /* this needs review - doesn't fit right. An XY slave would be expected to be masculine. */
 				<<if ($slaves[$i].balls == 0) && ($slaves[$i].dick == 0) && ($slaves[$i].vagina > -1)>>
 					$He uses $slaves[$i].slaveName as an example of how even a huge-balled freak like _him2 can be restored to proper femininity.
-					<<set $madamCashBonus += 0.20>>
 				<<else>>
 					$He tries to hide $slaves[$i].slaveName, 'her' body being notorious for its defiance of conventional femininity.
 				<</if>>
 			<<else>>
 				<<if (($slaves[$i].balls > 5) && ($slaves[$i].dick != 0)) || (($slaves[$i].balls > 4) && ($slaves[$i].dick != 0) && ($slaves[$i].prostate > 1))>>
 					$He shows off $slaves[$i].slaveName's copious loads by putting a condom over _his2 dick and teasing _him2 till _he2 bursts it. The show draws multiple clients that want to play with _his2 oversized junk and messy orgasms.
-					<<set $madamCashBonus += 0.15>>
 				<<else>>
 					$He would love to show off $slaves[$i].slaveName's copious loads, but $slaves[$i].slaveName<<if $slaves[$i].dick == 0>> doesn't have a dick<<elseif $slaves[$i].balls == 0>>'s not producing cum<<else>>'s orgasms just aren't messy enough<</if>>.
 				<</if>>
@@ -172,38 +152,26 @@
 			<<setLocalPronouns $slaves[$i] 2>>
 			<<if $slaves[$i].bellyPreg >= 5000>>
 				$He makes sure $slaves[$i].slaveName's growing pregnancy is well taken care of, even if it means driving away potential customers away when the mother-to-be needs a rest.
-				<<set $madamCashBonus -= 0.05>>
 			<<elseif canGetPregnant($slaves[$i])>>
 				$He makes sure to play off $slaves[$i].slaveName's fame and fertility by enticing potential customers to be the one to claim _his2 womb by filling it with their child.
-				<<set $madamCashBonus += 0.15>>
 			<<else>>
-				$He would love to play off of $slaves[$i].slaveName's fame and fertility, but unfortunately _he2 <<if $slaves[$i].pregKnown == 1 && $slaves[$i].bellyPreg < 1500>>is already pregnant and not far enough along to show it<<elseif $slaves[$i].pregKnown == 1 && $slaves[$i].bellyPreg < 5000>>already pregnant, but not enough to be exciting<<else>>is unable to get knocked up<</if>>.
+				$He would love to play off of $slaves[$i].slaveName's fame and fertility, but unfortunately _he2 <<if $slaves[$i].pregKnown == 1 && $slaves[$i].bellyPreg < 5000>> is already pregnant<<else>>is unable to get knocked up<</if>>.
 			<</if>>
 		<</if>>
 	<</for>>
 
-	<<if (_DL < 5)>>
-		<<set $slavesGettingHelp = 0>>
-		<<if $universalRulesFacilityWork == 1>>
-			<<for $i = 0; $i < _SL; $i++>>
-				<<if ($slaves[$i].assignment == "whore")>>
-					<<set $slavesGettingHelp++>>
-				<</if>>
-			<</for>>
-		<</if>>
-		<<if (_DL+$slavesGettingHelp < 5)>>
-			<<set $i = _FLs>> /* apply following SA passages to facility leader */
-			<<setLocalPronouns $slaves[$i]>>
-			<<set _oldCash = $cash>>
-			<<if $showEWD != 0>>
-				<br>&nbsp;&nbsp;&nbsp;&nbsp;$He <<= saWhore($slaves[$i])>>
-			<<else>>
-				<<run saWhore($slaves[$i])>>
-			<</if>>
-			<br>&nbsp;&nbsp;&nbsp;&nbsp;
-			$He whores $himself because $he doesn't have enough whores to manage to keep $him busy, and makes @@.yellowgreen;<<print cashFormat($Madam.lastWeeksCashIncome)>>.@@ $He can charge more for $his time, since many citizens find it erotic to fuck the Madam.
-			<<set _profits += $cash-_oldCash, _oldCash = $cash>>
+	<<if (_DL+$brothelSlavesGettingHelp < 10)>>
+		<<set $i = _FLs>> /* apply following SA passages to facility leader */
+		<<setLocalPronouns $slaves[$i]>>
+		<<set _oldCash = $cash>>
+		<<if $showEWD != 0>>
+			<br>&nbsp;&nbsp;&nbsp;&nbsp;$He <<= saWhore($slaves[$i])>>
+		<<else>>
+			<<run saWhore($slaves[$i])>>
 		<</if>>
+		<br>&nbsp;&nbsp;&nbsp;&nbsp;
+		$He whores $himself because $he doesn't have enough whores to manage to keep $him busy, and makes @@.yellowgreen;<<print cashFormat($Madam.lastWeeksCashIncome)>>.@@ $He can charge more for $his time, since many citizens find it erotic to fuck the Madam.
+		<<set _profits += $cash - _oldCash, _oldCash = $cash>>
 	<</if>>
 	<<if (_DL > 0)>><br><br><</if>>
 <</if>>
diff --git a/src/uncategorized/clubReport.tw b/src/uncategorized/clubReport.tw
index 822fe8c470c..bbea7673357 100644
--- a/src/uncategorized/clubReport.tw
+++ b/src/uncategorized/clubReport.tw
@@ -86,7 +86,7 @@
 	<<else>>
 		<<set $slaves[_FLs].skill.DJ += random(1,Math.ceil(($DJ.intelligence+$DJ.intelligenceImplant)/15) + 8)>>
 	<</if>>
-	<<if (_DL + $slavesGettingHelp < 10)>>
+	<<if (_DL + $clubSlavesGettingHelp < 10)>>
 		<<set $i = _FLs>> /* apply following SA passages to facility leader */
 		<<if ($legendaryEntertainerID == 0) && ($slaves[_FLs].prestige == 0) && ($slaves[_FLs].skill.entertainment >= 100) && ($slaves[_FLs].devotion > 50)>>
 			<<set $legendaryEntertainerID = $slaves[_FLs].ID>>
diff --git a/src/uncategorized/endWeek.tw b/src/uncategorized/endWeek.tw
index 4a032394187..0f52a3cd9ec 100644
--- a/src/uncategorized/endWeek.tw
+++ b/src/uncategorized/endWeek.tw
@@ -253,7 +253,7 @@
 	<<set $PC.pregWeek++>>
 <</if>>
 
-<<set $HGEnergy = 0, $HGCum = 0, $HGSlaveSuccess = 0, $HeadGirl = 0, $Recruiter = 0, $Madam = 0, $madamCashBonus = 0, $DJ = 0, $unDJ = 0, $DJRepBonus = 0, $Milkmaid = 0, $Farmer = 0, $Collectrix = 0, $Stewardess = 0, $Schoolteacher = 0, $Wardeness = 0, $Concubine = 0, $Attendant = 0, $Matron = 0, $Nurse = 0, $Bodyguard = 0, $fuckSlaves = 0, $freeSexualEnergy = 0, $publicServants = 0, $cumSlaves = 0, $averageDick = 0, $slavesWithWorkingDicks = 0, $slaveJobValues = {}>>
+<<set $HGEnergy = 0, $HGCum = 0, $HGSlaveSuccess = 0, $HeadGirl = 0, $Recruiter = 0, $Madam = 0, $unMadam = 0, $madamCashBonus = 0, $DJ = 0, $unDJ = 0, $DJRepBonus = 0, $Milkmaid = 0, $Farmer = 0, $Collectrix = 0, $Stewardess = 0, $Schoolteacher = 0, $Wardeness = 0, $Concubine = 0, $Attendant = 0, $Matron = 0, $Nurse = 0, $Bodyguard = 0, $fuckSlaves = 0, $freeSexualEnergy = 0, $publicServants = 0, $cumSlaves = 0, $averageDick = 0, $slavesWithWorkingDicks = 0, $slaveJobValues = {}>>
 
 /* GAMEOVERS */
 <<if $slaves.length < 1>>
diff --git a/src/uncategorized/slaveAssignmentsReport.tw b/src/uncategorized/slaveAssignmentsReport.tw
index 7b0d3451c15..252eed33363 100644
--- a/src/uncategorized/slaveAssignmentsReport.tw
+++ b/src/uncategorized/slaveAssignmentsReport.tw
@@ -21,7 +21,7 @@ i.e. a highly paternalist arcology with little choice for its lower class but Fu
 /*Low rent increases demand/available money for sexual services, high rent decreases it*/
 <<set _LCRent = 1 + (20 - $LCRent) / 100,
 _lowerClassSexDemand = Math.trunc($lowerClass * _LCRent) * 10,
-_lowerClassSexDemandRef = Math.max(_lowerClassSexDemand, 0);
+_lowerClassSexDemandRef = Math.max(_lowerClassSexDemand, 1);
 _MCRent = 1 + (50 - $MCRent) / 250,
 _middleClassSexDemand = Math.trunc($middleClass * _MCRent) * 50,
 _UCRent = 1 + (180 - $UCRent) / 900,
@@ -29,6 +29,7 @@ _upperClassSexDemand = Math.trunc($upperClass * _UCRent) * 400,
 _TCRent = 1 + (650 - $TCRent) / 3250,
 _topClassSexDemand = Math.trunc($topClass * _TCRent) * 4000,
 _visitorsSexDemand = Math.trunc($visitors) * 40,
+$whorePriceAdjustment = [0, 0, 0, 0],
 $slaveJobValues = slaveJobValues()>>
 
 /*Supply of sexual services*/
@@ -36,6 +37,7 @@ $slaveJobValues = slaveJobValues()>>
 	<br>Lower Class SD: <<print _lowerClassSexDemand>>
 	<br>Club SP: <<print Math.trunc($slaveJobValues.club * $slaveJobValues.clubSP)>>
 	<br>Arcade SP: <<print $slaveJobValues.arcade>>
+	<br>Brothel SP: <<print $slaveJobValues.brothel>>
 <</if>>
 
 /*Arcade Specific Demand for Degradationists to give it higher priority*/
@@ -95,6 +97,36 @@ _lowerClassClubRatio = _lowerClassSexDemand / _clubDemand>>
 	_visitorsSexDemand = 0>>
 <</if>>
 
+/*Brothel or street whore sex supply*/
+<<if _lowerClassSexDemand < $slaveJobValues.brothel[0]>>
+	<<set $whorePriceAdjustment[0] = Math.pow(_lowerClassSexDemand / $slaveJobValues.brothel[0], 1.5),
+	_lowerClassSexDemand = 0>> /*This accounts for people having too much choice and getting more picky how they spend their money*/
+<<else>>
+	<<set $whorePriceAdjustment[0] = Math.pow(_lowerClassSexDemand / $slaveJobValues.brothel[0], 0.5),
+	_lowerClassSexDemand -= $slaveJobValues.brothel[0]>>
+<</if>>
+<<if _middleClassSexDemand < $slaveJobValues.brothel[1]>>
+	<<set $whorePriceAdjustment[1] = Math.pow(_middleClassSexDemand / $slaveJobValues.brothel[1], 1.5),
+	_middleClassSexDemand = 0>>
+<<else>>
+	<<set $whorePriceAdjustment[1] = Math.pow(_middleClassSexDemand / $slaveJobValues.brothel[1], 0.5),
+	_middleClassSexDemand -= $slaveJobValues.brothel[1]>>
+<</if>>
+<<if _upperClassSexDemand < $slaveJobValues.brothel[2]>>
+	<<set $whorePriceAdjustment[2] = Math.pow(_upperClassSexDemand / $slaveJobValues.brothel[2], 1.5),
+	_upperClassSexDemand = 0>>
+<<else>>
+	<<set $whorePriceAdjustment[2] = Math.pow(_upperClassSexDemand / $slaveJobValues.brothel[2], 0.5),
+	_upperClassSexDemand -= $slaveJobValues.brothel[2]>>
+<</if>>
+<<if _topClassSexDemand < $slaveJobValues.brothel[3]>>
+	<<set $whorePriceAdjustment[3] = Math.pow(_topClassSexDemand / $slaveJobValues.brothel[3], 1.5),
+	_topClassSexDemand = 0>>
+<<else>>
+	<<set $whorePriceAdjustment[4] = Math.pow(_topClassSexDemand / $slaveJobValues.brothel[3], 0.5),
+	_topClassSexDemand -= $slaveJobValues.brothel[3]>>
+<</if>>
+
 /*Price for sex in the arcade or at a glory hole*/
 <<if $arcologies[0].FSPaternalist != "unset">>
 	<<set _arcadeDemand = Math.max((_arcadeDemandDeg + _lowerClassSexDemand) * (1 - $arcologies[0].FSPaternalist / 50), 0)>> /*Paternalists sap demand for the arcade*/
@@ -122,7 +154,7 @@ _lowerClassClubRatio = _lowerClassSexDemand / _clubDemand>>
 <</if>>
 
 /*NPC sex supply*/
-<<set $NPCSexSupply = NPCSexSupply(_lowerClassSexDemand/_lowerClassSexDemandRef),
+<<set $NPCSexSupply = NPCSexSupply(_lowerClassSexDemand/_lowerClassSexDemandRef, _middleClassSexDemand/_middleClassSexDemandRef, _upperClassSexDemand/_upperClassSexDemandRef, _topClassSexDemand/_topClassSexDemandRef),
 $NPCMarketShareLC = Math.trunc(($NPCSexSupply.lowerClass * 1000) / ($NPCSexSupply.lowerClass + $slaveJobValues.arcade + Math.trunc($slaveJobValues.club * $slaveJobValues.clubSP * _lowerClassClubRatio)))>>
 <<if _lowerClassSexDemand < $NPCSexSupply.lowerClass>>
 	<<set _lowerClassSexDemand = 0>>
@@ -132,11 +164,46 @@ $NPCMarketShareLC = Math.trunc(($NPCSexSupply.lowerClass * 1000) / ($NPCSexSuppl
 <<if ($cheatMode == 1) || ($debugMode == 1)>>
 	<br>NPC Supply Lower Class: $NPCSexSupply.lowerClass
 <</if>>
-
 <<if ($cheatMode == 1) || ($debugMode == 1)>>
 	<br>Leftover Lower Class SD: <<print _lowerClassSexDemand>>
 <</if>>
 
+<<if _middleClassSexDemand < $NPCSexSupply.middleClass>>
+	<<set _middleClassSexDemand = 0>>
+<<else>>
+	<<set _middleClassSexDemand -= $NPCSexSupply.middleClass>>
+<</if>>
+<<if ($cheatMode == 1) || ($debugMode == 1)>>
+	<br>NPC Supply Middle Class: $NPCSexSupply.middleClass
+<</if>>
+<<if ($cheatMode == 1) || ($debugMode == 1)>>
+	<br>Leftover Middle Class SD: <<print _middleClassSexDemand>>
+<</if>>
+
+<<if _upperClassSexDemand < $NPCSexSupply.upperClass>>
+	<<set _upperClassSexDemand = 0>>
+<<else>>
+	<<set _upperClassSexDemand -= $NPCSexSupply.upperClass>>
+<</if>>
+<<if ($cheatMode == 1) || ($debugMode == 1)>>
+	<br>NPC Supply Upper Class: $NPCSexSupply.upperClass
+<</if>>
+<<if ($cheatMode == 1) || ($debugMode == 1)>>
+	<br>Leftover Upper Class SD: <<print _upperClassSexDemand>>
+<</if>>
+
+<<if _topClassSexDemand < $NPCSexSupply.topClass>>
+	<<set _topClassSexDemand = 0>>
+<<else>>
+	<<set _topClassSexDemand -= $NPCSexSupply.topClass>>
+<</if>>
+<<if ($cheatMode == 1) || ($debugMode == 1)>>
+	<br>NPC Supply Top Class: $NPCSexSupply.topClass
+<</if>>
+<<if ($cheatMode == 1) || ($debugMode == 1)>>
+	<br>Leftover Top Class SD: <<print _topClassSexDemand>>
+<</if>>
+
 /*Sexual satisfaction effects*/
 <<if _lowerClassSexDemand > $lowerClass * _LCRent * 3>> /*You are providing < 40% of their desired amount of sex*/
 	<<set $lowerClassSexDemandResult = 1>>
@@ -168,6 +235,99 @@ $NPCMarketShareLC = Math.trunc(($NPCSexSupply.lowerClass * 1000) / ($NPCSexSuppl
 	<<set $lowerClassSexDemandResult = 4,
 	$lowerClassSatisfied = 1>>
 <</if>>
+
+<<if _middleClassSexDemand > $middleClass * _MCRent * 3>> /*You are providing < 40% of their desired amount of sex*/
+	<<set $middleClassSexDemandResult = 1>>
+	<<if $week <= 30>>
+		<<set $middleClassSatisfied = 0>>
+	<<else>>
+		<<set $middleClassSatisfied = -1>>
+	<</if>>
+<<elseif _middleClassSexDemand > $middleClass * _MCRent * 2>> /*You are providing between 40 and 60% of their desired amount of sex*/
+	<<set $middleClassSexDemandResult = 2>>
+	<<if $week <= 40>>
+		<<set $middleClassSatisfied = 1>>
+	<<elseif $week <= 60>>
+		<<set $middleClassSatisfied = 0>>
+	<<else>>
+		<<set $middleClassSatisfied = -1>>
+	<</if>>
+<<elseif _middleClassSexDemand > $middleClass * _MCRent>> /*You are providing between 60 and 80% of their desired amount of sex*/
+	<<set $middleClassSexDemandResult = 3>>
+	<<if $week <= 50>>
+		<<set $middleClassSatisfied = 1>>
+	<<else>>
+		<<set $middleClassSatisfied = 0>>
+	<</if>>
+<<elseif _middleClassSexDemand == 0>> /*You are providing 100% or more of their desired amount of sex*/
+	<<set $middleClassSexDemandResult = 5,
+	$middleClassSatisfied = 2>>
+<<else>> /*You are providing > 80% of their desired amount of sex*/
+	<<set $middleClassSexDemandResult = 4,
+	$middleClassSatisfied = 1>>
+<</if>>
+
+<<if _upperClassSexDemand > $upperClass * _UCRent * 3>> /*You are providing < 40% of their desired amount of sex*/
+	<<set $upperClassSexDemandResult = 1>>
+	<<if $week <= 30>>
+		<<set $upperClassSatisfied = 0>>
+	<<else>>
+		<<set $upperClassSatisfied = -1>>
+	<</if>>
+<<elseif _upperClassSexDemand > $upperClass * _UCRent * 2>> /*You are providing between 40 and 60% of their desired amount of sex*/
+	<<set $upperClassSexDemandResult = 2>>
+	<<if $week <= 40>>
+		<<set $upperClassSatisfied = 1>>
+	<<elseif $week <= 60>>
+		<<set $upperClassSatisfied = 0>>
+	<<else>>
+		<<set $upperClassSatisfied = -1>>
+	<</if>>
+<<elseif _upperClassSexDemand > $upperClass * _UCRent>> /*You are providing between 60 and 80% of their desired amount of sex*/
+	<<set $upperClassSexDemandResult = 3>>
+	<<if $week <= 50>>
+		<<set $upperClassSatisfied = 1>>
+	<<else>>
+		<<set $upperClassSatisfied = 0>>
+	<</if>>
+<<elseif _upperClassSexDemand == 0>> /*You are providing 100% or more of their desired amount of sex*/
+	<<set $upperClassSexDemandResult = 5,
+	$upperClassSatisfied = 2>>
+<<else>> /*You are providing > 80% of their desired amount of sex*/
+	<<set $upperClassSexDemandResult = 4,
+	$upperClassSatisfied = 1>>
+<</if>>
+
+<<if _topClassSexDemand > $topClass * _TCRent * 3>> /*You are providing < 40% of their desired amount of sex*/
+	<<set $topClassSexDemandResult = 1>>
+	<<if $week <= 30>>
+		<<set $topClassSatisfied = 0>>
+	<<else>>
+		<<set $topClassSatisfied = -1>>
+	<</if>>
+<<elseif _topClassSexDemand > $topClass * _TCRent * 2>> /*You are providing between 40 and 60% of their desired amount of sex*/
+	<<set $topClassSexDemandResult = 2>>
+	<<if $week <= 40>>
+		<<set $topClassSatisfied = 1>>
+	<<elseif $week <= 60>>
+		<<set $topClassSatisfied = 0>>
+	<<else>>
+		<<set $topClassSatisfied = -1>>
+	<</if>>
+<<elseif _topClassSexDemand > $topClass * _TCRent>> /*You are providing between 60 and 80% of their desired amount of sex*/
+	<<set $topClassSexDemandResult = 3>>
+	<<if $week <= 50>>
+		<<set $topClassSatisfied = 1>>
+	<<else>>
+		<<set $topClassSatisfied = 0>>
+	<</if>>
+<<elseif _topClassSexDemand == 0>> /*You are providing 100% or more of their desired amount of sex*/
+	<<set $topClassSexDemandResult = 5,
+	$topClassSatisfied = 2>>
+<<else>> /*You are providing > 80% of their desired amount of sex*/
+	<<set $topClassSexDemandResult = 4,
+	$topClassSatisfied = 1>>
+<</if>>
 <br><br>
 
 <<for $i = 0; $i < _SL; $i++>>
@@ -274,25 +434,18 @@ $NPCMarketShareLC = Math.trunc(($NPCSexSupply.lowerClass * 1000) / ($NPCSexSuppl
 		<<= removeJob($slaves[$i], "recruit girls")>>
 	<</if>>
 <<case "be the Madam">>
-	<<set $Madam = $slaves[$i]>>
-	<<if !canTalk($Madam)>>
+	<<if $unMadam == 1>>
 		''__@@.pink;$Madam.slaveName@@__'' can't give whores verbal orders @@.yellow;and cannot serve as your Madam any more.@@<br>
-		<<set $Madam = 0>>
-	<<elseif $Madam.preg > 37 && $Madam.broodmother == 2>>
+	<<elseif $unMadam == 2>>
 		''__@@.pink;$Madam.slaveName@@__'' spends so much time giving birth and laboring that @@.yellow;$he cannot effectively serve as your Madam any longer.@@
-		<<set $Madam = 0>>
-	<<elseif $Madam.fetish == "mindbroken">>
+	<<elseif $unMadam == 3>>
 		''__@@.pink;$Madam.slaveName@@__'' is mindbroken @@.yellow;and cannot serve as your Madam any more.@@<br>
-		<<set $Madam = 0>>
-	<<elseif !canWalk($Madam)>>
+	<<elseif $unMadam == 4>>
 		''__@@.pink;$Madam.slaveName@@__'' is no longer independently mobile @@.yellow;and cannot serve as your Madam any more.@@<br>
-		<<set $Madam = 0>>
-	<<elseif !canSee($Madam)>>
+	<<elseif $unMadam == 5>>
 		''__@@.pink;$Madam.slaveName@@__'' can no longer see @@.yellow;and cannot serve as your Madam any more.@@<br>
-		<<set $Madam = 0>>
-	<<elseif !canHear($Madam)>>
+	<<elseif $unMadam == 6>>
 		''__@@.pink;$Madam.slaveName@@__'' can no longer hear @@.yellow;and cannot serve as your Madam any more.@@<br>
-		<<set $Madam = 0>>
 	<</if>>
 	<<if $Madam == 0>>
 		<<= removeJob($slaves[$i], "be the Madam")>>
-- 
GitLab