CORPORATION: Fix wrong product price calculation (#1451)

This commit is contained in:
catloversg 2024-07-03 05:11:32 +07:00 committed by GitHub
parent 960fe5aa8b
commit 3c29757827
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -574,8 +574,7 @@ export class Division {
sCost = optimalPrice; sCost = optimalPrice;
} else if (mat.marketTa1) { } else if (mat.marketTa1) {
sCost = mat.marketPrice + markupLimit; sCost = mat.marketPrice + markupLimit;
// check truthyness to avoid unnecessary eval } else if (typeof mat.desiredSellPrice === "string") {
} else if (typeof mat.desiredSellPrice === "string" && mat.desiredSellPrice) {
sCost = mat.desiredSellPrice.replace(/MP/g, mat.marketPrice.toString()); sCost = mat.desiredSellPrice.replace(/MP/g, mat.marketPrice.toString());
sCost = eval(sCost); sCost = eval(sCost);
} else { } else {
@ -903,7 +902,7 @@ export class Division {
product.markup = 1; product.markup = 1;
} }
sCostString = sCostString.replace(/MP/g, product.cityData[city].productionCost.toString()); sCostString = sCostString.replace(/MP/g, product.cityData[city].productionCost.toString());
sCost = Math.max(product.cityData[city].productionCost, eval(sCostString)); sCost = eval(sCostString);
} else { } else {
sCost = sellPrice; sCost = sellPrice;
} }