From 98d02883b450dabbb003400bd8964c38351277f5 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Tue, 16 Mar 2021 22:33:34 -0400
Subject: [PATCH] fix bulkslave purchase displaying cost as 0

---
 src/markets/bulkSlave/bulkSlaveIntro.js | 7 +++----
 src/markets/marketUI.js                 | 5 +++++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/markets/bulkSlave/bulkSlaveIntro.js b/src/markets/bulkSlave/bulkSlaveIntro.js
index 8d51643695a..3409530dfde 100644
--- a/src/markets/bulkSlave/bulkSlaveIntro.js
+++ b/src/markets/bulkSlave/bulkSlaveIntro.js
@@ -4,7 +4,6 @@ App.Markets.bulkSlaveIntro = function() {
 	const discount = getDiscount();
 	let seed;
 	let p;
-	let spent = 0;
 
 	if (V.market.newSlaves.length === 0) {
 		bulkSlaveGenerate();
@@ -46,7 +45,7 @@ App.Markets.bulkSlaveIntro = function() {
 			} else {
 				r.push(`With all your discounts factored in you got a <span class="yellowgreen">${(500 - discount) / 5}%</span> discount;`);
 			}
-			r.push(`You spent <span class="yellowgreen">${cashFormat(spent)}</span> on your new slaves.`);
+			r.push(`You spent`, App.UI.DOM.cashFormat(V.market.totalCost), `on your new slaves.`);
 			break;
 		case "inStock":
 			r.push(`You clear out ${App.Markets.marketName(V.market.slaveMarket, V.market.numArcology)} of its stock of ${V.market.newSlaves.length} slaves.`);
@@ -57,7 +56,7 @@ App.Markets.bulkSlaveIntro = function() {
 			} else {
 				r.push(`With all your discounts factored in you got a <span class="yellowgreen">${(500 - discount) / 5}%</span> discount`);
 			}
-			r.push(`You spent <span class="yellowgreen">${cashFormat(spent)}</span> on your new slaves.`);
+			r.push(`You spent`, App.UI.DOM.cashFormat(V.market.totalCost), `on your new slaves.`);
 			break;
 		case "liquidator":
 			r.push(`Your new pair of slaves look frightened and uncertain, but seem encouraged by each other's presence.`);
@@ -160,7 +159,7 @@ App.Markets.bulkSlaveIntro = function() {
 			} else {
 				cashX(forceNeg(_slaveCost), "slaveTransfer", slave);
 				V.market.newSlaves.push(slave);
-				spent += _slaveCost;
+				V.market.totalCost += _slaveCost;
 			}
 		}
 
diff --git a/src/markets/marketUI.js b/src/markets/marketUI.js
index f3c0b1a7e1a..62a8a55c971 100644
--- a/src/markets/marketUI.js
+++ b/src/markets/marketUI.js
@@ -81,6 +81,7 @@ App.Markets.purchaseFramework = function(slaveMarket, {sTitleSingular = "slave",
 					title.buyAndKeepShopping,
 					() => {
 						cashX(forceNeg(cost), "slaveTransfer", slave);
+						V.market.totalCost += cost;
 						V.market.newSlaves.push(slave);
 						V.market.introType = "multi";
 						student();
@@ -99,6 +100,7 @@ App.Markets.purchaseFramework = function(slaveMarket, {sTitleSingular = "slave",
 						title.buyJustHer,
 						() => {
 							cashX(forceNeg(cost), "slaveTransfer", slave);
+							V.market.totalCost += cost;
 							V.market.newSlaves.push(slave);
 							V.nextButton = "Continue";
 							V.returnTo = "Main";
@@ -116,6 +118,7 @@ App.Markets.purchaseFramework = function(slaveMarket, {sTitleSingular = "slave",
 						() => {
 							student();
 							cashX(forceNeg(cost), "slaveTransfer", slave);
+							V.market.totalCost += cost;
 							V.market.newSlaves.push(slave);
 						},
 						[],
@@ -157,6 +160,7 @@ App.Markets.purchaseFramework = function(slaveMarket, {sTitleSingular = "slave",
  * @property {number} newSlavesDone
  * @property {number} numSlaves
  * @property {number} numArcology
+ * @property {number} totalCost
  */
 
 /** @this {marketGlobal} */
@@ -169,6 +173,7 @@ App.Markets.GlobalVariable = function() {
 	this.newSlavesDone = 0;
 	this.numSlaves = 0;
 	this.numArcology = 0;
+	this.totalCost = 0;
 	return this;
 };
 
-- 
GitLab