diff --git a/src/Corporation/Actions.ts b/src/Corporation/Actions.ts index 081447d9d..498157744 100644 --- a/src/Corporation/Actions.ts +++ b/src/Corporation/Actions.ts @@ -174,8 +174,8 @@ export function SellProduct(product: Product, city: string, amt: string, price: //Dynamically evaluated quantity. First test to make sure its valid let qty = amt.replace(/\s+/g, ""); qty = qty.replace(/[^-()\d/*+.MAXPROD]/g, ""); - let temp = qty.replace(/MAX/g, "1"); - temp = temp.replace(/PROD/g, "1"); + let temp = qty.replace(/MAX/g, product.maxsll.toString()); + temp = temp.replace(/PROD/g, product.data[city][1].toString()); try { temp = eval(temp); } catch (e) { diff --git a/src/Corporation/Industry.ts b/src/Corporation/Industry.ts index 6cfd4ffbb..0405755ef 100644 --- a/src/Corporation/Industry.ts +++ b/src/Corporation/Industry.ts @@ -1188,8 +1188,7 @@ export class Industry implements IIndustry { } } - const maxSell = - 0.5 * + product.maxsll = 0.5 * Math.pow(product.rat, 0.65) * marketFactor * corporation.getSalesMultiplier() * @@ -1200,7 +1199,7 @@ export class Industry implements IIndustry { let sellAmt; if (product.sllman[city][0] && isString(product.sllman[city][1])) { //Sell amount is dynamically evaluated - let tmp = product.sllman[city][1].replace(/MAX/g, (maxSell + "").toUpperCase()); + let tmp = product.sllman[city][1].replace(/MAX/g, (product.maxsll + "").toUpperCase()); tmp = tmp.replace(/PROD/g, product.data[city][1]); try { tmp = eval(tmp); @@ -1214,16 +1213,16 @@ export class Industry implements IIndustry { city + " office. Sell price is being set to MAX", ); - tmp = maxSell; + tmp = product.maxsll; } - sellAmt = Math.min(maxSell, tmp); + sellAmt = Math.min(product.maxsll, tmp); } else if (product.sllman[city][0] && product.sllman[city][1] > 0) { //Sell amount is manually limited - sellAmt = Math.min(maxSell, product.sllman[city][1]); + sellAmt = Math.min(product.maxsll, product.sllman[city][1]); } else if (product.sllman[city][0] === false) { sellAmt = 0; } else { - sellAmt = maxSell; + sellAmt = product.maxsll; } if (sellAmt < 0) { sellAmt = 0; diff --git a/src/Corporation/Product.ts b/src/Corporation/Product.ts index 652f9a3e8..bca8e6468 100644 --- a/src/Corporation/Product.ts +++ b/src/Corporation/Product.ts @@ -96,6 +96,8 @@ export class Product { marketTa2 = false; marketTa2Price: IMap = createCityMap(0); + // Determines the maximum amount of this product that can be sold in one market cycle + maxsll = 0 constructor(params: IConstructorParams = {}) { this.name = params.name ? params.name : ""; this.dmd = params.demand ? params.demand : 0;