mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-20 05:05:47 +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,
|
||||
marketingInvest: number,
|
||||
): void {
|
||||
if (designInvest < 0) {
|
||||
designInvest = 0;
|
||||
}
|
||||
if (marketingInvest < 0) {
|
||||
marketingInvest = 0;
|
||||
// For invalid investment inputs, just use 0
|
||||
if (isNaN(designInvest) || designInvest < 0) designInvest = 0;
|
||||
if (isNaN(marketingInvest) || 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 === "") {
|
||||
throw new Error("You must specify a name for your product!");
|
||||
@ -398,12 +399,6 @@ export function MakeProduct(
|
||||
if (!division.makesProducts) {
|
||||
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) {
|
||||
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({
|
||||
name: productName.replace(/[<>]/g, "").trim(), //Sanitize for HTMl elements
|
||||
name: productName.replace(/[<>]/g, "").trim(), //Sanitize for HTMl elements?
|
||||
createCity: city,
|
||||
designInvestment: designInvest,
|
||||
advertisingInvestment: marketingInvest,
|
||||
|
@ -713,8 +713,10 @@ export class Division {
|
||||
if (this.state !== "PRODUCTION") continue;
|
||||
const city = product.creationCity;
|
||||
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);
|
||||
if (product.developmentProgress >= 100) {
|
||||
product.finishProduct(this);
|
||||
|
Loading…
Reference in New Issue
Block a user