bitburner-src/src/NetscriptFunctions/Corporation.ts

926 lines
43 KiB
TypeScript
Raw Normal View History

2021-12-04 05:06:04 +01:00
import { INetscriptHelper } from "./INetscriptHelper";
import { WorkerScript } from "../Netscript/WorkerScript";
2021-10-14 09:22:02 +02:00
import { IPlayer } from "../PersonObjects/IPlayer";
2021-12-04 05:06:04 +01:00
import { netscriptDelay } from "../NetscriptEvaluator";
2021-10-14 09:22:02 +02:00
import { OfficeSpace } from "../Corporation/OfficeSpace";
import { Employee } from "../Corporation/Employee";
import { Product } from "../Corporation/Product";
import { Material } from "../Corporation/Material";
import { Warehouse } from "../Corporation/Warehouse";
import { IIndustry } from "../Corporation/IIndustry";
2021-12-04 05:06:04 +01:00
import { ICorporation } from "../Corporation/ICorporation";
import {
Corporation as NSCorporation,
CorporationInfo,
Employee as NSEmployee,
Product as NSProduct,
Material as NSMaterial,
Warehouse as NSWarehouse,
Division as NSDivision,
WarehouseAPI,
OfficeAPI,
2022-03-30 02:24:04 +02:00
InvestmentOffer,
2021-12-04 05:06:04 +01:00
} from "../ScriptEditor/NetscriptDefinitions";
2021-10-14 09:22:02 +02:00
import {
NewIndustry,
NewCity,
UnlockUpgrade,
LevelUpgrade,
IssueDividends,
SellMaterial,
SellProduct,
SetSmartSupply,
BuyMaterial,
AssignJob,
UpgradeOfficeSize,
ThrowParty,
PurchaseWarehouse,
UpgradeWarehouse,
BuyCoffee,
HireAdVert,
MakeProduct,
Research,
ExportMaterial,
CancelExportMaterial,
SetMaterialMarketTA1,
SetMaterialMarketTA2,
SetProductMarketTA1,
SetProductMarketTA2,
BulkPurchase,
SellShares,
BuyBackShares,
SetSmartSupplyUseLeftovers,
2021-10-14 09:22:02 +02:00
} from "../Corporation/Actions";
import { CorporationUnlockUpgrades } from "../Corporation/data/CorporationUnlockUpgrades";
import { CorporationUpgrades } from "../Corporation/data/CorporationUpgrades";
2021-12-04 05:06:04 +01:00
import { EmployeePositions } from "../Corporation/EmployeePositions";
import { calculateIntelligenceBonus } from "../PersonObjects/formulas/intelligence";
import { Industry } from "../Corporation/Industry";
import { IndustryResearchTrees, IndustryStartingCosts } from "../Corporation/IndustryData";
2022-01-12 00:47:04 +01:00
import { CorporationConstants } from "../Corporation/data/Constants";
import { IndustryUpgrades } from "../Corporation/IndustryUpgrades";
import { ResearchMap } from "../Corporation/ResearchMap";
2022-01-13 22:05:06 +01:00
import { Factions } from "../Faction/Factions";
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
2021-10-14 09:22:02 +02:00
2021-12-04 05:06:04 +01:00
export function NetscriptCorporation(
player: IPlayer,
workerScript: WorkerScript,
helper: INetscriptHelper,
): NSCorporation {
2022-01-11 20:43:29 +01:00
function createCorporation(corporationName: string, selfFund = true): boolean {
if (!player.canAccessCorporation() || player.hasCorporation()) return false;
if (!corporationName) return false;
2022-01-11 20:53:53 +01:00
if (player.bitNodeN !== 3 && !selfFund) throw new Error("cannot use seed funds outside of BitNode 3");
if (BitNodeMultipliers.CorporationSoftCap < 0.15)
throw new Error(`You cannot create a corporation for Bitnode ${player.bitNodeN}`);
2022-01-11 20:43:29 +01:00
if (selfFund) {
if (!player.canAfford(150e9)) return false;
player.startCorporation(corporationName);
player.loseMoney(150e9, "corporation");
} else {
player.startCorporation(corporationName, 500e6);
}
return true;
}
2022-01-12 00:47:04 +01:00
function hasUnlockUpgrade(upgradeName: string): boolean {
const corporation = getCorporation();
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
const upgN = upgrade[0];
return corporation.unlockUpgrades[upgN] === 1;
}
function getUnlockUpgradeCost(upgradeName: string): number {
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
return upgrade[1];
}
2022-03-30 02:24:04 +02:00
function getUpgradeLevel(_upgradeName: string): number {
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName);
2022-01-12 00:47:04 +01:00
const corporation = getCorporation();
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
const upgN = upgrade[0];
return corporation.upgrades[upgN];
}
2022-03-30 02:24:04 +02:00
function getUpgradeLevelCost(_upgradeName: string): number {
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName);
2022-01-12 00:47:04 +01:00
const corporation = getCorporation();
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
const upgN = upgrade[0];
const baseCost = upgrade[1];
const priceMult = upgrade[2];
const level = corporation.upgrades[upgN];
return baseCost * Math.pow(priceMult, level);
}
function getExpandIndustryCost(industryName: string): number {
const cost = IndustryStartingCosts[industryName];
if (cost === undefined) {
throw new Error(`Invalid industry: '${industryName}'`);
}
return cost;
}
function getExpandCityCost(): number {
return CorporationConstants.OfficeInitialCost;
}
2022-01-13 12:42:23 +01:00
function getInvestmentOffer(): InvestmentOffer {
const corporation = getCorporation();
2022-03-30 02:24:04 +02:00
if (
corporation.fundingRound >= CorporationConstants.FundingRoundShares.length ||
corporation.fundingRound >= CorporationConstants.FundingRoundMultiplier.length ||
corporation.public
)
2022-01-13 12:42:23 +01:00
return {
funds: 0,
shares: 0,
2022-03-30 02:24:04 +02:00
round: corporation.fundingRound + 1, // Make more readable
2022-01-13 12:42:23 +01:00
}; // Don't throw an error here, no reason to have a second function to check if you can get investment.
const val = corporation.determineValuation();
const percShares = CorporationConstants.FundingRoundShares[corporation.fundingRound];
const roundMultiplier = CorporationConstants.FundingRoundMultiplier[corporation.fundingRound];
const funding = val * percShares * roundMultiplier;
const investShares = Math.floor(CorporationConstants.INITIALSHARES * percShares);
return {
funds: funding,
shares: investShares,
2022-03-30 02:24:04 +02:00
round: corporation.fundingRound + 1, // Make more readable
2022-01-13 12:42:23 +01:00
};
}
function acceptInvestmentOffer(): boolean {
const corporation = getCorporation();
2022-03-30 02:24:04 +02:00
if (
corporation.fundingRound >= CorporationConstants.FundingRoundShares.length ||
corporation.fundingRound >= CorporationConstants.FundingRoundMultiplier.length ||
corporation.public
)
return false;
2022-01-13 12:42:23 +01:00
const val = corporation.determineValuation();
const percShares = CorporationConstants.FundingRoundShares[corporation.fundingRound];
const roundMultiplier = CorporationConstants.FundingRoundMultiplier[corporation.fundingRound];
const funding = val * percShares * roundMultiplier;
const investShares = Math.floor(CorporationConstants.INITIALSHARES * percShares);
corporation.fundingRound++;
corporation.addFunds(funding);
corporation.numShares -= investShares;
return true;
}
function goPublic(numShares: number): boolean {
const corporation = getCorporation();
const initialSharePrice = corporation.determineValuation() / corporation.totalShares;
if (isNaN(numShares)) throw new Error("Invalid value for number of issued shares");
if (numShares < 0) throw new Error("Invalid value for number of issued shares");
if (numShares > corporation.numShares) throw new Error("You don't have that many shares to issue!");
corporation.public = true;
corporation.sharePrice = initialSharePrice;
corporation.issuedShares = numShares;
corporation.numShares -= numShares;
corporation.addFunds(numShares * initialSharePrice);
return true;
}
function getResearchCost(division: IIndustry, researchName: string): number {
const researchTree = IndustryResearchTrees[division.type];
if (researchTree === undefined) throw new Error(`No research tree for industry '${division.type}'`);
const allResearch = researchTree.getAllNodes();
if (!allResearch.includes(researchName)) throw new Error(`No research named '${researchName}'`);
const research = ResearchMap[researchName];
return research.cost;
}
function hasResearched(division: IIndustry, researchName: string): boolean {
2022-03-30 02:24:04 +02:00
return division.researched[researchName] === undefined ? false : (division.researched[researchName] as boolean);
}
2022-01-13 22:05:06 +01:00
function bribe(factionName: string, amountCash: number, amountShares: number): boolean {
if (!player.factions.includes(factionName)) throw new Error("Invalid faction name");
2022-03-30 02:24:04 +02:00
if (isNaN(amountCash) || amountCash < 0 || isNaN(amountShares) || amountShares < 0)
throw new Error("Invalid value for amount field! Must be numeric, grater than 0.");
2022-01-13 22:05:06 +01:00
const corporation = getCorporation();
if (corporation.funds < amountCash) return false;
if (corporation.numShares < amountShares) return false;
2022-03-30 02:24:04 +02:00
const faction = Factions[factionName];
2022-01-13 22:05:06 +01:00
const info = faction.getInfo();
if (!info.offersWork()) return false;
if (player.hasGangWith(factionName)) return false;
const repGain = (amountCash + amountShares * corporation.sharePrice) / CorporationConstants.BribeToRepRatio;
faction.playerReputation += repGain;
corporation.funds = corporation.funds - amountCash;
corporation.numShares -= amountShares;
return true;
}
2021-12-04 05:06:04 +01:00
function getCorporation(): ICorporation {
2021-10-14 09:22:02 +02:00
const corporation = player.corporation;
if (corporation === null) throw new Error("cannot be called without a corporation");
2021-12-04 05:06:04 +01:00
return corporation;
}
function getDivision(divisionName: string): IIndustry {
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
2021-10-14 09:22:02 +02:00
const division = corporation.divisions.find((div) => div.name === divisionName);
if (division === undefined) throw new Error(`No division named '${divisionName}'`);
return division;
}
function getOffice(divisionName: string, cityName: string): OfficeSpace {
2021-10-14 09:22:02 +02:00
const division = getDivision(divisionName);
if (!(cityName in division.offices)) throw new Error(`Invalid city name '${cityName}'`);
const office = division.offices[cityName];
if (office === 0) throw new Error(`${division.name} has not expanded to '${cityName}'`);
return office;
}
function getWarehouse(divisionName: string, cityName: string): Warehouse {
2021-10-14 09:22:02 +02:00
const division = getDivision(divisionName);
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
const warehouse = division.warehouses[cityName];
if (warehouse === 0) throw new Error(`${division.name} has not expanded to '${cityName}'`);
return warehouse;
}
function getMaterial(divisionName: string, cityName: string, materialName: string): Material {
2021-10-14 09:22:02 +02:00
const warehouse = getWarehouse(divisionName, cityName);
2022-01-12 00:47:04 +01:00
const matName = (materialName as string).replace(/ /g, "");
const material = warehouse.materials[matName];
2021-10-14 09:22:02 +02:00
if (material === undefined) throw new Error(`Invalid material name: '${materialName}'`);
return material;
}
function getProduct(divisionName: string, productName: string): Product {
2021-10-14 09:22:02 +02:00
const division = getDivision(divisionName);
const product = division.products[productName];
if (product === undefined) throw new Error(`Invalid product name: '${productName}'`);
return product;
}
function getEmployee(divisionName: string, cityName: string, employeeName: string): Employee {
2021-10-14 09:22:02 +02:00
const office = getOffice(divisionName, cityName);
const employee = office.employees.find((e) => e.name === employeeName);
if (employee === undefined) throw new Error(`Invalid employee name: '${employeeName}'`);
return employee;
}
2021-12-04 05:06:04 +01:00
function checkAccess(func: string, api?: number): void {
if (player.corporation === null) throw helper.makeRuntimeErrorMsg(`corporation.${func}`, "Must own a corporation.");
if (!api) return;
if (!player.corporation.unlockUpgrades[api])
throw helper.makeRuntimeErrorMsg(`corporation.${func}`, "You do not have access to this API.");
}
function getSafeDivision(division: Industry): NSDivision {
const cities: string[] = [];
for (const office of Object.values(division.offices)) {
if (office === 0) continue;
cities.push(office.loc);
}
return {
name: division.name,
type: division.type,
awareness: division.awareness,
popularity: division.popularity,
prodMult: division.prodMult,
research: division.sciResearch.qty,
lastCycleRevenue: division.lastCycleRevenue,
lastCycleExpenses: division.lastCycleExpenses,
thisCycleRevenue: division.thisCycleRevenue,
thisCycleExpenses: division.thisCycleExpenses,
upgrades: division.upgrades.slice(),
cities: cities,
products: division.products === undefined ? [] : Object.keys(division.products),
};
}
2021-12-04 05:06:04 +01:00
const warehouseAPI: WarehouseAPI = {
2022-01-12 00:47:04 +01:00
getPurchaseWarehouseCost: function (): number {
checkAccess("getPurchaseWarehouseCost", 7);
return CorporationConstants.WarehouseInitialCost;
},
2022-03-30 02:24:04 +02:00
getUpgradeWarehouseCost: function (_divisionName: unknown, _cityName: unknown): number {
2022-01-12 00:47:04 +01:00
checkAccess("upgradeWarehouse", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("getUpgradeWarehouseCost", "divisionName", _divisionName);
const cityName = helper.city("getUpgradeWarehouseCost", "cityName", _cityName);
2022-01-12 00:47:04 +01:00
const warehouse = getWarehouse(divisionName, cityName);
return CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
},
2022-03-30 02:24:04 +02:00
hasWarehouse: function (_divisionName: unknown, _cityName: unknown): boolean {
2022-01-12 00:47:04 +01:00
checkAccess("hasWarehouse", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("getWarehouse", "divisionName", _divisionName);
const cityName = helper.city("getWarehouse", "cityName", _cityName);
2022-01-12 00:47:04 +01:00
const division = getDivision(divisionName);
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
const warehouse = division.warehouses[cityName];
return warehouse !== 0;
},
2022-03-30 02:24:04 +02:00
getWarehouse: function (_divisionName: unknown, _cityName: unknown): NSWarehouse {
2021-12-04 05:06:04 +01:00
checkAccess("getWarehouse", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("getWarehouse", "divisionName", _divisionName);
const cityName = helper.city("getWarehouse", "cityName", _cityName);
2021-12-04 05:06:04 +01:00
const warehouse = getWarehouse(divisionName, cityName);
return {
level: warehouse.level,
loc: warehouse.loc,
size: warehouse.size,
sizeUsed: warehouse.sizeUsed,
2022-03-30 02:24:04 +02:00
smartSupplyEnabled: warehouse.smartSupplyEnabled,
2021-12-04 05:06:04 +01:00
};
},
2022-03-30 02:24:04 +02:00
getMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown): NSMaterial {
2021-12-04 05:06:04 +01:00
checkAccess("getMaterial", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("getMaterial", "divisionName", _divisionName);
const cityName = helper.city("getMaterial", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const materialName = helper.string("getMaterial", "materialName", _materialName);
2021-12-04 05:06:04 +01:00
const material = getMaterial(divisionName, cityName, materialName);
return {
name: material.name,
qty: material.qty,
qlt: material.qlt,
prod: material.prd,
sell: material.sll,
2021-12-04 05:06:04 +01:00
};
},
2022-03-30 02:24:04 +02:00
getProduct: function (_divisionName: unknown, _productName: unknown): NSProduct {
2021-12-04 05:06:04 +01:00
checkAccess("getProduct", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("getProduct", "divisionName", _divisionName);
const productName = helper.string("getProduct", "productName", _productName);
2021-12-04 05:06:04 +01:00
const product = getProduct(divisionName, productName);
return {
name: product.name,
dmd: product.dmd,
cmp: product.cmp,
pCost: product.pCost,
sCost: product.sCost,
cityData: product.data,
developmentProgress: product.prog,
2021-12-04 05:06:04 +01:00
};
},
2022-03-30 02:24:04 +02:00
purchaseWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("purchaseWarehouse", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("purchaseWarehouse", "divisionName", _divisionName);
const cityName = helper.city("purchaseWarehouse", "cityName", _cityName);
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
2021-10-14 09:22:02 +02:00
},
2022-03-30 02:24:04 +02:00
upgradeWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("upgradeWarehouse", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("upgradeWarehouse", "divisionName", _divisionName);
const cityName = helper.city("upgradeWarehouse", "cityName", _cityName);
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName));
2021-10-14 09:22:02 +02:00
},
2022-03-30 02:24:04 +02:00
sellMaterial: function (
_divisionName: unknown,
_cityName: unknown,
_materialName: unknown,
_amt: unknown,
_price: unknown,
): void {
2021-12-04 05:06:04 +01:00
checkAccess("sellMaterial", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("sellMaterial", "divisionName", _divisionName);
const cityName = helper.city("sellMaterial", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const materialName = helper.string("sellMaterial", "materialName", _materialName);
const amt = helper.string("sellMaterial", "amt", _amt);
const price = helper.string("sellMaterial", "price", _price);
2021-10-14 09:22:02 +02:00
const material = getMaterial(divisionName, cityName, materialName);
SellMaterial(material, amt, price);
},
2021-12-04 05:06:04 +01:00
sellProduct: function (
2022-03-30 02:24:04 +02:00
_divisionName: unknown,
_cityName: unknown,
_productName: unknown,
_amt: unknown,
_price: unknown,
_all: unknown,
2021-12-04 05:06:04 +01:00
): void {
checkAccess("sellProduct", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("sellProduct", "divisionName", _divisionName);
const cityName = helper.city("sellProduct", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const productName = helper.string("sellProduct", "productName", _productName);
const amt = helper.string("sellProduct", "amt", _amt);
const price = helper.string("sellProduct", "price", _price);
const all = helper.boolean(_all);
2021-10-14 09:22:02 +02:00
const product = getProduct(divisionName, productName);
SellProduct(product, cityName, amt, price, all);
},
2022-03-30 02:24:04 +02:00
discontinueProduct: function (_divisionName: unknown, _productName: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("discontinueProduct", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("discontinueProduct", "divisionName", _divisionName);
const productName = helper.string("discontinueProduct", "productName", _productName);
2021-10-14 09:22:02 +02:00
getDivision(divisionName).discontinueProduct(getProduct(divisionName, productName));
},
2022-03-30 02:24:04 +02:00
setSmartSupply: function (_divisionName: unknown, _cityName: unknown, _enabled: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("setSmartSupply", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("setSmartSupply", "divisionName", _divisionName);
const cityName = helper.city("sellProduct", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const enabled = helper.boolean(_enabled);
2021-10-14 09:22:02 +02:00
const warehouse = getWarehouse(divisionName, cityName);
if (!hasUnlockUpgrade("Smart Supply"))
2022-03-30 02:24:04 +02:00
throw helper.makeRuntimeErrorMsg(
`corporation.setSmartSupply`,
`You have not purchased the Smart Supply upgrade!`,
);
2021-10-14 09:22:02 +02:00
SetSmartSupply(warehouse, enabled);
},
2022-03-30 02:24:04 +02:00
setSmartSupplyUseLeftovers: function (
_divisionName: unknown,
_cityName: unknown,
_materialName: unknown,
_enabled: unknown,
): void {
checkAccess("setSmartSupplyUseLeftovers", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("setSmartSupply", "divisionName", _divisionName);
const cityName = helper.city("sellProduct", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const materialName = helper.string("sellProduct", "materialName", _materialName);
const enabled = helper.boolean(_enabled);
const warehouse = getWarehouse(divisionName, cityName);
const material = getMaterial(divisionName, cityName, materialName);
if (!hasUnlockUpgrade("Smart Supply"))
2022-03-30 02:24:04 +02:00
throw helper.makeRuntimeErrorMsg(
`corporation.setSmartSupply`,
`You have not purchased the Smart Supply upgrade!`,
);
SetSmartSupplyUseLeftovers(warehouse, material, enabled);
},
2022-03-30 02:24:04 +02:00
buyMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("buyMaterial", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("buyMaterial", "divisionName", _divisionName);
const cityName = helper.city("buyMaterial", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const materialName = helper.string("buyMaterial", "materialName", _materialName);
const amt = helper.number("buyMaterial", "amt", _amt);
2022-02-01 12:43:14 +01:00
if (amt < 0) throw new Error("Invalid value for amount field! Must be numeric and greater than 0");
2021-10-14 09:22:02 +02:00
const material = getMaterial(divisionName, cityName, materialName);
BuyMaterial(material, amt);
},
2022-03-30 02:24:04 +02:00
bulkPurchase: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
checkAccess("bulkPurchase", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("bulkPurchase", "divisionName", _divisionName);
if (!hasResearched(getDivision(divisionName), "Bulk Purchasing"))
2022-03-30 02:24:04 +02:00
throw new Error(`You have not researched Bulk Purchasing in ${divisionName}`);
const corporation = getCorporation();
const cityName = helper.city("bulkPurchase", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const materialName = helper.string("bulkPurchase", "materialName", _materialName);
const amt = helper.number("bulkPurchase", "amt", _amt);
const warehouse = getWarehouse(divisionName, cityName);
const material = getMaterial(divisionName, cityName, materialName);
BulkPurchase(corporation, warehouse, material, amt);
},
2021-12-04 05:06:04 +01:00
makeProduct: function (
2022-03-30 02:24:04 +02:00
_divisionName: unknown,
_cityName: unknown,
_productName: unknown,
_designInvest: unknown,
_marketingInvest: unknown,
2021-12-04 05:06:04 +01:00
): void {
checkAccess("makeProduct", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("makeProduct", "divisionName", _divisionName);
const cityName = helper.city("makeProduct", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const productName = helper.string("makeProduct", "productName", _productName);
const designInvest = helper.number("makeProduct", "designInvest", _designInvest);
const marketingInvest = helper.number("makeProduct", "marketingInvest", _marketingInvest);
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
MakeProduct(corporation, getDivision(divisionName), cityName, productName, designInvest, marketingInvest);
},
exportMaterial: function (
2022-03-30 02:24:04 +02:00
_sourceDivision: unknown,
_sourceCity: unknown,
_targetDivision: unknown,
_targetCity: unknown,
_materialName: unknown,
_amt: unknown,
2021-12-04 05:06:04 +01:00
): void {
checkAccess("exportMaterial", 7);
2022-03-30 02:24:04 +02:00
const sourceDivision = helper.string("exportMaterial", "sourceDivision", _sourceDivision);
const sourceCity = helper.string("exportMaterial", "sourceCity", _sourceCity);
const targetDivision = helper.string("exportMaterial", "targetDivision", _targetDivision);
const targetCity = helper.string("exportMaterial", "targetCity", _targetCity);
const materialName = helper.string("exportMaterial", "materialName", _materialName);
const amt = helper.string("exportMaterial", "amt", _amt);
ExportMaterial(
targetDivision,
targetCity,
getMaterial(sourceDivision, sourceCity, materialName),
amt + "",
getDivision(targetDivision),
);
2021-12-04 05:06:04 +01:00
},
cancelExportMaterial: function (
2022-03-30 02:24:04 +02:00
_sourceDivision: unknown,
_sourceCity: unknown,
_targetDivision: unknown,
_targetCity: unknown,
_materialName: unknown,
_amt: unknown,
2021-12-04 05:06:04 +01:00
): void {
checkAccess("cancelExportMaterial", 7);
2022-03-30 02:24:04 +02:00
const sourceDivision = helper.string("cancelExportMaterial", "sourceDivision", _sourceDivision);
const sourceCity = helper.string("cancelExportMaterial", "sourceCity", _sourceCity);
const targetDivision = helper.string("cancelExportMaterial", "targetDivision", _targetDivision);
const targetCity = helper.string("cancelExportMaterial", "targetCity", _targetCity);
const materialName = helper.string("cancelExportMaterial", "materialName", _materialName);
const amt = helper.string("cancelExportMaterial", "amt", _amt);
2021-12-04 05:06:04 +01:00
CancelExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt + "");
},
2022-03-30 02:24:04 +02:00
setMaterialMarketTA1: function (
_divisionName: unknown,
_cityName: unknown,
_materialName: unknown,
_on: unknown,
): void {
2021-12-04 05:06:04 +01:00
checkAccess("setMaterialMarketTA1", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("setMaterialMarketTA1", "divisionName", _divisionName);
const cityName = helper.city("setMaterialMarketTA1", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const materialName = helper.string("setMaterialMarketTA1", "materialName", _materialName);
const on = helper.boolean(_on);
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
2022-03-30 02:24:04 +02:00
throw helper.makeRuntimeErrorMsg(
`corporation.setMaterialMarketTA1`,
`You have not researched MarketTA.I for division: ${divisionName}`,
);
2021-12-04 05:06:04 +01:00
SetMaterialMarketTA1(getMaterial(divisionName, cityName, materialName), on);
},
2022-03-30 02:24:04 +02:00
setMaterialMarketTA2: function (
_divisionName: unknown,
_cityName: unknown,
_materialName: unknown,
_on: unknown,
): void {
2021-12-04 05:06:04 +01:00
checkAccess("setMaterialMarketTA2", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("setMaterialMarketTA2", "divisionName", _divisionName);
const cityName = helper.city("setMaterialMarketTA2", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const materialName = helper.string("setMaterialMarketTA2", "materialName", _materialName);
const on = helper.boolean(_on);
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
2022-03-30 02:24:04 +02:00
throw helper.makeRuntimeErrorMsg(
`corporation.setMaterialMarketTA2`,
`You have not researched MarketTA.II for division: ${divisionName}`,
);
2021-12-04 05:06:04 +01:00
SetMaterialMarketTA2(getMaterial(divisionName, cityName, materialName), on);
},
2022-03-30 02:24:04 +02:00
setProductMarketTA1: function (_divisionName: unknown, _productName: unknown, _on: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("setProductMarketTA1", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("setProductMarketTA1", "divisionName", _divisionName);
const productName = helper.string("setProductMarketTA1", "productName", _productName);
const on = helper.boolean(_on);
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
2022-03-30 02:24:04 +02:00
throw helper.makeRuntimeErrorMsg(
`corporation.setProductMarketTA1`,
`You have not researched MarketTA.I for division: ${divisionName}`,
);
2021-12-04 05:06:04 +01:00
SetProductMarketTA1(getProduct(divisionName, productName), on);
},
2022-03-30 02:24:04 +02:00
setProductMarketTA2: function (_divisionName: unknown, _productName: unknown, _on: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("setProductMarketTA2", 7);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("setProductMarketTA2", "divisionName", _divisionName);
const productName = helper.string("setProductMarketTA2", "productName", _productName);
const on = helper.boolean(_on);
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
2022-03-30 02:24:04 +02:00
throw helper.makeRuntimeErrorMsg(
`corporation.setProductMarketTA2`,
`You have not researched MarketTA.II for division: ${divisionName}`,
);
2021-12-04 05:06:04 +01:00
SetProductMarketTA2(getProduct(divisionName, productName), on);
},
};
const officeAPI: OfficeAPI = {
2022-03-30 02:24:04 +02:00
getHireAdVertCost: function (_divisionName: unknown): number {
checkAccess("getHireAdVertCost", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("getHireAdVertCost", "divisionName", _divisionName);
2022-01-12 00:47:04 +01:00
const division = getDivision(divisionName);
const upgrade = IndustryUpgrades[1];
return upgrade[1] * Math.pow(upgrade[2], division.upgrades[1]);
},
2022-03-30 02:24:04 +02:00
getHireAdVertCount: function (_divisionName: unknown): number {
checkAccess("getHireAdVertCount", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("getHireAdVertCount", "divisionName", _divisionName);
2022-01-12 00:47:04 +01:00
const division = getDivision(divisionName);
2022-03-30 02:24:04 +02:00
return division.upgrades[1];
2022-01-12 00:47:04 +01:00
},
2022-03-30 02:24:04 +02:00
getResearchCost: function (_divisionName: unknown, _researchName: unknown): number {
checkAccess("getResearchCost", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("getResearchCost", "divisionName", _divisionName);
const researchName = helper.string("getResearchCost", "researchName", _researchName);
return getResearchCost(getDivision(divisionName), researchName);
},
2022-03-30 02:24:04 +02:00
hasResearched: function (_divisionName: unknown, _researchName: unknown): boolean {
checkAccess("hasResearched", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("hasResearched", "divisionName", _divisionName);
const researchName = helper.string("hasResearched", "researchName", _researchName);
return hasResearched(getDivision(divisionName), researchName);
},
2022-03-30 02:24:04 +02:00
setAutoJobAssignment: function (
_divisionName: unknown,
_cityName: unknown,
_job: unknown,
_amount: unknown,
): Promise<boolean> {
checkAccess("setAutoJobAssignment", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("setAutoJobAssignment", "divisionName", _divisionName);
const cityName = helper.city("setAutoJobAssignment", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const amount = helper.number("setAutoJobAssignment", "amount", _amount);
const job = helper.string("setAutoJobAssignment", "job", _job);
const office = getOffice(divisionName, cityName);
if (!Object.values(EmployeePositions).includes(job)) throw new Error(`'${job}' is not a valid job.`);
return netscriptDelay(1000, workerScript).then(function () {
if (workerScript.env.stopFlag) {
return Promise.reject(workerScript);
}
return Promise.resolve(office.setEmployeeToJob(job, amount));
});
},
2022-03-30 02:24:04 +02:00
getOfficeSizeUpgradeCost: function (_divisionName: unknown, _cityName: unknown, _size: unknown): number {
2022-01-15 15:24:01 +01:00
checkAccess("getOfficeSizeUpgradeCost", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("getOfficeSizeUpgradeCost", "divisionName", _divisionName);
const cityName = helper.city("getOfficeSizeUpgradeCost", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const size = helper.number("getOfficeSizeUpgradeCost", "size", _size);
2022-02-01 12:43:14 +01:00
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
2022-01-15 15:24:01 +01:00
const office = getOffice(divisionName, cityName);
const initialPriceMult = Math.round(office.size / CorporationConstants.OfficeInitialSize);
const costMultiplier = 1.09;
let mult = 0;
for (let i = 0; i < size / CorporationConstants.OfficeInitialSize; ++i) {
mult += Math.pow(costMultiplier, initialPriceMult + i);
}
return CorporationConstants.OfficeInitialCost * mult;
},
2022-03-30 02:24:04 +02:00
assignJob: function (
_divisionName: unknown,
_cityName: unknown,
_employeeName: unknown,
_job: unknown,
): Promise<void> {
2021-12-04 05:06:04 +01:00
checkAccess("assignJob", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("assignJob", "divisionName", _divisionName);
const cityName = helper.city("assignJob", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const employeeName = helper.string("assignJob", "employeeName", _employeeName);
const job = helper.string("assignJob", "job", _job);
2021-10-14 09:22:02 +02:00
const employee = getEmployee(divisionName, cityName, employeeName);
2021-12-04 05:06:04 +01:00
return netscriptDelay(1000, workerScript).then(function () {
return Promise.resolve(AssignJob(employee, job));
});
},
2022-03-30 02:24:04 +02:00
hireEmployee: function (_divisionName: unknown, _cityName: unknown): any {
2021-12-04 05:06:04 +01:00
checkAccess("hireEmployee", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("hireEmployee", "divisionName", _divisionName);
const cityName = helper.city("hireEmployee", "cityName", _cityName);
2021-10-14 09:22:02 +02:00
const office = getOffice(divisionName, cityName);
2021-12-09 02:03:22 +01:00
return office.hireRandomEmployee();
2021-10-14 09:22:02 +02:00
},
2022-03-30 02:24:04 +02:00
upgradeOfficeSize: function (_divisionName: unknown, _cityName: unknown, _size: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("upgradeOfficeSize", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("upgradeOfficeSize", "divisionName", _divisionName);
const cityName = helper.city("upgradeOfficeSize", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const size = helper.number("upgradeOfficeSize", "size", _size);
2022-02-01 12:43:14 +01:00
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
2021-10-14 09:22:02 +02:00
const office = getOffice(divisionName, cityName);
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
2021-10-14 09:22:02 +02:00
UpgradeOfficeSize(corporation, office, size);
},
2022-03-30 02:24:04 +02:00
throwParty: function (_divisionName: unknown, _cityName: unknown, _costPerEmployee: unknown): Promise<number> {
2021-12-04 05:06:04 +01:00
checkAccess("throwParty", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("throwParty", "divisionName", _divisionName);
const cityName = helper.city("throwParty", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const costPerEmployee = helper.number("throwParty", "costPerEmployee", _costPerEmployee);
if (costPerEmployee < 0)
throw new Error("Invalid value for Cost Per Employee field! Must be numeric and greater than 0");
2021-10-14 09:22:02 +02:00
const office = getOffice(divisionName, cityName);
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
return netscriptDelay(
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
workerScript,
).then(function () {
return Promise.resolve(ThrowParty(corporation, office, costPerEmployee));
});
},
2022-03-30 02:24:04 +02:00
buyCoffee: function (_divisionName: unknown, _cityName: unknown): Promise<void> {
2021-12-04 05:06:04 +01:00
checkAccess("buyCoffee", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("buyCoffee", "divisionName", _divisionName);
const cityName = helper.city("buyCoffee", "cityName", _cityName);
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
return netscriptDelay(
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
workerScript,
).then(function () {
return Promise.resolve(BuyCoffee(corporation, getDivision(divisionName), getOffice(divisionName, cityName)));
});
},
2022-03-30 02:24:04 +02:00
hireAdVert: function (_divisionName: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("hireAdVert", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("hireAdVert", "divisionName", _divisionName);
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
2021-10-14 09:22:02 +02:00
HireAdVert(corporation, getDivision(divisionName), getOffice(divisionName, "Sector-12"));
},
2022-03-30 02:24:04 +02:00
research: function (_divisionName: unknown, _researchName: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("research", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("research", "divisionName", _divisionName);
const researchName = helper.string("research", "researchName", _researchName);
2021-10-14 09:22:02 +02:00
Research(getDivision(divisionName), researchName);
},
2022-03-30 02:24:04 +02:00
getOffice: function (_divisionName: unknown, _cityName: unknown): any {
2021-12-04 05:06:04 +01:00
checkAccess("getOffice", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("getOffice", "divisionName", _divisionName);
const cityName = helper.city("getOffice", "cityName", _cityName);
2021-12-04 05:06:04 +01:00
const office = getOffice(divisionName, cityName);
return {
loc: office.loc,
size: office.size,
minEne: office.minEne,
maxEne: office.maxEne,
minHap: office.minHap,
maxHap: office.maxHap,
maxMor: office.maxMor,
employees: office.employees.map((e) => e.name),
employeeProd: {
Operations: office.employeeProd[EmployeePositions.Operations],
Engineer: office.employeeProd[EmployeePositions.Engineer],
Business: office.employeeProd[EmployeePositions.Business],
Management: office.employeeProd[EmployeePositions.Management],
"Research & Development": office.employeeProd[EmployeePositions.RandD],
Training: office.employeeProd[EmployeePositions.Training],
},
};
},
2022-03-30 02:24:04 +02:00
getEmployee: function (_divisionName: unknown, _cityName: unknown, _employeeName: unknown): NSEmployee {
2021-12-04 05:06:04 +01:00
checkAccess("getEmployee", 8);
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("getEmployee", "divisionName", _divisionName);
const cityName = helper.city("getEmployee", "cityName", _cityName);
2022-03-30 02:24:04 +02:00
const employeeName = helper.string("getEmployee", "employeeName", _employeeName);
2021-12-04 05:06:04 +01:00
const employee = getEmployee(divisionName, cityName, employeeName);
return {
name: employee.name,
mor: employee.mor,
hap: employee.hap,
ene: employee.ene,
int: employee.int,
cha: employee.cha,
exp: employee.exp,
cre: employee.cre,
eff: employee.eff,
sal: employee.sal,
loc: employee.loc,
pos: employee.pos,
};
2021-10-14 09:22:02 +02:00
},
2021-12-04 05:06:04 +01:00
};
return {
...warehouseAPI,
...officeAPI,
2022-03-30 02:24:04 +02:00
expandIndustry: function (_industryName: unknown, _divisionName: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("expandIndustry");
2022-03-30 02:24:04 +02:00
const industryName = helper.string("expandIndustry", "industryName", _industryName);
const divisionName = helper.string("expandIndustry", "divisionName", _divisionName);
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
NewIndustry(corporation, industryName, divisionName);
2021-10-14 09:22:02 +02:00
},
2022-03-30 02:24:04 +02:00
expandCity: function (_divisionName: unknown, _cityName: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("expandCity");
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("expandCity", "divisionName", _divisionName);
const cityName = helper.city("expandCity", "cityName", _cityName);
if (!CorporationConstants.Cities.includes(cityName)) throw new Error("Invalid city name");
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
const division = getDivision(divisionName);
NewCity(corporation, division, cityName);
2021-10-14 09:22:02 +02:00
},
2022-03-30 02:24:04 +02:00
unlockUpgrade: function (_upgradeName: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("unlockUpgrade");
2022-03-30 02:24:04 +02:00
const upgradeName = helper.string("unlockUpgrade", "upgradeName", _upgradeName);
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
UnlockUpgrade(corporation, upgrade);
2021-10-14 09:22:02 +02:00
},
2022-03-30 02:24:04 +02:00
levelUpgrade: function (_upgradeName: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("levelUpgrade");
2022-03-30 02:24:04 +02:00
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName);
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
LevelUpgrade(corporation, upgrade);
2021-10-14 09:22:02 +02:00
},
2022-03-30 02:24:04 +02:00
issueDividends: function (_percent: unknown): void {
2021-12-04 05:06:04 +01:00
checkAccess("issueDividends");
2022-03-30 02:24:04 +02:00
const percent = helper.number("issueDividends", "percent", _percent);
if (percent < 0 || percent > 100)
throw new Error("Invalid value for percent field! Must be numeric, greater than 0, and less than 100");
2021-12-04 05:06:04 +01:00
const corporation = getCorporation();
if (!corporation.public)
throw helper.makeRuntimeErrorMsg(`corporation.issueDividends`, `Your company has not gone public!`);
2021-12-04 05:06:04 +01:00
IssueDividends(corporation, percent);
2021-10-14 09:22:02 +02:00
},
2021-12-04 05:06:04 +01:00
2021-10-14 09:22:02 +02:00
// If you modify these objects you will affect them for real, it's not
// copies.
2022-03-30 02:24:04 +02:00
getDivision: function (_divisionName: unknown): NSDivision {
2021-12-04 05:06:04 +01:00
checkAccess("getDivision");
2022-03-30 02:24:04 +02:00
const divisionName = helper.string("getDivision", "divisionName", _divisionName);
2021-12-04 05:06:04 +01:00
const division = getDivision(divisionName);
return getSafeDivision(division);
2021-12-04 05:06:04 +01:00
},
getCorporation: function (): CorporationInfo {
checkAccess("getCorporation");
const corporation = getCorporation();
return {
name: corporation.name,
funds: corporation.funds,
revenue: corporation.revenue,
expenses: corporation.expenses,
public: corporation.public,
totalShares: corporation.totalShares,
numShares: corporation.numShares,
shareSaleCooldown: corporation.shareSaleCooldown,
issuedShares: corporation.issuedShares,
sharePrice: corporation.sharePrice,
state: corporation.state.getState(),
divisions: corporation.divisions.map((division): NSDivision => getSafeDivision(division)),
2021-12-04 05:06:04 +01:00
};
2021-10-14 09:22:02 +02:00
},
2022-03-30 02:24:04 +02:00
createCorporation: function (_corporationName: unknown, _selfFund: unknown = true): boolean {
const corporationName = helper.string("createCorporation", "corporationName", _corporationName);
const selfFund = helper.boolean(_selfFund);
2022-01-12 00:47:04 +01:00
return createCorporation(corporationName, selfFund);
},
2022-03-30 02:24:04 +02:00
hasUnlockUpgrade: function (_upgradeName: unknown): boolean {
2022-01-12 00:47:04 +01:00
checkAccess("hasUnlockUpgrade");
2022-03-30 02:24:04 +02:00
const upgradeName = helper.string("hasUnlockUpgrade", "upgradeName", _upgradeName);
2022-01-12 00:47:04 +01:00
return hasUnlockUpgrade(upgradeName);
},
2022-03-30 02:24:04 +02:00
getUnlockUpgradeCost: function (_upgradeName: unknown): number {
2022-01-12 00:47:04 +01:00
checkAccess("getUnlockUpgradeCost");
2022-03-30 02:24:04 +02:00
const upgradeName = helper.string("getUnlockUpgradeCost", "upgradeName", _upgradeName);
2022-01-12 00:47:04 +01:00
return getUnlockUpgradeCost(upgradeName);
},
2022-03-30 02:24:04 +02:00
getUpgradeLevel: function (_upgradeName: unknown): number {
2022-01-12 00:47:04 +01:00
checkAccess("hasUnlockUpgrade");
2022-03-30 02:24:04 +02:00
const upgradeName = helper.string("getUpgradeLevel", "upgradeName", _upgradeName);
2022-01-12 00:47:04 +01:00
return getUpgradeLevel(upgradeName);
},
2022-03-30 02:24:04 +02:00
getUpgradeLevelCost: function (_upgradeName: unknown): number {
2022-01-12 00:47:04 +01:00
checkAccess("getUpgradeLevelCost");
2022-03-30 02:24:04 +02:00
const upgradeName = helper.string("getUpgradeLevelCost", "upgradeName", _upgradeName);
2022-01-12 00:47:04 +01:00
return getUpgradeLevelCost(upgradeName);
},
2022-03-30 02:24:04 +02:00
getExpandIndustryCost: function (_industryName: unknown): number {
2022-01-12 00:47:04 +01:00
checkAccess("getExpandIndustryCost");
2022-03-30 02:24:04 +02:00
const industryName = helper.string("getExpandIndustryCost", "industryName", _industryName);
2022-01-12 00:47:04 +01:00
return getExpandIndustryCost(industryName);
},
getExpandCityCost: function (): number {
2022-01-12 00:47:04 +01:00
checkAccess("getExpandCityCost");
return getExpandCityCost();
2022-01-13 12:42:23 +01:00
},
getInvestmentOffer: function (): InvestmentOffer {
2022-01-13 12:42:23 +01:00
checkAccess("getInvestmentOffer");
return getInvestmentOffer();
},
acceptInvestmentOffer: function (): boolean {
2022-01-13 12:42:23 +01:00
checkAccess("acceptInvestmentOffer");
return acceptInvestmentOffer();
},
2022-03-30 02:24:04 +02:00
goPublic: function (_numShares: unknown): boolean {
checkAccess("acceptInvestmentOffer");
2022-03-30 02:24:04 +02:00
const numShares = helper.number("goPublic", "numShares", _numShares);
return goPublic(numShares);
},
2022-03-30 02:24:04 +02:00
sellShares: function (_numShares: unknown): number {
checkAccess("acceptInvestmentOffer");
2022-03-30 02:24:04 +02:00
const numShares = helper.number("sellStock", "numShares", _numShares);
return SellShares(getCorporation(), player, numShares);
},
2022-03-30 02:24:04 +02:00
buyBackShares: function (_numShares: unknown): boolean {
checkAccess("acceptInvestmentOffer");
2022-03-30 02:24:04 +02:00
const numShares = helper.number("buyStock", "numShares", _numShares);
return BuyBackShares(getCorporation(), player, numShares);
},
2022-03-30 02:24:04 +02:00
bribe: function (_factionName: unknown, _amountCash: unknown, _amountShares: unknown): boolean {
2022-01-13 22:05:06 +01:00
checkAccess("bribe");
2022-03-30 02:24:04 +02:00
const factionName = helper.string("bribe", "factionName", _factionName);
const amountCash = helper.number("bribe", "amountCash", _amountCash);
const amountShares = helper.number("bribe", "amountShares", _amountShares);
2022-01-13 22:05:06 +01:00
return bribe(factionName, amountCash, amountShares);
},
getBonusTime: function (): number {
checkAccess("getBonusTime");
return Math.round(getCorporation().storedCycles / 5) * 1000;
2022-03-30 02:24:04 +02:00
},
2021-10-14 09:22:02 +02:00
};
}