CORP: Products sell all at price of 0 (#1330)

Match material behaviour - price of 0 discards stored products
This commit is contained in:
gmcew 2024-06-03 02:01:03 +01:00 committed by GitHub
parent a28bb4bd99
commit 1f08724fea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -925,6 +925,8 @@ export class Division {
if (sCost - product.cityData[city].productionCost > markupLimit) { if (sCost - product.cityData[city].productionCost > markupLimit) {
markup = markupLimit / (sCost - product.cityData[city].productionCost); markup = markupLimit / (sCost - product.cityData[city].productionCost);
} }
} else if (sCost <= 0) {
markup = 1e12; //Sell everything, essentially discard - as materials
} }
product.maxSellAmount = product.maxSellAmount =
@ -939,7 +941,7 @@ export class Division {
sellAmt = Math.min(product.maxSellAmount, sellAmt); sellAmt = Math.min(product.maxSellAmount, sellAmt);
sellAmt = sellAmt * corpConstants.secondsPerMarketCycle * marketCycles; sellAmt = sellAmt * corpConstants.secondsPerMarketCycle * marketCycles;
sellAmt = Math.min(product.cityData[city].stored, sellAmt); //data[0] is qty sellAmt = Math.min(product.cityData[city].stored, sellAmt); //data[0] is qty
if (sellAmt && sCost) { if (sellAmt && sCost >= 0) {
product.cityData[city].stored -= sellAmt; //data[0] is qty product.cityData[city].stored -= sellAmt; //data[0] is qty
totalProfit += sellAmt * sCost; totalProfit += sellAmt * sCost;
product.cityData[city].actualSellAmount = sellAmt / (corpConstants.secondsPerMarketCycle * marketCycles); //data[2] is sell property product.cityData[city].actualSellAmount = sellAmt / (corpConstants.secondsPerMarketCycle * marketCycles); //data[2] is sell property