From 25afecc0ec896f9b9c87a766ecc3aa6dd1e4f90f Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Mon, 13 May 2024 04:52:07 +0700 Subject: [PATCH] CORPORATION: Rename functions in Actions.ts (#1272) This should be a straight rename, no functionality changes. --- src/Corporation/Actions.ts | 60 ++++----- src/Corporation/ui/DivisionOffice.tsx | 4 +- src/Corporation/ui/DivisionOverview.tsx | 4 +- src/Corporation/ui/NewDivisionTab.tsx | 4 +- .../ui/modals/BuybackSharesModal.tsx | 4 +- src/Corporation/ui/modals/ExportModal.tsx | 4 +- .../ui/modals/FindInvestorsModal.tsx | 4 +- src/Corporation/ui/modals/GoPublicModal.tsx | 4 +- .../ui/modals/IssueDividendsModal.tsx | 4 +- .../ui/modals/IssueNewSharesModal.tsx | 4 +- .../modals/LimitMaterialProductionModal.tsx | 4 +- .../ui/modals/LimitProductProductionModal.tsx | 4 +- .../ui/modals/MakeProductModal.tsx | 4 +- .../ui/modals/PurchaseMaterialModal.tsx | 6 +- src/Corporation/ui/modals/ResearchModal.tsx | 4 +- .../ui/modals/SellMaterialModal.tsx | 4 +- .../ui/modals/SellProductModal.tsx | 4 +- src/Corporation/ui/modals/SellSharesModal.tsx | 4 +- .../ui/modals/SmartSupplyModal.tsx | 8 +- src/Corporation/ui/modals/ThrowPartyModal.tsx | 4 +- .../ui/modals/UpgradeOfficeSizeModal.tsx | 4 +- src/NetscriptFunctions/Corporation.ts | 116 +++++++++--------- src/SaveObject.ts | 4 +- test/jest/Corporation.test.ts | 26 ++-- 24 files changed, 146 insertions(+), 146 deletions(-) diff --git a/src/Corporation/Actions.ts b/src/Corporation/Actions.ts index c2e299b4b..a5d4fdb86 100644 --- a/src/Corporation/Actions.ts +++ b/src/Corporation/Actions.ts @@ -57,7 +57,7 @@ export function createCorporation(corporationName: string, selfFund: boolean, re return true; } -export function NewDivision(corporation: Corporation, industry: IndustryType, name: string): void { +export function createDivision(corporation: Corporation, industry: IndustryType, name: string): void { if (corporation.divisions.size >= corporation.maxDivisions) throw new Error(`Cannot expand into ${industry} industry, too many divisions!`); @@ -124,7 +124,7 @@ export function purchaseOffice(corporation: Corporation, division: Division, cit ++corporation.numberOfOfficesAndWarehouses; } -export function IssueDividends(corporation: Corporation, rate: number): void { +export function issueDividends(corporation: Corporation, rate: number): void { if (isNaN(rate) || rate < 0 || rate > corpConstants.dividendMaxRate) { throw new Error(`Invalid value. Must be an number between 0 and ${corpConstants.dividendMaxRate}`); } @@ -132,7 +132,7 @@ export function IssueDividends(corporation: Corporation, rate: number): void { corporation.dividendRate = rate; } -export function GoPublic(corporation: Corporation, numShares: number): void { +export function goPublic(corporation: Corporation, numShares: number): void { const ceoOwnership = (corporation.numShares - numShares) / corporation.totalShares; const initialSharePrice = corporation.getTargetSharePrice(ceoOwnership); @@ -149,7 +149,7 @@ export function GoPublic(corporation: Corporation, numShares: number): void { corporation.gainFunds(numShares * initialSharePrice, "public equity"); } -export function IssueNewShares( +export function issueNewShares( corporation: Corporation, amount: number, ): [profit: number, amount: number, privateShares: number] { @@ -178,7 +178,7 @@ export function IssueNewShares( return [profit, amount, privateShares]; } -export function AcceptInvestmentOffer(corporation: Corporation): void { +export function acceptInvestmentOffer(corporation: Corporation): void { if ( corporation.fundingRound >= corpConstants.fundingRoundShares.length || corporation.fundingRound >= corpConstants.fundingRoundMultiplier.length || @@ -198,7 +198,7 @@ export function AcceptInvestmentOffer(corporation: Corporation): void { corporation.investorShares += investShares; } -export function SellMaterial(material: Material, amount: string, price: string): void { +export function sellMaterial(material: Material, amount: string, price: string): void { if (price === "") price = "0"; if (amount === "") amount = "0"; let cost = price.replace(/\s+/g, ""); @@ -250,7 +250,7 @@ export function SellMaterial(material: Material, amount: string, price: string): } } -export function SellProduct(product: Product, city: CityName, amt: string, price: string, all: boolean): void { +export function sellProduct(product: Product, city: CityName, amt: string, price: string, all: boolean): void { //Parse price // initliaze newPrice with oldPrice as default let newPrice = product.cityData[city].desiredSellPrice; @@ -320,15 +320,15 @@ export function SellProduct(product: Product, city: CityName, amt: string, price } } -export function SetSmartSupply(warehouse: Warehouse, smartSupply: boolean): void { +export function setSmartSupply(warehouse: Warehouse, smartSupply: boolean): void { warehouse.smartSupplyEnabled = smartSupply; } -export function SetSmartSupplyOption(warehouse: Warehouse, material: Material, useOption: CorpSmartSupplyOption): void { +export function setSmartSupplyOption(warehouse: Warehouse, material: Material, useOption: CorpSmartSupplyOption): void { warehouse.smartSupplyOptions[material.name] = useOption; } -export function BuyMaterial(division: Division, material: Material, amt: number): void { +export function buyMaterial(division: Division, material: Material, amt: number): void { if (!isRelevantMaterial(material.name, division)) { throw new Error(`${material.name} is not a relevant material for industry ${division.type}`); } @@ -338,7 +338,7 @@ export function BuyMaterial(division: Division, material: Material, amt: number) material.buyAmount = amt; } -export function BulkPurchase( +export function bulkPurchase( corp: Corporation, division: Division, warehouse: Warehouse, @@ -368,7 +368,7 @@ export function BulkPurchase( } } -export function SellShares(corporation: Corporation, numShares: number): number { +export function sellShares(corporation: Corporation, numShares: number): number { const failureReason = sellSharesFailureReason(corporation, numShares); if (failureReason) throw new Error(failureReason); @@ -383,7 +383,7 @@ export function SellShares(corporation: Corporation, numShares: number): number return profit; } -export function BuyBackShares(corporation: Corporation, numShares: number): boolean { +export function buyBackShares(corporation: Corporation, numShares: number): boolean { const failureReason = buybackSharesFailureReason(corporation, numShares); if (failureReason) throw new Error(failureReason); @@ -397,21 +397,21 @@ export function BuyBackShares(corporation: Corporation, numShares: number): bool return true; } -export function UpgradeOfficeSize(corp: Corporation, office: OfficeSpace, increase: PositiveInteger): void { +export function upgradeOfficeSize(corp: Corporation, office: OfficeSpace, increase: PositiveInteger): void { const cost = calculateOfficeSizeUpgradeCost(office.size, increase); if (corp.funds < cost) return; office.size += increase; corp.loseFunds(cost, "office"); } -export function BuyTea(corp: Corporation, office: OfficeSpace): boolean { +export function buyTea(corp: Corporation, office: OfficeSpace): boolean { const cost = office.getTeaCost(); if (corp.funds < cost || !office.setTea()) return false; corp.loseFunds(cost, "tea"); return true; } -export function ThrowParty(corp: Corporation, office: OfficeSpace, costPerEmployee: number): number { +export function throwParty(corp: Corporation, office: OfficeSpace, costPerEmployee: number): number { const mult = 1 + costPerEmployee / 10e6; const cost = costPerEmployee * office.numEmployees; if (corp.funds < cost) { @@ -438,29 +438,29 @@ export function purchaseWarehouse(corp: Corporation, division: Division, city: C ++corp.numberOfOfficesAndWarehouses; } -export function UpgradeWarehouseCost(warehouse: Warehouse, amt: number): number { +export function upgradeWarehouseCost(warehouse: Warehouse, amt: number): number { return Array.from(Array(amt).keys()).reduce( (acc, index) => acc + corpConstants.warehouseSizeUpgradeCostBase * Math.pow(1.07, warehouse.level + 1 + index), 0, ); } -export function UpgradeWarehouse(corp: Corporation, division: Division, warehouse: Warehouse, amt = 1): void { - const sizeUpgradeCost = UpgradeWarehouseCost(warehouse, amt); +export function upgradeWarehouse(corp: Corporation, division: Division, warehouse: Warehouse, amt = 1): void { + const sizeUpgradeCost = upgradeWarehouseCost(warehouse, amt); if (corp.funds < sizeUpgradeCost) return; warehouse.level += amt; warehouse.updateSize(corp, division); corp.loseFunds(sizeUpgradeCost, "warehouse"); } -export function HireAdVert(corp: Corporation, division: Division): void { +export function hireAdVert(corp: Corporation, division: Division): void { const cost = division.getAdVertCost(); if (corp.funds < cost) return; corp.loseFunds(cost, "advert"); division.applyAdVert(corp); } -export function MakeProduct( +export function makeProduct( corp: Corporation, division: Division, city: CityName, @@ -502,7 +502,7 @@ export function MakeProduct( division.products.set(product.name, product); } -export function Research(researchingDivision: Division, researchName: CorpResearchName): void { +export function research(researchingDivision: Division, researchName: CorpResearchName): void { const corp = Player.corporation; if (!corp) return; const researchTree = IndustryResearchTrees[researchingDivision.type]; @@ -541,7 +541,7 @@ export function Research(researchingDivision: Division, researchName: CorpResear } /** Set a new export for a material. Throw on any invalid input. */ -export function ExportMaterial( +export function exportMaterial( targetDivision: Division, targetCity: CityName, material: Material, @@ -592,13 +592,13 @@ Error encountered: ${error}`); material.exports.push(exportObj); } -export function CancelExportMaterial(divisionName: string, cityName: CityName, material: Material): void { +export function cancelExportMaterial(divisionName: string, cityName: CityName, material: Material): void { const index = material.exports.findIndex((exp) => exp.division === divisionName && exp.city === cityName); if (index === -1) return; material.exports.splice(index, 1); } -export function LimitProductProduction(product: Product, cityName: CityName, quantity: number): void { +export function limitProductProduction(product: Product, cityName: CityName, quantity: number): void { if (quantity < 0 || isNaN(quantity)) { product.cityData[cityName].productionLimit = null; } else { @@ -606,7 +606,7 @@ export function LimitProductProduction(product: Product, cityName: CityName, qua } } -export function LimitMaterialProduction(material: Material, quantity: number): void { +export function limitMaterialProduction(material: Material, quantity: number): void { if (quantity < 0 || isNaN(quantity)) { material.productionLimit = null; } else { @@ -614,19 +614,19 @@ export function LimitMaterialProduction(material: Material, quantity: number): v } } -export function SetMaterialMarketTA1(material: Material, on: boolean): void { +export function setMaterialMarketTA1(material: Material, on: boolean): void { material.marketTa1 = on; } -export function SetMaterialMarketTA2(material: Material, on: boolean): void { +export function setMaterialMarketTA2(material: Material, on: boolean): void { material.marketTa2 = on; } -export function SetProductMarketTA1(product: Product, on: boolean): void { +export function setProductMarketTA1(product: Product, on: boolean): void { product.marketTa1 = on; } -export function SetProductMarketTA2(product: Product, on: boolean): void { +export function setProductMarketTA2(product: Product, on: boolean): void { product.marketTa2 = on; } diff --git a/src/Corporation/ui/DivisionOffice.tsx b/src/Corporation/ui/DivisionOffice.tsx index 84eafd54a..305ecb856 100644 --- a/src/Corporation/ui/DivisionOffice.tsx +++ b/src/Corporation/ui/DivisionOffice.tsx @@ -4,7 +4,7 @@ import React, { useState } from "react"; import { OfficeSpace } from "../OfficeSpace"; import { CorpUnlockName, CorpEmployeeJob, CorpUpgradeName, CorpProductResearchName } from "@enums"; -import { BuyTea } from "../Actions"; +import { buyTea } from "../Actions"; import { MoneyCost } from "./MoneyCost"; import { formatBigNumber, formatCorpStat, formatCorpMultiplier } from "../../ui/formatNumber"; @@ -375,7 +375,7 @@ export function DivisionOffice(props: OfficeProps): React.ReactElement { BuyTea(corp, props.office)} + onClick={() => buyTea(corp, props.office)} > {props.office.teaPending ? ( "Buying Tea" diff --git a/src/Corporation/ui/DivisionOverview.tsx b/src/Corporation/ui/DivisionOverview.tsx index 1360d58f8..b407f229b 100644 --- a/src/Corporation/ui/DivisionOverview.tsx +++ b/src/Corporation/ui/DivisionOverview.tsx @@ -4,7 +4,7 @@ import React, { useState } from "react"; import { MathJax } from "better-react-mathjax"; import { CorpUnlockName, IndustryType } from "@enums"; -import { HireAdVert } from "../Actions"; +import { hireAdVert } from "../Actions"; import { formatBigNumber, formatCorpMultiplier } from "../../ui/formatNumber"; import { createProgressBarText } from "../../utils/helpers/createProgressBarText"; import { MakeProductModal } from "./modals/MakeProductModal"; @@ -226,7 +226,7 @@ export function DivisionOverview(props: DivisionOverviewProps): React.ReactEleme } disabledTooltip={division.getAdVertCost() > corp.funds ? "Insufficient corporation funds" : ""} onClick={() => { - HireAdVert(corp, division); + hireAdVert(corp, division); props.rerender(); }} > diff --git a/src/Corporation/ui/NewDivisionTab.tsx b/src/Corporation/ui/NewDivisionTab.tsx index 164a77401..39ffed4e0 100644 --- a/src/Corporation/ui/NewDivisionTab.tsx +++ b/src/Corporation/ui/NewDivisionTab.tsx @@ -10,7 +10,7 @@ import { dialogBoxCreate } from "../../ui/React/DialogBox"; import { IndustriesData } from "../data/IndustryData"; import { IndustryType } from "@enums"; import { useCorporation } from "./Context"; -import { NewDivision } from "../Actions"; +import { createDivision } from "../Actions"; import { ButtonWithTooltip } from "../../ui/Components/ButtonWithTooltip"; import { KEY } from "../../utils/helpers/keyCodes"; @@ -38,7 +38,7 @@ export function NewDivisionTab(props: IProps): React.ReactElement { function newDivision(): void { if (disabledText) return; try { - NewDivision(corp, industry, name); + createDivision(corp, industry, name); } catch (err) { dialogBoxCreate(err + ""); return; diff --git a/src/Corporation/ui/modals/BuybackSharesModal.tsx b/src/Corporation/ui/modals/BuybackSharesModal.tsx index 85388841b..f967d649b 100644 --- a/src/Corporation/ui/modals/BuybackSharesModal.tsx +++ b/src/Corporation/ui/modals/BuybackSharesModal.tsx @@ -7,7 +7,7 @@ import { useCorporation } from "../Context"; import Typography from "@mui/material/Typography"; import { ButtonWithTooltip } from "../../../ui/Components/ButtonWithTooltip"; import { NumberInput } from "../../../ui/React/NumberInput"; -import { BuyBackShares } from "../../Actions"; +import { buyBackShares } from "../../Actions"; import { KEY } from "../../../utils/helpers/keyCodes"; import { buybackSharesFailureReason } from "../../helpers"; @@ -29,7 +29,7 @@ export function BuybackSharesModal(props: IProps): React.ReactElement { function buy(): void { if (disabledText) return; try { - BuyBackShares(corp, shares); + buyBackShares(corp, shares); dialogBoxCreate( <> diff --git a/src/Corporation/ui/modals/ExportModal.tsx b/src/Corporation/ui/modals/ExportModal.tsx index 8b6d0ff0c..dd059417a 100644 --- a/src/Corporation/ui/modals/ExportModal.tsx +++ b/src/Corporation/ui/modals/ExportModal.tsx @@ -4,7 +4,7 @@ import { dialogBoxCreate } from "../../../ui/React/DialogBox"; import { Material } from "../../Material"; import { Export } from "../../Export"; import { Division } from "../../Division"; -import { ExportMaterial } from "../../Actions"; +import * as actions from "../../Actions"; import { Modal } from "../../../ui/React/Modal"; import { useCorporation } from "../Context"; import { isRelevantMaterial } from "../Helpers"; @@ -58,7 +58,7 @@ export function ExportModal(props: ExportModalProps): React.ReactElement { function exportMaterial(): void { try { if (!targetDivision || !targetCity) return; - ExportMaterial(targetDivision, targetCity, props.mat, exportAmount); + actions.exportMaterial(targetDivision, targetCity, props.mat, exportAmount); } catch (err) { dialogBoxCreate(err + ""); } diff --git a/src/Corporation/ui/modals/FindInvestorsModal.tsx b/src/Corporation/ui/modals/FindInvestorsModal.tsx index 9d3504289..1ecb65ac7 100644 --- a/src/Corporation/ui/modals/FindInvestorsModal.tsx +++ b/src/Corporation/ui/modals/FindInvestorsModal.tsx @@ -4,7 +4,7 @@ import { formatPercent, formatShares } from "../../../ui/formatNumber"; import { Modal } from "../../../ui/React/Modal"; import { Money } from "../../../ui/React/Money"; import { useCorporation } from "../Context"; -import { AcceptInvestmentOffer } from "../../Actions"; +import { acceptInvestmentOffer } from "../../Actions"; import Typography from "@mui/material/Typography"; import Button from "@mui/material/Button"; @@ -23,7 +23,7 @@ export function FindInvestorsModal(props: IProps): React.ReactElement { function findInvestors(): void { if (shares === 0) return; try { - AcceptInvestmentOffer(corp); + acceptInvestmentOffer(corp); dialogBoxCreate( <> You accepted the investment offer. diff --git a/src/Corporation/ui/modals/GoPublicModal.tsx b/src/Corporation/ui/modals/GoPublicModal.tsx index 2b02b241e..29eba01b4 100644 --- a/src/Corporation/ui/modals/GoPublicModal.tsx +++ b/src/Corporation/ui/modals/GoPublicModal.tsx @@ -10,7 +10,7 @@ import { NumberInput } from "../../../ui/React/NumberInput"; import Box from "@mui/material/Box"; import { KEY } from "../../../utils/helpers/keyCodes"; import { isPositiveInteger } from "../../../types"; -import { GoPublic } from "../../Actions"; +import * as actions from "../../Actions"; interface IProps { open: boolean; @@ -36,7 +36,7 @@ export function GoPublicModal(props: IProps): React.ReactElement { function goPublic(): void { if (disabledText) return; try { - GoPublic(corp, shares); + actions.goPublic(corp, shares); dialogBoxCreate( {corp.name} went public and earned in its IPO. diff --git a/src/Corporation/ui/modals/IssueDividendsModal.tsx b/src/Corporation/ui/modals/IssueDividendsModal.tsx index 3b60b44dd..a512aa281 100644 --- a/src/Corporation/ui/modals/IssueDividendsModal.tsx +++ b/src/Corporation/ui/modals/IssueDividendsModal.tsx @@ -4,7 +4,7 @@ import { Modal } from "../../../ui/React/Modal"; import { Money } from "../../../ui/React/Money"; import { MoneyRate } from "../../../ui/React/MoneyRate"; import * as corpConstants from "../../data/Constants"; -import { IssueDividends } from "../../Actions"; +import * as actions from "../../Actions"; import { useCorporation } from "../Context"; import Typography from "@mui/material/Typography"; import TextField from "@mui/material/TextField"; @@ -26,7 +26,7 @@ export function IssueDividendsModal(props: IProps): React.ReactElement { if (!canIssue) return; if (percent === null) return; try { - IssueDividends(corp, percent / 100); + actions.issueDividends(corp, percent / 100); } catch (err) { dialogBoxCreate(err + ""); } diff --git a/src/Corporation/ui/modals/IssueNewSharesModal.tsx b/src/Corporation/ui/modals/IssueNewSharesModal.tsx index 361b7de66..0031b02b0 100644 --- a/src/Corporation/ui/modals/IssueNewSharesModal.tsx +++ b/src/Corporation/ui/modals/IssueNewSharesModal.tsx @@ -8,7 +8,7 @@ import Typography from "@mui/material/Typography"; import { NumberInput } from "../../../ui/React/NumberInput"; import { ButtonWithTooltip } from "../../../ui/Components/ButtonWithTooltip"; import { KEY } from "../../../utils/helpers/keyCodes"; -import { IssueNewShares } from "../../Actions"; +import * as actions from "../../Actions"; import * as corpConstants from "../../data/Constants"; import { issueNewSharesFailureReason } from "../../helpers"; @@ -39,7 +39,7 @@ export function IssueNewSharesModal(props: IProps): React.ReactElement { function issueNewShares(): void { if (disabledText) return; try { - const [profit, newShares, privateShares] = IssueNewShares(corp, shares); + const [profit, newShares, privateShares] = actions.issueNewShares(corp, shares); dialogBoxCreate( <> diff --git a/src/Corporation/ui/modals/LimitMaterialProductionModal.tsx b/src/Corporation/ui/modals/LimitMaterialProductionModal.tsx index 9d9ab6563..a23bbba23 100644 --- a/src/Corporation/ui/modals/LimitMaterialProductionModal.tsx +++ b/src/Corporation/ui/modals/LimitMaterialProductionModal.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from "react"; -import { LimitMaterialProduction } from "../../Actions"; +import * as actions from "../../Actions"; import { Modal } from "../../../ui/React/Modal"; import Typography from "@mui/material/Typography"; import Button from "@mui/material/Button"; @@ -27,7 +27,7 @@ export function LimitMaterialProductionModal(props: IProps): React.ReactElement function limitMaterialProduction(): void { let qty = limit; if (qty === null) qty = -1; - LimitMaterialProduction(props.material, qty); + actions.limitMaterialProduction(props.material, qty); props.onClose(); } diff --git a/src/Corporation/ui/modals/LimitProductProductionModal.tsx b/src/Corporation/ui/modals/LimitProductProductionModal.tsx index f14c30381..2aeab61b4 100644 --- a/src/Corporation/ui/modals/LimitProductProductionModal.tsx +++ b/src/Corporation/ui/modals/LimitProductProductionModal.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from "react"; import type { CityName } from "@enums"; import type { Product } from "../../Product"; -import { LimitProductProduction } from "../../Actions"; +import * as actions from "../../Actions"; import { Modal } from "../../../ui/React/Modal"; import Typography from "@mui/material/Typography"; import Button from "@mui/material/Button"; @@ -29,7 +29,7 @@ export function LimitProductProductionModal(props: IProps): React.ReactElement { function limitProductProduction(): void { let qty = limit; if (qty === null) qty = -1; - LimitProductProduction(props.product, props.city, qty); + actions.limitProductProduction(props.product, props.city, qty); props.onClose(); } diff --git a/src/Corporation/ui/modals/MakeProductModal.tsx b/src/Corporation/ui/modals/MakeProductModal.tsx index dd424945e..9874863dc 100644 --- a/src/Corporation/ui/modals/MakeProductModal.tsx +++ b/src/Corporation/ui/modals/MakeProductModal.tsx @@ -3,7 +3,7 @@ import { dialogBoxCreate } from "../../../ui/React/DialogBox"; import { Modal } from "../../../ui/React/Modal"; import { IndustriesData } from "../../data/IndustryData"; import { IndustryType } from "@enums"; -import { MakeProduct } from "../../Actions"; +import * as actions from "../../Actions"; import { useCorporation, useDivision } from "../Context"; import Typography from "@mui/material/Typography"; import TextField from "@mui/material/TextField"; @@ -46,7 +46,7 @@ export function MakeProductModal(props: IProps): React.ReactElement { function makeProduct(): void { if (isNaN(design) || isNaN(marketing)) return; try { - MakeProduct(corp, division, city, name, design, marketing); + actions.makeProduct(corp, division, city, name, design, marketing); } catch (err) { dialogBoxCreate(err + ""); } diff --git a/src/Corporation/ui/modals/PurchaseMaterialModal.tsx b/src/Corporation/ui/modals/PurchaseMaterialModal.tsx index a7afcd8aa..d4ed5df51 100644 --- a/src/Corporation/ui/modals/PurchaseMaterialModal.tsx +++ b/src/Corporation/ui/modals/PurchaseMaterialModal.tsx @@ -4,7 +4,7 @@ import { MaterialInfo } from "../../MaterialInfo"; import { Warehouse } from "../../Warehouse"; import { Material } from "../../Material"; import { formatMatPurchaseAmount } from "../../../ui/formatNumber"; -import { BulkPurchase, BuyMaterial } from "../../Actions"; +import * as actions from "../../Actions"; import { Modal } from "../../../ui/React/Modal"; import { Money } from "../../../ui/React/Money"; import { useCorporation, useDivision } from "../Context"; @@ -66,7 +66,7 @@ function BulkPurchaseSection(props: IBPProps): React.ReactElement { function bulkPurchase(): void { try { - BulkPurchase(corp, division, props.warehouse, props.mat, parseFloat(buyAmt)); + actions.bulkPurchase(corp, division, props.warehouse, props.mat, parseFloat(buyAmt)); } catch (err) { dialogBoxCreate(err + ""); } @@ -118,7 +118,7 @@ export function PurchaseMaterialModal(props: IProps): React.ReactElement { function purchaseMaterial(): void { if (buyAmt === null) return; try { - BuyMaterial(division, props.mat, buyAmt); + actions.buyMaterial(division, props.mat, buyAmt); } catch (err) { dialogBoxCreate(err + ""); } diff --git a/src/Corporation/ui/modals/ResearchModal.tsx b/src/Corporation/ui/modals/ResearchModal.tsx index 04a1466e5..e2021fb8f 100644 --- a/src/Corporation/ui/modals/ResearchModal.tsx +++ b/src/Corporation/ui/modals/ResearchModal.tsx @@ -6,7 +6,7 @@ import { formatCorpMultiplier } from "../../../ui/formatNumber"; import { IndustryResearchTrees } from "../../data/IndustryData"; import * as corpConstants from "../../data/Constants"; import { Division } from "../../Division"; -import { Research } from "../../Actions"; +import * as actions from "../../Actions"; import { Node } from "../../ResearchTree"; import { ResearchMap } from "../../ResearchMap"; import { Settings } from "../../../Settings/Settings"; @@ -38,7 +38,7 @@ function Upgrade({ n, division }: INodeProps): React.ReactElement { function research(): void { if (n === null || disabled) return; try { - Research(division, n.researchName); + actions.research(division, n.researchName); } catch (err) { dialogBoxCreate(err + ""); return; diff --git a/src/Corporation/ui/modals/SellMaterialModal.tsx b/src/Corporation/ui/modals/SellMaterialModal.tsx index e6c321421..424a56ca7 100644 --- a/src/Corporation/ui/modals/SellMaterialModal.tsx +++ b/src/Corporation/ui/modals/SellMaterialModal.tsx @@ -6,7 +6,7 @@ import { Button, FormControlLabel, Switch, TextField, Tooltip, Typography } from import { Modal } from "../../../ui/React/Modal"; import { dialogBoxCreate } from "../../../ui/React/DialogBox"; -import { SellMaterial } from "../../Actions"; +import * as actions from "../../Actions"; import { KEY } from "../../../utils/helpers/keyCodes"; interface IProps { @@ -23,7 +23,7 @@ export function SellMaterialModal(props: IProps): React.ReactElement { function sellMaterial(): void { try { - SellMaterial(props.mat, amt, price); + actions.sellMaterial(props.mat, amt, price); } catch (err) { dialogBoxCreate(err + ""); } diff --git a/src/Corporation/ui/modals/SellProductModal.tsx b/src/Corporation/ui/modals/SellProductModal.tsx index 954a13a68..88d1354e5 100644 --- a/src/Corporation/ui/modals/SellProductModal.tsx +++ b/src/Corporation/ui/modals/SellProductModal.tsx @@ -7,7 +7,7 @@ import { Button, FormControlLabel, Switch, TextField, Tooltip, Typography } from import { Modal } from "../../../ui/React/Modal"; import { dialogBoxCreate } from "../../../ui/React/DialogBox"; -import { SellProduct } from "../../Actions"; +import * as actions from "../../Actions"; import { KEY } from "../../../utils/helpers/keyCodes"; interface IProps { @@ -30,7 +30,7 @@ export function SellProductModal(props: IProps): React.ReactElement { function sellProduct(): void { try { - SellProduct(props.product, props.city, iQty, px, checked); + actions.sellProduct(props.product, props.city, iQty, px, checked); } catch (err) { dialogBoxCreate(err + ""); } diff --git a/src/Corporation/ui/modals/SellSharesModal.tsx b/src/Corporation/ui/modals/SellSharesModal.tsx index 6ffdc0d0b..9a5b95a2a 100644 --- a/src/Corporation/ui/modals/SellSharesModal.tsx +++ b/src/Corporation/ui/modals/SellSharesModal.tsx @@ -7,7 +7,7 @@ import { useCorporation } from "../Context"; import * as corpConstants from "../../data/Constants"; import Typography from "@mui/material/Typography"; import { ButtonWithTooltip } from "../../../ui/Components/ButtonWithTooltip"; -import { SellShares } from "../../Actions"; +import { sellShares } from "../../Actions"; import { KEY } from "../../../utils/helpers/keyCodes"; import { NumberInput } from "../../../ui/React/NumberInput"; import { sellSharesFailureReason } from "../../helpers"; @@ -30,7 +30,7 @@ export function SellSharesModal(props: IProps): React.ReactElement { function sell(): void { if (disabledText) return; try { - SellShares(corp, shares); + sellShares(corp, shares); dialogBoxCreate( <> diff --git a/src/Corporation/ui/modals/SmartSupplyModal.tsx b/src/Corporation/ui/modals/SmartSupplyModal.tsx index 01f6b89c6..68afafb94 100644 --- a/src/Corporation/ui/modals/SmartSupplyModal.tsx +++ b/src/Corporation/ui/modals/SmartSupplyModal.tsx @@ -1,7 +1,7 @@ import React, { useState } from "react"; import { Warehouse } from "../../Warehouse"; -import { SetSmartSupply, SetSmartSupplyOption } from "../../Actions"; +import { setSmartSupply, setSmartSupplyOption } from "../../Actions"; import { dialogBoxCreate } from "../../../ui/React/DialogBox"; import { Modal } from "../../../ui/React/Modal"; import { useDivision } from "../Context"; @@ -26,7 +26,7 @@ function SSoption(props: ISSoptionProps): React.ReactElement { try { const matName = props.matName; const material = props.warehouse.materials[matName]; - SetSmartSupplyOption(props.warehouse, material, newValue); + setSmartSupplyOption(props.warehouse, material, newValue); } catch (err) { dialogBoxCreate(err + ""); } @@ -39,7 +39,7 @@ function SSoption(props: ISSoptionProps): React.ReactElement { try { const matName = props.matName; const material = props.warehouse.materials[matName]; - SetSmartSupplyOption(props.warehouse, material, newValue); + setSmartSupplyOption(props.warehouse, material, newValue); } catch (err) { dialogBoxCreate(err + ""); } @@ -74,7 +74,7 @@ export function SmartSupplyModal(props: IProps): React.ReactElement { // Smart Supply Checkbox function smartSupplyOnChange(e: React.ChangeEvent): void { - SetSmartSupply(props.warehouse, e.target.checked); + setSmartSupply(props.warehouse, e.target.checked); rerender(); } diff --git a/src/Corporation/ui/modals/ThrowPartyModal.tsx b/src/Corporation/ui/modals/ThrowPartyModal.tsx index ffa216ec8..4835055a5 100644 --- a/src/Corporation/ui/modals/ThrowPartyModal.tsx +++ b/src/Corporation/ui/modals/ThrowPartyModal.tsx @@ -2,7 +2,7 @@ import React, { useState } from "react"; import { formatMultiplier, formatPercent } from "../../../ui/formatNumber"; import { dialogBoxCreate } from "../../../ui/React/DialogBox"; import { OfficeSpace } from "../../OfficeSpace"; -import { ThrowParty } from "../../Actions"; +import * as actions from "../../Actions"; import { MoneyCost } from "../MoneyCost"; import { Modal } from "../../../ui/React/Modal"; import { useCorporation } from "../Context"; @@ -37,7 +37,7 @@ export function ThrowPartyModal(props: IProps): React.ReactElement { } else if (!canParty) { dialogBoxCreate("You don't have enough company funds to throw a party!"); } else { - const mult = ThrowParty(corp, props.office, cost); + const mult = actions.throwParty(corp, props.office, cost); // Each 10% multiplier gives an extra flat +1 to morale to make recovering from low morale easier. const increase = mult > 1 ? (mult - 1) * 0.1 : 0; diff --git a/src/Corporation/ui/modals/UpgradeOfficeSizeModal.tsx b/src/Corporation/ui/modals/UpgradeOfficeSizeModal.tsx index 5f04a5345..0271a67c1 100644 --- a/src/Corporation/ui/modals/UpgradeOfficeSizeModal.tsx +++ b/src/Corporation/ui/modals/UpgradeOfficeSizeModal.tsx @@ -3,7 +3,7 @@ import { formatMoney } from "../../../ui/formatNumber"; import * as corpConstants from "../../data/Constants"; import { OfficeSpace } from "../../OfficeSpace"; import { Corporation } from "../../Corporation"; -import { UpgradeOfficeSize } from "../../Actions"; +import { upgradeOfficeSize } from "../../Actions"; import { Modal } from "../../../ui/React/Modal"; import { useCorporation } from "../Context"; import Typography from "@mui/material/Typography"; @@ -29,7 +29,7 @@ function UpgradeSizeButton(props: IUpgradeButton): React.ReactElement { return; } - UpgradeOfficeSize(corp, props.office, increase); + upgradeOfficeSize(corp, props.office, increase); props.rerender(); props.onClose(); } diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index cc6591010..9ba5f4e30 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -19,37 +19,37 @@ import { } from "@nsdefs"; import { - NewDivision, + createDivision, purchaseOffice, - IssueDividends, - GoPublic, - IssueNewShares, - AcceptInvestmentOffer, - SellMaterial, - SellProduct, - SetSmartSupply, - BuyMaterial, - UpgradeOfficeSize, + issueDividends, + goPublic, + issueNewShares, + acceptInvestmentOffer, + sellMaterial, + sellProduct, + setSmartSupply, + buyMaterial, + upgradeOfficeSize, purchaseWarehouse, - UpgradeWarehouse, - BuyTea, - ThrowParty, - HireAdVert, - MakeProduct, - Research, - ExportMaterial, - CancelExportMaterial, - SetMaterialMarketTA1, - SetMaterialMarketTA2, - SetProductMarketTA1, - SetProductMarketTA2, - BulkPurchase, - SellShares, - BuyBackShares, - SetSmartSupplyOption, - LimitMaterialProduction, - LimitProductProduction, - UpgradeWarehouseCost, + upgradeWarehouse, + buyTea, + throwParty, + hireAdVert, + makeProduct, + research, + exportMaterial, + cancelExportMaterial, + setMaterialMarketTA1, + setMaterialMarketTA2, + setProductMarketTA1, + setProductMarketTA2, + bulkPurchase, + sellShares, + buyBackShares, + setSmartSupplyOption, + limitMaterialProduction, + limitProductProduction, + upgradeWarehouseCost, createCorporation, removeDivision, bribe, @@ -184,7 +184,7 @@ export function NetscriptCorporation(): InternalAPI { throw helpers.errorMessage(ctx, "You must provide a positive number"); } const warehouse = getWarehouse(divisionName, cityName); - return UpgradeWarehouseCost(warehouse, amt); + return upgradeWarehouseCost(warehouse, amt); }, hasWarehouse: (ctx) => (_divisionName, _cityName) => { checkAccess(ctx, CorpUnlockName.WarehouseAPI); @@ -273,7 +273,7 @@ export function NetscriptCorporation(): InternalAPI { if (amt < 1) { throw helpers.errorMessage(ctx, "You must provide a positive number"); } - UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName), amt); + upgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName), amt); }, sellMaterial: (ctx) => (_divisionName, _cityName, _materialName, _amt, _price) => { checkAccess(ctx, CorpUnlockName.WarehouseAPI); @@ -283,7 +283,7 @@ export function NetscriptCorporation(): InternalAPI { const amt = helpers.string(ctx, "amt", _amt); const price = helpers.string(ctx, "price", _price); const material = getMaterial(divisionName, cityName, materialName); - SellMaterial(material, amt, price); + sellMaterial(material, amt, price); }, sellProduct: (ctx) => @@ -296,7 +296,7 @@ export function NetscriptCorporation(): InternalAPI { const price = helpers.string(ctx, "price", _price); const all = !!_all; const product = getProduct(divisionName, productName); - SellProduct(product, cityName, amt, price, all); + sellProduct(product, cityName, amt, price, all); }, discontinueProduct: (ctx) => (_divisionName, _productName) => { checkAccess(ctx, CorpUnlockName.WarehouseAPI); @@ -312,7 +312,7 @@ export function NetscriptCorporation(): InternalAPI { const warehouse = getWarehouse(divisionName, cityName); if (!hasUnlock(CorpUnlockName.SmartSupply)) throw helpers.errorMessage(ctx, `You have not purchased the Smart Supply upgrade!`); - SetSmartSupply(warehouse, enabled); + setSmartSupply(warehouse, enabled); }, setSmartSupplyOption: (ctx) => (_divisionName, _cityName, _materialName, _option) => { checkAccess(ctx, CorpUnlockName.WarehouseAPI); @@ -324,7 +324,7 @@ export function NetscriptCorporation(): InternalAPI { const option = getEnumHelper("SmartSupplyOption").nsGetMember(ctx, _option); if (!hasUnlock(CorpUnlockName.SmartSupply)) throw helpers.errorMessage(ctx, `You have not purchased the Smart Supply upgrade!`); - SetSmartSupplyOption(warehouse, material, option); + setSmartSupplyOption(warehouse, material, option); }, buyMaterial: (ctx) => (_divisionName, _cityName, _materialName, _amt) => { checkAccess(ctx, CorpUnlockName.WarehouseAPI); @@ -337,7 +337,7 @@ export function NetscriptCorporation(): InternalAPI { if (amt < 0 || !Number.isFinite(amt)) throw new Error("Invalid value for amount field! Must be numeric and greater than or equal to 0"); const material = getMaterial(divisionName, cityName, materialName); - BuyMaterial(division, material, amt); + buyMaterial(division, material, amt); }, bulkPurchase: (ctx) => (_divisionName, _cityName, _materialName, _amt) => { checkAccess(ctx, CorpUnlockName.WarehouseAPI); @@ -350,7 +350,7 @@ export function NetscriptCorporation(): InternalAPI { const amt = helpers.number(ctx, "amt", _amt); const warehouse = getWarehouse(divisionName, cityName); const material = getMaterial(divisionName, cityName, materialName); - BulkPurchase(corporation, division, warehouse, material, amt); + bulkPurchase(corporation, division, warehouse, material, amt); }, makeProduct: (ctx) => @@ -362,7 +362,7 @@ export function NetscriptCorporation(): InternalAPI { const designInvest = helpers.number(ctx, "designInvest", _designInvest); const marketingInvest = helpers.number(ctx, "marketingInvest", _marketingInvest); const corporation = getCorporation(); - MakeProduct(corporation, getDivision(divisionName), cityName, productName, designInvest, marketingInvest); + makeProduct(corporation, getDivision(divisionName), cityName, productName, designInvest, marketingInvest); }, limitProductProduction: (ctx) => (_divisionName, _cityName, _productName, _qty) => { checkAccess(ctx, CorpUnlockName.WarehouseAPI); @@ -370,7 +370,7 @@ export function NetscriptCorporation(): InternalAPI { const cityName = getEnumHelper("CityName").nsGetMember(ctx, _cityName); const productName = helpers.string(ctx, "productName", _productName); const qty = helpers.number(ctx, "qty", _qty); - LimitProductProduction(getProduct(divisionName, productName), cityName, qty); + limitProductProduction(getProduct(divisionName, productName), cityName, qty); }, exportMaterial: (ctx) => @@ -386,7 +386,7 @@ export function NetscriptCorporation(): InternalAPI { const materialName = getEnumHelper("CorpMaterialName").nsGetMember(ctx, _materialName, "materialName"); const amt = helpers.string(ctx, "amt", _amt); - ExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt); + exportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt); }, cancelExportMaterial: (ctx) => @@ -400,7 +400,7 @@ export function NetscriptCorporation(): InternalAPI { const targetDivision = helpers.string(ctx, "targetDivision", _targetDivision); const targetCity = getEnumHelper("CityName").nsGetMember(ctx, _targetCity, "targetCity"); const materialName = getEnumHelper("CorpMaterialName").nsGetMember(ctx, _materialName, "materialName"); - CancelExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName)); + cancelExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName)); }, limitMaterialProduction: (ctx) => (_divisionName, _cityName, _materialName, _qty) => { checkAccess(ctx, CorpUnlockName.WarehouseAPI); @@ -408,7 +408,7 @@ export function NetscriptCorporation(): InternalAPI { const cityName = getEnumHelper("CityName").nsGetMember(ctx, _cityName); const materialName = getEnumHelper("CorpMaterialName").nsGetMember(ctx, _materialName, "materialName"); const qty = helpers.number(ctx, "qty", _qty); - LimitMaterialProduction(getMaterial(divisionName, cityName, materialName), qty); + limitMaterialProduction(getMaterial(divisionName, cityName, materialName), qty); }, setMaterialMarketTA1: (ctx) => (_divisionName, _cityName, _materialName, _on) => { checkAccess(ctx, CorpUnlockName.WarehouseAPI); @@ -418,7 +418,7 @@ export function NetscriptCorporation(): InternalAPI { const on = !!_on; if (!getDivision(divisionName).hasResearch("Market-TA.I")) throw helpers.errorMessage(ctx, `You have not researched MarketTA.I for division: ${divisionName}`); - SetMaterialMarketTA1(getMaterial(divisionName, cityName, materialName), on); + setMaterialMarketTA1(getMaterial(divisionName, cityName, materialName), on); }, setMaterialMarketTA2: (ctx) => (_divisionName, _cityName, _materialName, _on) => { checkAccess(ctx, CorpUnlockName.WarehouseAPI); @@ -428,7 +428,7 @@ export function NetscriptCorporation(): InternalAPI { const on = !!_on; if (!getDivision(divisionName).hasResearch("Market-TA.II")) throw helpers.errorMessage(ctx, `You have not researched MarketTA.II for division: ${divisionName}`); - SetMaterialMarketTA2(getMaterial(divisionName, cityName, materialName), on); + setMaterialMarketTA2(getMaterial(divisionName, cityName, materialName), on); }, setProductMarketTA1: (ctx) => (_divisionName, _productName, _on) => { checkAccess(ctx, CorpUnlockName.WarehouseAPI); @@ -437,7 +437,7 @@ export function NetscriptCorporation(): InternalAPI { const on = !!_on; if (!getDivision(divisionName).hasResearch("Market-TA.I")) throw helpers.errorMessage(ctx, `You have not researched MarketTA.I for division: ${divisionName}`); - SetProductMarketTA1(getProduct(divisionName, productName), on); + setProductMarketTA1(getProduct(divisionName, productName), on); }, setProductMarketTA2: (ctx) => (_divisionName, _productName, _on) => { checkAccess(ctx, CorpUnlockName.WarehouseAPI); @@ -446,7 +446,7 @@ export function NetscriptCorporation(): InternalAPI { const on = !!_on; if (!getDivision(divisionName).hasResearch("Market-TA.II")) throw helpers.errorMessage(ctx, `You have not researched MarketTA.II for division: ${divisionName}`); - SetProductMarketTA2(getProduct(divisionName, productName), on); + setProductMarketTA2(getProduct(divisionName, productName), on); }, }; @@ -526,7 +526,7 @@ export function NetscriptCorporation(): InternalAPI { const office = getOffice(divisionName, cityName); const corporation = getCorporation(); - UpgradeOfficeSize(corporation, office, size); + upgradeOfficeSize(corporation, office, size); }, throwParty: (ctx) => (_divisionName, _cityName, _costPerEmployee) => { checkAccess(ctx, CorpUnlockName.OfficeAPI); @@ -540,7 +540,7 @@ export function NetscriptCorporation(): InternalAPI { const corporation = getCorporation(); const office = getOffice(divisionName, cityName); - return ThrowParty(corporation, office, costPerEmployee); + return throwParty(corporation, office, costPerEmployee); }, buyTea: (ctx) => (_divisionName, _cityName) => { checkAccess(ctx, CorpUnlockName.OfficeAPI); @@ -549,19 +549,19 @@ export function NetscriptCorporation(): InternalAPI { const corporation = getCorporation(); const office = getOffice(divisionName, cityName); - return BuyTea(corporation, office); + return buyTea(corporation, office); }, hireAdVert: (ctx) => (_divisionName) => { checkAccess(ctx, CorpUnlockName.OfficeAPI); const divisionName = helpers.string(ctx, "divisionName", _divisionName); const corporation = getCorporation(); - HireAdVert(corporation, getDivision(divisionName)); + hireAdVert(corporation, getDivision(divisionName)); }, research: (ctx) => (_divisionName, _researchName) => { checkAccess(ctx, CorpUnlockName.OfficeAPI); const divisionName = helpers.string(ctx, "divisionName", _divisionName); const researchName = getEnumHelper("CorpResearchName").nsGetMember(ctx, _researchName, "researchName"); - Research(getDivision(divisionName), researchName); + research(getDivision(divisionName), researchName); }, getOffice: (ctx) => (_divisionName, _cityName) => { checkAccess(ctx, CorpUnlockName.OfficeAPI); @@ -611,7 +611,7 @@ export function NetscriptCorporation(): InternalAPI { const industryName = getEnumHelper("IndustryType").nsGetMember(ctx, _industryName, "industryName"); const divisionName = helpers.string(ctx, "divisionName", _divisionName); const corporation = getCorporation(); - NewDivision(corporation, industryName, divisionName); + createDivision(corporation, industryName, divisionName); }, expandCity: (ctx) => (_divisionName, _cityName) => { checkAccess(ctx); @@ -643,7 +643,7 @@ export function NetscriptCorporation(): InternalAPI { throw new Error(`Invalid value for rate field! Must be numeric, greater than 0, and less than ${max}`); const corporation = getCorporation(); if (!corporation.public) throw helpers.errorMessage(ctx, `Your company has not gone public!`); - IssueDividends(corporation, rate); + issueDividends(corporation, rate); }, issueNewShares: (ctx) => (_amount) => { checkAccess(ctx); @@ -651,7 +651,7 @@ export function NetscriptCorporation(): InternalAPI { const maxNewShares = corporation.calculateMaxNewShares(); if (_amount == undefined) _amount = maxNewShares; const amount = helpers.number(ctx, "amount", _amount); - const [funds] = IssueNewShares(corporation, amount); + const [funds] = issueNewShares(corporation, amount); return funds; }, getDivision: (ctx) => (_divisionName) => { @@ -728,7 +728,7 @@ export function NetscriptCorporation(): InternalAPI { checkAccess(ctx); const corporation = getCorporation(); try { - AcceptInvestmentOffer(corporation); + acceptInvestmentOffer(corporation); return true; } catch (err) { return false; @@ -739,18 +739,18 @@ export function NetscriptCorporation(): InternalAPI { const corporation = getCorporation(); if (corporation.public) throw helpers.errorMessage(ctx, "Corporation is already public"); const numShares = helpers.number(ctx, "numShares", _numShares); - GoPublic(corporation, numShares); + goPublic(corporation, numShares); return true; }, sellShares: (ctx) => (_numShares) => { checkAccess(ctx); const numShares = helpers.number(ctx, "numShares", _numShares); - return SellShares(getCorporation(), numShares); + return sellShares(getCorporation(), numShares); }, buyBackShares: (ctx) => (_numShares) => { checkAccess(ctx); const numShares = helpers.number(ctx, "numShares", _numShares); - return BuyBackShares(getCorporation(), numShares); + return buyBackShares(getCorporation(), numShares); }, bribe: (ctx) => (_factionName, _amountCash) => { checkAccess(ctx); diff --git a/src/SaveObject.ts b/src/SaveObject.ts index 5f23c5a52..3c77948c9 100644 --- a/src/SaveObject.ts +++ b/src/SaveObject.ts @@ -36,7 +36,7 @@ import { v2APIBreak } from "./utils/v2APIBreak"; import { Corporation } from "./Corporation/Corporation"; import { Terminal } from "./Terminal"; import { getRecordValues } from "./Types/Record"; -import { ExportMaterial } from "./Corporation/Actions"; +import { exportMaterial } from "./Corporation/Actions"; import { getGoSave, loadGo } from "./Go/SaveLoad"; import { SaveData } from "./types"; import { SaveDataError, canUseBinaryFormat, decodeSaveData, encodeJsonSaveString } from "./utils/SaveDataUtils"; @@ -692,7 +692,7 @@ function evaluateVersionCompatibility(ver: string | number): void { const targetDivision = Player.corporation.divisions.get(originalExport.division); if (!targetDivision) throw new Error(`Target division ${originalExport.division} did not exist`); // Set the export again. ExportMaterial throws on failure - ExportMaterial(targetDivision, originalExport.city, material, originalExport.amount); + exportMaterial(targetDivision, originalExport.city, material, originalExport.amount); } catch (e) { anyExportsFailed = true; // We just need the text error, not a full stack trace diff --git a/test/jest/Corporation.test.ts b/test/jest/Corporation.test.ts index 92aac82c9..3aa3c031a 100644 --- a/test/jest/Corporation.test.ts +++ b/test/jest/Corporation.test.ts @@ -9,11 +9,11 @@ import { import { Player, setPlayer } from "../../src/Player"; import { PlayerObject } from "../../src/PersonObjects/Player/PlayerObject"; import { - AcceptInvestmentOffer, - BuyBackShares, - GoPublic, - IssueNewShares, - SellShares, + acceptInvestmentOffer, + buyBackShares, + goPublic, + issueNewShares, + sellShares, } from "../../src/Corporation/Actions"; describe("Corporation", () => { @@ -87,32 +87,32 @@ describe("Corporation", () => { expectSharesToAddUp(Player.corporation!); }); it("should be preserved by acceptInvestmentOffer", () => { - AcceptInvestmentOffer(corporation); + acceptInvestmentOffer(corporation); expectSharesToAddUp(corporation); }); it("should be preserved by goPublic", () => { const numShares = 1e8; - GoPublic(corporation, numShares); + goPublic(corporation, numShares); expectSharesToAddUp(corporation); }); it("should be preserved by IssueNewShares", () => { const numShares = 1e8; - GoPublic(corporation, numShares); + goPublic(corporation, numShares); corporation.issueNewSharesCooldown = 0; - IssueNewShares(corporation, numShares); + issueNewShares(corporation, numShares); expectSharesToAddUp(corporation); }); it("should be preserved by BuyBackShares", () => { const numShares = 1e8; - GoPublic(corporation, numShares); - BuyBackShares(corporation, numShares); + goPublic(corporation, numShares); + buyBackShares(corporation, numShares); expectSharesToAddUp(corporation); }); it("should be preserved by SellShares", () => { const numShares = 1e8; - GoPublic(corporation, numShares); + goPublic(corporation, numShares); corporation.shareSaleCooldown = 0; - SellShares(corporation, numShares); + sellShares(corporation, numShares); expectSharesToAddUp(corporation); }); });