mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-24 15:12:27 +01:00
CORP: Validate city with office for product development (#579)
This commit is contained in:
parent
cbff2a420b
commit
c67f32cdc1
@ -386,11 +386,12 @@ export function MakeProduct(
|
|||||||
designInvest: number,
|
designInvest: number,
|
||||||
marketingInvest: number,
|
marketingInvest: number,
|
||||||
): void {
|
): void {
|
||||||
if (designInvest < 0) {
|
// For invalid investment inputs, just use 0
|
||||||
designInvest = 0;
|
if (isNaN(designInvest) || designInvest < 0) designInvest = 0;
|
||||||
}
|
if (isNaN(marketingInvest) || marketingInvest < 0) marketingInvest = 0;
|
||||||
if (marketingInvest < 0) {
|
|
||||||
marketingInvest = 0;
|
if (!division.offices[city]) {
|
||||||
|
throw new Error(`Cannot develop a product in a city without an office!`);
|
||||||
}
|
}
|
||||||
if (productName == null || productName === "") {
|
if (productName == null || productName === "") {
|
||||||
throw new Error("You must specify a name for your product!");
|
throw new Error("You must specify a name for your product!");
|
||||||
@ -398,12 +399,6 @@ export function MakeProduct(
|
|||||||
if (!division.makesProducts) {
|
if (!division.makesProducts) {
|
||||||
throw new Error("You cannot create products for this industry!");
|
throw new Error("You cannot create products for this industry!");
|
||||||
}
|
}
|
||||||
if (isNaN(designInvest)) {
|
|
||||||
throw new Error("Invalid value for design investment");
|
|
||||||
}
|
|
||||||
if (isNaN(marketingInvest)) {
|
|
||||||
throw new Error("Invalid value for marketing investment");
|
|
||||||
}
|
|
||||||
if (corp.funds < designInvest + marketingInvest) {
|
if (corp.funds < designInvest + marketingInvest) {
|
||||||
throw new Error("You don't have enough company funds to make this large of an investment");
|
throw new Error("You don't have enough company funds to make this large of an investment");
|
||||||
}
|
}
|
||||||
@ -412,7 +407,7 @@ export function MakeProduct(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const product = new Product({
|
const product = new Product({
|
||||||
name: productName.replace(/[<>]/g, "").trim(), //Sanitize for HTMl elements
|
name: productName.replace(/[<>]/g, "").trim(), //Sanitize for HTMl elements?
|
||||||
createCity: city,
|
createCity: city,
|
||||||
designInvestment: designInvest,
|
designInvestment: designInvest,
|
||||||
advertisingInvestment: marketingInvest,
|
advertisingInvestment: marketingInvest,
|
||||||
|
@ -713,8 +713,10 @@ export class Division {
|
|||||||
if (this.state !== "PRODUCTION") continue;
|
if (this.state !== "PRODUCTION") continue;
|
||||||
const city = product.creationCity;
|
const city = product.creationCity;
|
||||||
const office = this.offices[city];
|
const office = this.offices[city];
|
||||||
if (!office) throw new Error(`Product ${name} being created in a city without an office. This is a bug.`);
|
if (!office) {
|
||||||
|
console.error(`Product ${name} being created in a city without an office. This is a bug.`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
product.createProduct(marketCycles, office.employeeProductionByJob);
|
product.createProduct(marketCycles, office.employeeProductionByJob);
|
||||||
if (product.developmentProgress >= 100) {
|
if (product.developmentProgress >= 100) {
|
||||||
product.finishProduct(this);
|
product.finishProduct(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user