diff --git a/src/Corporation/Actions.ts b/src/Corporation/Actions.ts index a29bebd40..bf13b6d33 100644 --- a/src/Corporation/Actions.ts +++ b/src/Corporation/Actions.ts @@ -1,5 +1,5 @@ import { Player } from "@player"; -import { MaterialSizes } from "./MaterialSizes"; +import { MaterialInfo } from "./MaterialInfo"; import { Corporation } from "./Corporation"; import { IndustryResearchTrees, IndustryType, IndustriesData } from "./IndustryData"; import { Industry } from "./Industry"; @@ -254,7 +254,7 @@ export function BuyMaterial(material: Material, amt: number): void { } export function BulkPurchase(corp: Corporation, warehouse: Warehouse, material: Material, amt: number): void { - const matSize = MaterialSizes[material.name]; + const matSize = MaterialInfo[material.name][1]; const maxAmount = (warehouse.size - warehouse.sizeUsed) / matSize; if (isNaN(amt) || amt < 0) { throw new Error(`Invalid input amount`); diff --git a/src/Corporation/Industry.ts b/src/Corporation/Industry.ts index d42130add..7f8199e6f 100644 --- a/src/Corporation/Industry.ts +++ b/src/Corporation/Industry.ts @@ -10,7 +10,7 @@ import { OfficeSpace } from "./OfficeSpace"; import { Product } from "./Product"; import { dialogBoxCreate } from "../ui/React/DialogBox"; import { isString } from "../utils/helpers/isString"; -import { MaterialSizes } from "./MaterialSizes"; +import { MaterialInfo } from "./MaterialInfo"; import { Warehouse } from "./Warehouse"; import { Corporation } from "./Corporation"; @@ -324,7 +324,7 @@ export class Industry { } buyAmt = mat.buy * CorporationConstants.SecsPerMarketCycle * marketCycles; - maxAmt = Math.floor((warehouse.size - warehouse.sizeUsed) / MaterialSizes[matName]); + maxAmt = Math.floor((warehouse.size - warehouse.sizeUsed) / MaterialInfo[matName][1]); buyAmt = Math.min(buyAmt, maxAmt); if (buyAmt > 0) { @@ -346,7 +346,7 @@ export class Industry { if (reqMat === undefined) throw new Error(`reqMat "${matName}" is undefined`); mat.buy = reqMat * warehouse.smartSupplyStore; let buyAmt = mat.buy * CorporationConstants.SecsPerMarketCycle * marketCycles; - const maxAmt = Math.floor((warehouse.size - warehouse.sizeUsed) / MaterialSizes[matName]); + const maxAmt = Math.floor((warehouse.size - warehouse.sizeUsed) / MaterialInfo[matName][1]); buyAmt = Math.min(buyAmt, maxAmt); if (buyAmt > 0) smartBuy[matName] = buyAmt; } @@ -374,7 +374,7 @@ export class Industry { for (const matName of Object.keys(smartBuy)) { const buyAmt = smartBuy[matName]; if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`); - totalSize += buyAmt * MaterialSizes[matName]; + totalSize += buyAmt * MaterialInfo[matName][1]; } // Shrink to the size of available space. @@ -432,12 +432,12 @@ export class Industry { // Calculate net change in warehouse storage making the produced materials will cost let totalMatSize = 0; for (let tmp = 0; tmp < this.prodMats.length; ++tmp) { - totalMatSize += MaterialSizes[this.prodMats[tmp]]; + totalMatSize += MaterialInfo[this.prodMats[tmp]][1]; } for (const reqMatName of Object.keys(this.reqMats)) { const normQty = this.reqMats[reqMatName]; if (normQty === undefined) continue; - totalMatSize -= MaterialSizes[reqMatName] * normQty; + totalMatSize -= MaterialInfo[reqMatName][1] * normQty; } // If not enough space in warehouse, limit the amount of produced materials if (totalMatSize > 0) { @@ -684,7 +684,9 @@ export class Industry { // affect revenue so just return 0's return [0, 0]; } else { - const maxAmt = Math.floor((expWarehouse.size - expWarehouse.sizeUsed) / MaterialSizes[matName]); + const maxAmt = Math.floor( + (expWarehouse.size - expWarehouse.sizeUsed) / MaterialInfo[matName][1], + ); amt = Math.min(maxAmt, amt); } expWarehouse.materials[matName].imp += @@ -797,7 +799,7 @@ export class Industry { for (const reqMatName of Object.keys(product.reqMats)) { if (product.reqMats.hasOwnProperty(reqMatName)) { const normQty = product.reqMats[reqMatName]; - netStorageSize -= MaterialSizes[reqMatName] * normQty; + netStorageSize -= MaterialInfo[reqMatName][1] * normQty; } } diff --git a/src/Corporation/IndustryData.tsx b/src/Corporation/IndustryData.tsx index 521358b5e..b1dbaecc4 100644 --- a/src/Corporation/IndustryData.tsx +++ b/src/Corporation/IndustryData.tsx @@ -21,11 +21,21 @@ export enum IndustryType { RealEstate = "RealEstate", } +export interface IProductRatingWeight { + Aesthetics?: number; + Durability?: number; + Features?: number; + Quality?: number; + Performance?: number; + Reliability?: number; +} + type IndustryData = { startingCost: number; description: string; /** Product name for industry. Empty string for industries with no products. */ product?: { name: string; verb: string; desc: string }; + ProductRatingWeights?: IProductRatingWeight; recommendStarting: boolean; reqMats: Record; /** Real estate factor */ @@ -74,6 +84,14 @@ export const IndustriesData: Record = { startingCost: 500e9, description: "Develop and manufacture new computer hardware and networking infrastructures.", product: { name: "Product", verb: "Create", desc: "Design and manufacture a new computer hardware product!" }, + ProductRatingWeights: { + Quality: 0.15, + Performance: 0.25, + Durability: 0.25, + Reliability: 0.2, + Aesthetics: 0.05, + Features: 0.1, + }, recommendStarting: false, reFac: 0.2, sciFac: 0.62, @@ -112,6 +130,11 @@ export const IndustriesData: Record = { startingCost: 10e9, description: "Create your own restaurants all around the world.", product: { name: "Restaurant", verb: "Build", desc: "Build and manage a new restaurant!" }, + ProductRatingWeights: { + Quality: 0.7, + Durability: 0.1, + Aesthetics: 0.2, + }, recommendStarting: true, sciFac: 0.12, hwFac: 0.15, @@ -125,6 +148,13 @@ export const IndustriesData: Record = { startingCost: 750e9, description: "Create and manage hospitals.", product: { name: "Hospital", verb: "Build", desc: "Build and manage a new hospital!" }, + ProductRatingWeights: { + Quality: 0.4, + Performance: 0.1, + Durability: 0.1, + Reliability: 0.3, + Features: 0.1, + }, recommendStarting: false, reFac: 0.1, sciFac: 0.75, @@ -151,6 +181,13 @@ export const IndustriesData: Record = { startingCost: 200e9, description: "Discover, develop, and create new pharmaceutical drugs.", product: { name: "Drug", verb: "Develop", desc: "Design and develop a new pharmaceutical drug!" }, + ProductRatingWeights: { + Quality: 0.2, + Performance: 0.2, + Durability: 0.1, + Reliability: 0.3, + Features: 0.2, + }, recommendStarting: false, reFac: 0.05, sciFac: 0.8, @@ -165,6 +202,13 @@ export const IndustriesData: Record = { startingCost: 600e9, description: "Develop and manage real estate properties.", product: { name: "Property", verb: "Develop", desc: "Develop a new piece of real estate property!" }, + ProductRatingWeights: { + Quality: 0.2, + Durability: 0.25, + Reliability: 0.1, + Aesthetics: 0.35, + Features: 0.1, + }, recommendStarting: false, robFac: 0.6, aiFac: 0.6, @@ -172,12 +216,20 @@ export const IndustriesData: Record = { sciFac: 0.05, hwFac: 0.05, reqMats: { Metal: 5, Energy: 5, Water: 2, Hardware: 4 }, - prodMats: ["RealEstate"], + prodMats: ["Real Estate"], }, [IndustryType.Robotics]: { startingCost: 1e12, description: "Develop and create robots.", product: { name: "Robot", verb: "Design", desc: "Design and create a new robot or robotic system!" }, + ProductRatingWeights: { + Quality: 0.1, + Performance: 0.2, + Durability: 0.2, + Reliability: 0.2, + Aesthetics: 0.1, + Features: 0.2, + }, recommendStarting: false, reFac: 0.32, sciFac: 0.65, @@ -191,7 +243,14 @@ export const IndustriesData: Record = { startingCost: 25e9, description: "Develop computer software and create AI Cores.", product: { name: "Software", verb: "Develop", desc: "Develop a new piece of software!" }, - recommendStarting: true, + ProductRatingWeights: { + Quality: 0.2, + Performance: 0.2, + Reliability: 0.2, + Durability: 0.2, + Features: 0.2, + }, + recommendStarting: false, sciFac: 0.62, advFac: 0.16, hwFac: 0.25, @@ -199,12 +258,17 @@ export const IndustriesData: Record = { aiFac: 0.18, robFac: 0.05, reqMats: { Hardware: 0.5, Energy: 0.5 }, - prodMats: ["AICores"], + prodMats: ["AI Cores"], }, [IndustryType.Tobacco]: { startingCost: 20e9, description: "Create and distribute tobacco and tobacco-related products.", product: { name: "Product", verb: "Create", desc: "Create a new tobacco product!" }, + ProductRatingWeights: { + Quality: 0.7, + Durability: 0.1, + Aesthetics: 0.2, + }, recommendStarting: true, reFac: 0.15, sciFac: 0.75, diff --git a/src/Corporation/MaterialInfo.ts b/src/Corporation/MaterialInfo.ts new file mode 100644 index 000000000..b5c0633cb --- /dev/null +++ b/src/Corporation/MaterialInfo.ts @@ -0,0 +1,14 @@ +// Map of material (by name) to their sizes (how much space it takes in warehouse) +export const MaterialInfo: Record = { + Water: ["Water", 0.05, false], + Energy: ["Energy", 0.01, false], + Food: ["Food", 0.03, false], + Plants: ["Plants", 0.05, false], + Metal: ["Metal", 0.1, false], + Hardware: ["Hardware", 0.06, true], + Chemicals: ["Chemicals", 0.05, false], + Drugs: ["Drugs", 0.02, false], + Robots: ["Robots", 0.5, true], + AICores: ["AI Cores", 0.1, true], + RealEstate: ["Real Estate", 0.005, true], +}; diff --git a/src/Corporation/MaterialSizes.ts b/src/Corporation/MaterialSizes.ts deleted file mode 100644 index b7e402a54..000000000 --- a/src/Corporation/MaterialSizes.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Map of material (by name) to their sizes (how much space it takes in warehouse) -export const MaterialSizes: Record = { - Water: 0.05, - Energy: 0.01, - Food: 0.03, - Plants: 0.05, - Metal: 0.1, - Hardware: 0.06, - Chemicals: 0.05, - Drugs: 0.02, - Robots: 0.5, - AICores: 0.1, - RealEstate: 0.005, - "Real Estate": 0.005, - "AI Cores": 0.1, -}; diff --git a/src/Corporation/Product.ts b/src/Corporation/Product.ts index 092f5aaf2..4d3ea2df2 100644 --- a/src/Corporation/Product.ts +++ b/src/Corporation/Product.ts @@ -1,7 +1,7 @@ import { EmployeePositions } from "./EmployeePositions"; -import { MaterialSizes } from "./MaterialSizes"; +import { MaterialInfo } from "./MaterialInfo"; import { Industry } from "./Industry"; -import { ProductRatingWeights } from "./ProductRatingWeights"; +import { IndustriesData } from "./IndustryData"; import { createCityMap } from "../Locations/createCityMap"; @@ -244,12 +244,12 @@ export class Product { for (const matName of Object.keys(industry.reqMats)) { const reqMat = industry.reqMats[matName]; if (reqMat === undefined) continue; - this.siz += MaterialSizes[matName] * reqMat; + this.siz += MaterialInfo[matName][1] * reqMat; } } calculateRating(industry: Industry): void { - const weights = ProductRatingWeights[industry.type]; + const weights = IndustriesData[industry.type].ProductRatingWeights; if (!weights) return console.error(`Could not find product rating weights for: ${industry}`); this.rat = 0; this.rat += weights.Quality ? this.qlt * weights.Quality : 0; diff --git a/src/Corporation/ProductRatingWeights.ts b/src/Corporation/ProductRatingWeights.ts deleted file mode 100644 index 9f46eda07..000000000 --- a/src/Corporation/ProductRatingWeights.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { IndustryType } from "./IndustryData"; - -export interface IProductRatingWeight { - Aesthetics?: number; - Durability?: number; - Features?: number; - Quality?: number; - Performance?: number; - Reliability?: number; -} -//TODO: Move this to IndustryData -export const ProductRatingWeights: Partial> = { - [IndustryType.Food]: { - Quality: 0.7, - Durability: 0.1, - Aesthetics: 0.2, - }, - [IndustryType.Tobacco]: { - Quality: 0.4, - Durability: 0.2, - Reliability: 0.2, - Aesthetics: 0.2, - }, - [IndustryType.Pharmaceutical]: { - Quality: 0.2, - Performance: 0.2, - Durability: 0.1, - Reliability: 0.3, - Features: 0.2, - }, - [IndustryType.Computers]: { - Quality: 0.15, - Performance: 0.25, - Durability: 0.25, - Reliability: 0.2, - Aesthetics: 0.05, - Features: 0.1, - }, - [IndustryType.Robotics]: { - Quality: 0.1, - Performance: 0.2, - Durability: 0.2, - Reliability: 0.2, - Aesthetics: 0.1, - Features: 0.2, - }, - [IndustryType.Software]: { - Quality: 0.2, - Performance: 0.2, - Reliability: 0.2, - Durability: 0.2, - Features: 0.2, - }, - [IndustryType.Healthcare]: { - Quality: 0.4, - Performance: 0.1, - Durability: 0.1, - Reliability: 0.3, - Features: 0.1, - }, - [IndustryType.RealEstate]: { - Quality: 0.2, - Durability: 0.25, - Reliability: 0.1, - Aesthetics: 0.35, - Features: 0.1, - }, -}; diff --git a/src/Corporation/Warehouse.ts b/src/Corporation/Warehouse.ts index dda5d46c6..1b370aac7 100644 --- a/src/Corporation/Warehouse.ts +++ b/src/Corporation/Warehouse.ts @@ -1,7 +1,7 @@ import { Material } from "./Material"; import { Corporation } from "./Corporation"; import { Industry } from "./Industry"; -import { MaterialSizes } from "./MaterialSizes"; +import { MaterialInfo } from "./MaterialInfo"; import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { exceptionAlert } from "../utils/helpers/exceptionAlert"; @@ -86,8 +86,8 @@ export class Warehouse { this.sizeUsed = 0; for (const matName of Object.keys(this.materials)) { const mat = this.materials[matName]; - if (MaterialSizes.hasOwnProperty(matName)) { - this.sizeUsed += mat.qty * MaterialSizes[matName]; + if (MaterialInfo.hasOwnProperty(matName)) { + this.sizeUsed += mat.qty * MaterialInfo[matName][1]; } } if (this.sizeUsed > this.size) { diff --git a/src/Corporation/data/Constants.ts b/src/Corporation/data/Constants.ts index 4afd712b0..fd2eaa37d 100644 --- a/src/Corporation/data/Constants.ts +++ b/src/Corporation/data/Constants.ts @@ -77,7 +77,7 @@ export const CorporationConstants = { "ABC SalesBots", "Project Insight", ], - AllResearch: [ + BaseResearch: [ "Hi-Tech R&D Laboratory", "AutoBrew", "AutoPartyManager", @@ -96,12 +96,8 @@ export const CorporationConstants = { "Overclock", "Self-Correcting Assemblers", "Sti.mu", - "sudo.Assist", - "uPgrade: Capacity.I", - "uPgrade: Capacity.II", - "uPgrade: Dashboard", - "uPgrade: Fulcrum", ], + ProdResearch: ["uPgrade: Capacity.I", "uPgrade: Capacity.II", "uPgrade: Dashboard", "uPgrade: Fulcrum"], FundingRoundShares: [0.1, 0.35, 0.25, 0.2], FundingRoundMultiplier: [4, 3, 3, 2.5], diff --git a/src/Corporation/data/CorporationUpgrades.ts b/src/Corporation/data/CorporationUpgrades.ts index f3cd6054c..3e9f86211 100644 --- a/src/Corporation/data/CorporationUpgrades.ts +++ b/src/Corporation/data/CorporationUpgrades.ts @@ -59,7 +59,7 @@ export const CorporationUpgrades: Record - {matName}: {numeralWrapper.format(mat.qty * MaterialSizes[matName], "0,0.0")} + {matName}: {numeralWrapper.format(mat.qty * MaterialInfo[matName][1], "0,0.0")} , ); } diff --git a/src/Corporation/ui/modals/PurchaseMaterialModal.tsx b/src/Corporation/ui/modals/PurchaseMaterialModal.tsx index c03486f0b..654c12b99 100644 --- a/src/Corporation/ui/modals/PurchaseMaterialModal.tsx +++ b/src/Corporation/ui/modals/PurchaseMaterialModal.tsx @@ -1,6 +1,6 @@ import React, { useState } from "react"; import { dialogBoxCreate } from "../../../ui/React/DialogBox"; -import { MaterialSizes } from "../../MaterialSizes"; +import { MaterialInfo } from "../../MaterialInfo"; import { Warehouse } from "../../Warehouse"; import { Material } from "../../Material"; import { numeralWrapper } from "../../../ui/numeralFormat"; @@ -33,7 +33,7 @@ function BulkPurchaseSection(props: IBPProps): React.ReactElement { const parsedAmt = parseFloat(props.amount); const cost = parsedAmt * props.mat.bCost; - const matSize = MaterialSizes[props.mat.name]; + const matSize = MaterialInfo[props.mat.name][1]; const maxAmount = (props.warehouse.size - props.warehouse.sizeUsed) / matSize; if (parsedAmt > maxAmount) { diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index 9492a3a8d..296c22e53 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -349,6 +349,7 @@ const grafting = { const corporation = { hasCorporation: 0, getMaterialNames: 0, + getConstants: 0, getIndustryTypes: 0, getEmployeePositions: 0, getUnlockables: 0, diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index 9e8e282df..cd51a3075 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -8,6 +8,9 @@ import { Industry } from "../Corporation/Industry"; import { Corporation } from "../Corporation/Corporation"; import { + productInfo as NSProduct, + materialInfo as NSMaterial, + divisionInfo as NSDivisionInfo, Corporation as NSCorporation, Division as NSDivision, WarehouseAPI, @@ -60,6 +63,7 @@ import { InternalAPI, NetscriptContext } from "../Netscript/APIWrapper"; import { assertEnumMember, helpers } from "../Netscript/NetscriptHelpers"; import { checkEnum } from "../utils/helpers/enum"; import { CityName } from "../Locations/data/CityNames"; +import { MaterialInfo } from "../Corporation/MaterialInfo"; export function NetscriptCorporation(): InternalAPI { function createCorporation(corporationName: string, selfFund = true): boolean { @@ -115,10 +119,6 @@ export function NetscriptCorporation(): InternalAPI { return baseCost * Math.pow(priceMult, level); } - function getExpandCityCost(): number { - return CorporationConstants.OfficeInitialCost; - } - function getInvestmentOffer(): InvestmentOffer { const corporation = getCorporation(); if ( @@ -285,11 +285,59 @@ export function NetscriptCorporation(): InternalAPI { }; } + function getDivisionConstants(): Record { + const divObject: Record = {}; + for (const [ind, type] of Object.entries(IndustryType)) { + divObject[ind] = { + type: type, + cost: IndustriesData[type].startingCost, + requiredMaterials: IndustriesData[type].reqMats, + makesMaterials: IndustriesData[type].prodMats ? true : false, + makesProducts: IndustriesData[type].product ? true : false, + }; + if (divObject[ind].makesProducts) { + divObject[ind].productType = IndustriesData[type].product?.name; + } + if (divObject[ind].makesMaterials) { + divObject[ind].producedMaterials = IndustriesData[type].prodMats; + } + } + return divObject; + } + + function getProductInfo(): Record { + const prodsObject: Record = {}; + for (const [ind, type] of Object.entries(IndustryType)) { + if (typeof IndustriesData[type].product !== "undefined") { + prodsObject[ind] = { + requiredMaterials: Object.keys(IndustriesData[type].reqMats), + size: 0, + division: type, + }; + prodsObject[ind].type = IndustriesData[type].product?.name; + let totSize = 0; + for (const mat of prodsObject[ind].requiredMaterials) { + totSize += MaterialInfo[mat][1]; + } + prodsObject[ind].size = totSize; + } + } + return prodsObject; + } + + function getMaterialInfo(): Record { + const matsObject: Record = {}; + for (const [mat, info] of Object.entries(MaterialInfo)) { + matsObject[mat] = { + name: info[0], + size: info[1], + prodMult: info[2], + }; + } + return matsObject; + } + const warehouseAPI: InternalAPI = { - getPurchaseWarehouseCost: (ctx) => () => { - checkAccess(ctx, 7); - return CorporationConstants.WarehouseInitialCost; - }, getUpgradeWarehouseCost: (ctx) => (_divisionName, _cityName, _amt = 1) => { @@ -710,22 +758,22 @@ export function NetscriptCorporation(): InternalAPI { ...warehouseAPI, ...officeAPI, hasCorporation: () => () => !!Player.corporation, - // Todo: Just remove these functions and provide enums? - getMaterialNames: (ctx) => () => { + getConstants: (ctx) => () => { checkAccess(ctx); - return [...CorporationConstants.AllMaterials]; - }, - getUnlockables: (ctx) => () => { - checkAccess(ctx); - return [...CorporationConstants.AllUnlocks]; - }, - getUpgradeNames: (ctx) => () => { - checkAccess(ctx); - return [...CorporationConstants.AllUpgrades]; - }, - getResearchNames: (ctx) => () => { - checkAccess(ctx); - return [...CorporationConstants.AllResearch]; + return { + coffeeCost: 5e8, + states: [...CorporationConstants.AllCorporationStates], + bribeToRepRatio: CorporationConstants.BribeToRepRatio, + cityExpandCost: CorporationConstants.OfficeInitialCost, + warehousePurchaseCost: CorporationConstants.WarehouseInitialCost, + baseMaxProducts: CorporationConstants.BaseMaxProducts, + products: getProductInfo(), + materials: getMaterialInfo(), + unlocks: [...CorporationConstants.AllUnlocks], + upgrades: [...CorporationConstants.AllUpgrades], + researches: { base: [...CorporationConstants.BaseResearch], product: [...CorporationConstants.ProdResearch] }, + divisions: getDivisionConstants(), + }; }, expandIndustry: (ctx) => (_industryName, _divisionName) => { checkAccess(ctx); @@ -826,18 +874,6 @@ export function NetscriptCorporation(): InternalAPI { const upgradeName = helpers.string(ctx, "upgradeName", _upgradeName); return getUpgradeLevelCost(ctx, upgradeName); }, - getExpandIndustryCost: (ctx) => (_industryName) => { - checkAccess(ctx); - const industryName = helpers.string(ctx, "industryName", _industryName); - if (!checkEnum(IndustryType, industryName)) { - throw helpers.makeRuntimeErrorMsg(ctx, `Invalid industry: '${industryName}'`); - } - return IndustriesData[industryName].startingCost; - }, - getExpandCityCost: (ctx) => () => { - checkAccess(ctx); - return getExpandCityCost(); - }, getInvestmentOffer: (ctx) => () => { checkAccess(ctx); return getInvestmentOffer(); diff --git a/src/NetscriptWorker.ts b/src/NetscriptWorker.ts index ded347790..a9844ff6c 100644 --- a/src/NetscriptWorker.ts +++ b/src/NetscriptWorker.ts @@ -415,6 +415,9 @@ export function runScriptFromScript( return 0; } + //prevent leading / from causing a bug + if (scriptname.startsWith("/")) scriptname = scriptname.slice(1); + if (typeof scriptname !== "string" || !Array.isArray(args)) { workerScript.log(caller, () => `Invalid arguments: scriptname='${scriptname} args='${args}'`); console.error(`runScriptFromScript() failed due to invalid arguments`); diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 992da7877..ff09b105d 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -7039,6 +7039,17 @@ declare enum IndustryType { RealEstate = "RealEstate", } +/** Names of all cities + * @public */ +declare enum CityName { + Aevum = "Aevum", + Chongqing = "Chongqing", + Sector12 = "Sector-12", + NewTokyo = "New Tokyo", + Ishima = "Ishima", + Volhaven = "Volhaven", +} + /** Names of all locations * @public */ declare enum LocationName { @@ -7422,11 +7433,6 @@ export interface WarehouseAPI { * @param qty - Amount to limit to. Pass a negative value to remove the limit instead. */ limitProductProduction(divisionName: string, cityName: string, productName: string, qty: number): void; - /** - * Gets the cost to purchase a warehouse - * @returns cost - */ - getPurchaseWarehouseCost(): number; /** * Gets the cost to upgrade a warehouse to the next level * @param divisionName - Name of the division @@ -7483,34 +7489,13 @@ export interface Corporation extends WarehouseAPI, OfficeAPI { * @returns cost of the upgrade */ getUpgradeLevelCost(upgradeName: string): number; - /** Gets the cost to expand into a new industry - * @param industryName - Name of the industry - * @returns cost */ - getExpandIndustryCost(industryName: IndustryType | `${IndustryType}`): number; - - /** Gets the cost to expand into a new city - * @returns cost */ - getExpandCityCost(): number; - /** Get an offer for investment based on you companies current valuation * @returns An offer of investment */ getInvestmentOffer(): InvestmentOffer; - /** Get list of materials - * @returns material names */ - getMaterialNames(): string[]; - - /** Get list of one-time unlockable upgrades - * @returns unlockable upgrades names */ - getUnlockables(): string[]; - - /** Get list of upgrade names - * @returns upgrade names */ - getUpgradeNames(): string[]; - - /** Get list of research names - * @returns research names */ - getResearchNames(): string[]; + /** Get corporation related constants + * @returns corporation related constants */ + getConstants(): CorpConstants; /** Accept investment based on you companies current valuation * @remarks @@ -7612,6 +7597,86 @@ interface CorporationInfo { divisions: Division[]; } +/** + * Corporation related constants + * @public + */ +interface CorpConstants { + /** Corporation cycle states */ + states: string[]; + /** Unlockable upgrades */ + unlocks: string[]; + /** Levelable upgrades */ + upgrades: string[]; + /** Researches, product researches are only available to product making divisions */ + researches: Record; + /** Amount of funds required to bribe for 1 reputation */ + bribeToRepRatio: number; + /** Amount of products a division can have without researches */ + baseMaxProducts: number; + /** Cost to expand to another city within a division */ + cityExpandCost: number; + /** Cost to purchase a warehouse in a city */ + warehousePurchaseCost: number; + /** Cost of coffee per employee in an office */ + coffeeCost: number; + /** Array of all material types */ + materials: Record; + /** Array of all product types */ + products: Record; + /** Array of all division types */ + divisions: Record; +} + +/** + * Corporation material information + * @public + */ +interface materialInfo { + /** Name of the material */ + name: string; + /** Size of the material */ + size: number; + /** Revenue per second this cycle */ + prodMult: boolean; +} + +/** + * Corporation product information + * @public + */ +interface productInfo { + /** Product type */ + type?: string; + /** Size of the product */ + size: number; + /** Materials required to make the product */ + requiredMaterials: string[]; + /** Division type which makes the product */ + division: string; +} + +/** + * Corporation division information + * @public + */ +interface divisionInfo { + /** Division type */ + type: string; + /** Cost to expand to the division */ + cost: number; + /** Materials required for production and their amounts */ + requiredMaterials: Record; + /** Materials produced */ + producedMaterials?: string[]; + /** Whether the division makes materials */ + makesMaterials: boolean; + /** Whether the division makes products */ + makesProducts: boolean; + /** Product type */ + productType?: string; +} + /** * Product in a warehouse * @public diff --git a/src/utils/enums.ts b/src/utils/enums.ts index 766b079b8..1dbc14ecb 100644 --- a/src/utils/enums.ts +++ b/src/utils/enums.ts @@ -77,6 +77,16 @@ export enum GymType { agility = "agi", } +/** Names of all cities */ +export enum CityName { + Aevum = "Aevum", + Chongqing = "Chongqing", + Sector12 = "Sector-12", + NewTokyo = "New Tokyo", + Ishima = "Ishima", + Volhaven = "Volhaven", +} + /** Names of all locations */ export enum LocationName { AevumAeroCorp = "AeroCorp",