mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 03:23:48 +01:00
added the ability to mass upgrade warehouse
This commit is contained in:
parent
e5bb695f6f
commit
b73570e2f7
@ -348,10 +348,17 @@ export function PurchaseWarehouse(corp: ICorporation, division: IIndustry, city:
|
|||||||
corp.funds = corp.funds - CorporationConstants.WarehouseInitialCost;
|
corp.funds = corp.funds - CorporationConstants.WarehouseInitialCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UpgradeWarehouse(corp: ICorporation, division: IIndustry, warehouse: Warehouse): void {
|
export function UpgradeWarehouseCost(warehouse: Warehouse, amt: number): number {
|
||||||
const sizeUpgradeCost = CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
|
return Array.from(Array(amt).keys()).reduce(
|
||||||
|
(acc, index) => acc + CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1 + index),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UpgradeWarehouse(corp: ICorporation, division: IIndustry, warehouse: Warehouse, amt = 1): void {
|
||||||
|
const sizeUpgradeCost = UpgradeWarehouseCost(warehouse, amt);
|
||||||
if (corp.funds < sizeUpgradeCost) return;
|
if (corp.funds < sizeUpgradeCost) return;
|
||||||
++warehouse.level;
|
warehouse.level += amt;
|
||||||
warehouse.updateSize(corp, division);
|
warehouse.updateSize(corp, division);
|
||||||
corp.funds = corp.funds - sizeUpgradeCost;
|
corp.funds = corp.funds - sizeUpgradeCost;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ import {
|
|||||||
SetSmartSupplyUseLeftovers,
|
SetSmartSupplyUseLeftovers,
|
||||||
LimitMaterialProduction,
|
LimitMaterialProduction,
|
||||||
LimitProductProduction,
|
LimitProductProduction,
|
||||||
|
UpgradeWarehouseCost,
|
||||||
} from "../Corporation/Actions";
|
} from "../Corporation/Actions";
|
||||||
import { CorporationUnlockUpgrades } from "../Corporation/data/CorporationUnlockUpgrades";
|
import { CorporationUnlockUpgrades } from "../Corporation/data/CorporationUnlockUpgrades";
|
||||||
import { CorporationUpgrades } from "../Corporation/data/CorporationUpgrades";
|
import { CorporationUpgrades } from "../Corporation/data/CorporationUpgrades";
|
||||||
@ -316,12 +317,13 @@ export function NetscriptCorporation(
|
|||||||
checkAccess("getPurchaseWarehouseCost", 7);
|
checkAccess("getPurchaseWarehouseCost", 7);
|
||||||
return CorporationConstants.WarehouseInitialCost;
|
return CorporationConstants.WarehouseInitialCost;
|
||||||
},
|
},
|
||||||
getUpgradeWarehouseCost: function (_divisionName: unknown, _cityName: unknown): number {
|
getUpgradeWarehouseCost: function (_divisionName: unknown, _cityName: unknown, _amt: unknown = 1): number {
|
||||||
checkAccess("upgradeWarehouse", 7);
|
checkAccess("upgradeWarehouse", 7);
|
||||||
const divisionName = helper.string("getUpgradeWarehouseCost", "divisionName", _divisionName);
|
const divisionName = helper.string("getUpgradeWarehouseCost", "divisionName", _divisionName);
|
||||||
const cityName = helper.city("getUpgradeWarehouseCost", "cityName", _cityName);
|
const cityName = helper.city("getUpgradeWarehouseCost", "cityName", _cityName);
|
||||||
|
const amt = helper.number("getUpgradeWarehouseCost", "amount", _amt);
|
||||||
const warehouse = getWarehouse(divisionName, cityName);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
return CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
|
return UpgradeWarehouseCost(warehouse, amt);
|
||||||
},
|
},
|
||||||
hasWarehouse: function (_divisionName: unknown, _cityName: unknown): boolean {
|
hasWarehouse: function (_divisionName: unknown, _cityName: unknown): boolean {
|
||||||
checkAccess("hasWarehouse", 7);
|
checkAccess("hasWarehouse", 7);
|
||||||
@ -382,12 +384,13 @@ export function NetscriptCorporation(
|
|||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
|
PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
|
||||||
},
|
},
|
||||||
upgradeWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
upgradeWarehouse: function (_divisionName: unknown, _cityName: unknown, _amt: unknown): void {
|
||||||
checkAccess("upgradeWarehouse", 7);
|
checkAccess("upgradeWarehouse", 7);
|
||||||
const divisionName = helper.string("upgradeWarehouse", "divisionName", _divisionName);
|
const divisionName = helper.string("upgradeWarehouse", "divisionName", _divisionName);
|
||||||
const cityName = helper.city("upgradeWarehouse", "cityName", _cityName);
|
const cityName = helper.city("upgradeWarehouse", "cityName", _cityName);
|
||||||
|
const amt = helper.number("upgradeWarehouse", "amount", _amt);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName));
|
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName), amt);
|
||||||
},
|
},
|
||||||
sellMaterial: function (
|
sellMaterial: function (
|
||||||
_divisionName: unknown,
|
_divisionName: unknown,
|
||||||
|
8
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
8
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -6639,8 +6639,9 @@ export interface WarehouseAPI {
|
|||||||
* Upgrade warehouse
|
* Upgrade warehouse
|
||||||
* @param divisionName - Name of the division
|
* @param divisionName - Name of the division
|
||||||
* @param cityName - Name of the city
|
* @param cityName - Name of the city
|
||||||
|
* @param amt - amount of upgrades defaults to 1
|
||||||
*/
|
*/
|
||||||
upgradeWarehouse(divisionName: string, cityName: string): void;
|
upgradeWarehouse(divisionName: string, cityName: string, amt: number): void;
|
||||||
/**
|
/**
|
||||||
* Create a new product
|
* Create a new product
|
||||||
* @param divisionName - Name of the division
|
* @param divisionName - Name of the division
|
||||||
@ -6679,9 +6680,12 @@ export interface WarehouseAPI {
|
|||||||
getPurchaseWarehouseCost(): number;
|
getPurchaseWarehouseCost(): number;
|
||||||
/**
|
/**
|
||||||
* Gets the cost to upgrade a warehouse to the next level
|
* Gets the cost to upgrade a warehouse to the next level
|
||||||
|
* @param divisionName - Name of the division
|
||||||
|
* @param cityName - Name of the city
|
||||||
|
* @param amt - amount of upgrades defaults to 1
|
||||||
* @returns cost to upgrade
|
* @returns cost to upgrade
|
||||||
*/
|
*/
|
||||||
getUpgradeWarehouseCost(adivisionName: any, acityName: any): number;
|
getUpgradeWarehouseCost(adivisionName: any, acityName: any, amt: number): number;
|
||||||
/**
|
/**
|
||||||
* Check if you have a warehouse in city
|
* Check if you have a warehouse in city
|
||||||
* @returns true if warehouse is present, false if not
|
* @returns true if warehouse is present, false if not
|
||||||
|
Loading…
Reference in New Issue
Block a user