mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-21 23:23:51 +01:00
CORPORATION: Rename functions in Actions.ts (#1272)
This should be a straight rename, no functionality changes.
This commit is contained in:
parent
7f5bc5700e
commit
25afecc0ec
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
<ButtonWithTooltip
|
||||
normalTooltip={"Provide your employees with tea to increase their energy"}
|
||||
disabledTooltip={teaDisabledText}
|
||||
onClick={() => BuyTea(corp, props.office)}
|
||||
onClick={() => buyTea(corp, props.office)}
|
||||
>
|
||||
{props.office.teaPending ? (
|
||||
"Buying Tea"
|
||||
|
@ -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();
|
||||
}}
|
||||
>
|
||||
|
@ -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;
|
||||
|
@ -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(
|
||||
<>
|
||||
<Typography>
|
||||
|
@ -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 + "");
|
||||
}
|
||||
|
@ -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(
|
||||
<>
|
||||
<Typography>You accepted the investment offer.</Typography>
|
||||
|
@ -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(
|
||||
<Typography>
|
||||
<b>{corp.name}</b> went public and earned <Money money={shares * initialSharePrice} /> in its IPO.
|
||||
|
@ -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 + "");
|
||||
}
|
||||
|
@ -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(
|
||||
<>
|
||||
<Typography>
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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 + "");
|
||||
}
|
||||
|
@ -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 + "");
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 + "");
|
||||
}
|
||||
|
@ -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 + "");
|
||||
}
|
||||
|
@ -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(
|
||||
<>
|
||||
<Typography>
|
||||
|
@ -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<HTMLInputElement>): void {
|
||||
SetSmartSupply(props.warehouse, e.target.checked);
|
||||
setSmartSupply(props.warehouse, e.target.checked);
|
||||
rerender();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
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<NSCorporation> {
|
||||
checkAccess(ctx);
|
||||
const corporation = getCorporation();
|
||||
try {
|
||||
AcceptInvestmentOffer(corporation);
|
||||
acceptInvestmentOffer(corporation);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
@ -739,18 +739,18 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
||||
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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user