mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-11 02:03:58 +01:00
fixed temporary evaluation of MAX and PROD
This commit is contained in:
parent
07fe3c1906
commit
bfa271881b
@ -109,8 +109,8 @@ export function SellMaterial(mat: Material, amt: string, price: string): void {
|
||||
if (amt.includes("MAX") || amt.includes("PROD")) {
|
||||
let q = amt.replace(/\s+/g, "");
|
||||
q = q.replace(/[^-()\d/*+.MAXPROD]/g, "");
|
||||
let tempQty = q.replace(/MAX/g, "1");
|
||||
tempQty = tempQty.replace(/PROD/g, "1");
|
||||
let tempQty = q.replace(/MAX/g, mat.maxsll.toString());
|
||||
tempQty = tempQty.replace(/PROD/g, mat.prd.toString());
|
||||
try {
|
||||
tempQty = eval(tempQty);
|
||||
} catch (e) {
|
||||
|
@ -828,7 +828,7 @@ export class Industry implements IIndustry {
|
||||
}
|
||||
}
|
||||
|
||||
const maxSell =
|
||||
mat.maxsll =
|
||||
(mat.qlt + 0.001) *
|
||||
marketFactor *
|
||||
markup *
|
||||
@ -839,7 +839,7 @@ export class Industry implements IIndustry {
|
||||
let sellAmt;
|
||||
if (isString(mat.sllman[1])) {
|
||||
//Dynamically evaluated
|
||||
let tmp = (mat.sllman[1] as string).replace(/MAX/g, (maxSell + "").toUpperCase());
|
||||
let tmp = (mat.sllman[1] as string).replace(/MAX/g, (mat.maxsll + "").toUpperCase());
|
||||
tmp = tmp.replace(/PROD/g, mat.prd + "");
|
||||
try {
|
||||
sellAmt = eval(tmp);
|
||||
@ -856,13 +856,13 @@ export class Industry implements IIndustry {
|
||||
);
|
||||
sellAmt = 0;
|
||||
}
|
||||
sellAmt = Math.min(maxSell, sellAmt);
|
||||
sellAmt = Math.min(mat.maxsll, sellAmt);
|
||||
} else if (mat.sllman[1] === -1) {
|
||||
//Backwards compatibility, -1 = MAX
|
||||
sellAmt = maxSell;
|
||||
sellAmt = mat.maxsll;
|
||||
} else {
|
||||
//Player's input value is just a number
|
||||
sellAmt = Math.min(maxSell, mat.sllman[1] as number);
|
||||
sellAmt = Math.min(mat.maxsll, mat.sllman[1] as number);
|
||||
}
|
||||
|
||||
sellAmt = sellAmt * CorporationConstants.SecsPerMarketCycle * marketCycles;
|
||||
|
@ -62,6 +62,9 @@ export class Material {
|
||||
marketTa2 = false;
|
||||
marketTa2Price = 0;
|
||||
|
||||
// Determines the maximum amount of this material that can be sold in one market cycle
|
||||
maxsll = 0;
|
||||
|
||||
constructor(params: IConstructorParams = {}) {
|
||||
if (params.name) {
|
||||
this.name = params.name;
|
||||
|
Loading…
Reference in New Issue
Block a user