mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-01-03 20:07:34 +01:00
Merge pull request #2757 from ltoni90/bugfix/2719_Corporation_Expressions
Bug fix corporation expressions
This commit is contained in:
commit
d955398a68
@ -114,8 +114,8 @@ export function SellMaterial(mat: Material, amt: string, price: string): void {
|
|||||||
if (amt.includes("MAX") || amt.includes("PROD")) {
|
if (amt.includes("MAX") || amt.includes("PROD")) {
|
||||||
let q = amt.replace(/\s+/g, "");
|
let q = amt.replace(/\s+/g, "");
|
||||||
q = q.replace(/[^-()\d/*+.MAXPROD]/g, "");
|
q = q.replace(/[^-()\d/*+.MAXPROD]/g, "");
|
||||||
let tempQty = q.replace(/MAX/g, "1");
|
let tempQty = q.replace(/MAX/g, mat.maxsll.toString());
|
||||||
tempQty = tempQty.replace(/PROD/g, "1");
|
tempQty = tempQty.replace(/PROD/g, mat.prd.toString());
|
||||||
try {
|
try {
|
||||||
tempQty = eval(tempQty);
|
tempQty = eval(tempQty);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -179,8 +179,8 @@ export function SellProduct(product: Product, city: string, amt: string, price:
|
|||||||
//Dynamically evaluated quantity. First test to make sure its valid
|
//Dynamically evaluated quantity. First test to make sure its valid
|
||||||
let qty = amt.replace(/\s+/g, "");
|
let qty = amt.replace(/\s+/g, "");
|
||||||
qty = qty.replace(/[^-()\d/*+.MAXPROD]/g, "");
|
qty = qty.replace(/[^-()\d/*+.MAXPROD]/g, "");
|
||||||
let temp = qty.replace(/MAX/g, "1");
|
let temp = qty.replace(/MAX/g, product.maxsll.toString());
|
||||||
temp = temp.replace(/PROD/g, "1");
|
temp = temp.replace(/PROD/g, product.data[city][1].toString());
|
||||||
try {
|
try {
|
||||||
temp = eval(temp);
|
temp = eval(temp);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -828,7 +828,7 @@ export class Industry implements IIndustry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxSell =
|
mat.maxsll =
|
||||||
(mat.qlt + 0.001) *
|
(mat.qlt + 0.001) *
|
||||||
marketFactor *
|
marketFactor *
|
||||||
markup *
|
markup *
|
||||||
@ -839,7 +839,7 @@ export class Industry implements IIndustry {
|
|||||||
let sellAmt;
|
let sellAmt;
|
||||||
if (isString(mat.sllman[1])) {
|
if (isString(mat.sllman[1])) {
|
||||||
//Dynamically evaluated
|
//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 + "");
|
tmp = tmp.replace(/PROD/g, mat.prd + "");
|
||||||
try {
|
try {
|
||||||
sellAmt = eval(tmp);
|
sellAmt = eval(tmp);
|
||||||
@ -856,13 +856,13 @@ export class Industry implements IIndustry {
|
|||||||
);
|
);
|
||||||
sellAmt = 0;
|
sellAmt = 0;
|
||||||
}
|
}
|
||||||
sellAmt = Math.min(maxSell, sellAmt);
|
sellAmt = Math.min(mat.maxsll, sellAmt);
|
||||||
} else if (mat.sllman[1] === -1) {
|
} else if (mat.sllman[1] === -1) {
|
||||||
//Backwards compatibility, -1 = MAX
|
//Backwards compatibility, -1 = MAX
|
||||||
sellAmt = maxSell;
|
sellAmt = mat.maxsll;
|
||||||
} else {
|
} else {
|
||||||
//Player's input value is just a number
|
//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;
|
sellAmt = sellAmt * CorporationConstants.SecsPerMarketCycle * marketCycles;
|
||||||
@ -1188,8 +1188,7 @@ export class Industry implements IIndustry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxSell =
|
product.maxsll = 0.5 *
|
||||||
0.5 *
|
|
||||||
Math.pow(product.rat, 0.65) *
|
Math.pow(product.rat, 0.65) *
|
||||||
marketFactor *
|
marketFactor *
|
||||||
corporation.getSalesMultiplier() *
|
corporation.getSalesMultiplier() *
|
||||||
@ -1200,7 +1199,7 @@ export class Industry implements IIndustry {
|
|||||||
let sellAmt;
|
let sellAmt;
|
||||||
if (product.sllman[city][0] && isString(product.sllman[city][1])) {
|
if (product.sllman[city][0] && isString(product.sllman[city][1])) {
|
||||||
//Sell amount is dynamically evaluated
|
//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]);
|
tmp = tmp.replace(/PROD/g, product.data[city][1]);
|
||||||
try {
|
try {
|
||||||
tmp = eval(tmp);
|
tmp = eval(tmp);
|
||||||
@ -1214,16 +1213,16 @@ export class Industry implements IIndustry {
|
|||||||
city +
|
city +
|
||||||
" office. Sell price is being set to MAX",
|
" 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) {
|
} else if (product.sllman[city][0] && product.sllman[city][1] > 0) {
|
||||||
//Sell amount is manually limited
|
//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) {
|
} else if (product.sllman[city][0] === false) {
|
||||||
sellAmt = 0;
|
sellAmt = 0;
|
||||||
} else {
|
} else {
|
||||||
sellAmt = maxSell;
|
sellAmt = product.maxsll;
|
||||||
}
|
}
|
||||||
if (sellAmt < 0) {
|
if (sellAmt < 0) {
|
||||||
sellAmt = 0;
|
sellAmt = 0;
|
||||||
|
@ -62,6 +62,9 @@ export class Material {
|
|||||||
marketTa2 = false;
|
marketTa2 = false;
|
||||||
marketTa2Price = 0;
|
marketTa2Price = 0;
|
||||||
|
|
||||||
|
// Determines the maximum amount of this material that can be sold in one market cycle
|
||||||
|
maxsll = 0;
|
||||||
|
|
||||||
constructor(params: IConstructorParams = {}) {
|
constructor(params: IConstructorParams = {}) {
|
||||||
if (params.name) {
|
if (params.name) {
|
||||||
this.name = params.name;
|
this.name = params.name;
|
||||||
|
@ -96,6 +96,8 @@ export class Product {
|
|||||||
marketTa2 = false;
|
marketTa2 = false;
|
||||||
marketTa2Price: IMap<number> = createCityMap<number>(0);
|
marketTa2Price: IMap<number> = createCityMap<number>(0);
|
||||||
|
|
||||||
|
// Determines the maximum amount of this product that can be sold in one market cycle
|
||||||
|
maxsll = 0;
|
||||||
constructor(params: IConstructorParams = {}) {
|
constructor(params: IConstructorParams = {}) {
|
||||||
this.name = params.name ? params.name : "";
|
this.name = params.name ? params.name : "";
|
||||||
this.dmd = params.demand ? params.demand : 0;
|
this.dmd = params.demand ? params.demand : 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user