mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 07:33:48 +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;
|
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)
|
if (corporation.divisions.size >= corporation.maxDivisions)
|
||||||
throw new Error(`Cannot expand into ${industry} industry, too many divisions!`);
|
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;
|
++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) {
|
if (isNaN(rate) || rate < 0 || rate > corpConstants.dividendMaxRate) {
|
||||||
throw new Error(`Invalid value. Must be an number between 0 and ${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;
|
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 ceoOwnership = (corporation.numShares - numShares) / corporation.totalShares;
|
||||||
const initialSharePrice = corporation.getTargetSharePrice(ceoOwnership);
|
const initialSharePrice = corporation.getTargetSharePrice(ceoOwnership);
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ export function GoPublic(corporation: Corporation, numShares: number): void {
|
|||||||
corporation.gainFunds(numShares * initialSharePrice, "public equity");
|
corporation.gainFunds(numShares * initialSharePrice, "public equity");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function IssueNewShares(
|
export function issueNewShares(
|
||||||
corporation: Corporation,
|
corporation: Corporation,
|
||||||
amount: number,
|
amount: number,
|
||||||
): [profit: number, amount: number, privateShares: number] {
|
): [profit: number, amount: number, privateShares: number] {
|
||||||
@ -178,7 +178,7 @@ export function IssueNewShares(
|
|||||||
return [profit, amount, privateShares];
|
return [profit, amount, privateShares];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AcceptInvestmentOffer(corporation: Corporation): void {
|
export function acceptInvestmentOffer(corporation: Corporation): void {
|
||||||
if (
|
if (
|
||||||
corporation.fundingRound >= corpConstants.fundingRoundShares.length ||
|
corporation.fundingRound >= corpConstants.fundingRoundShares.length ||
|
||||||
corporation.fundingRound >= corpConstants.fundingRoundMultiplier.length ||
|
corporation.fundingRound >= corpConstants.fundingRoundMultiplier.length ||
|
||||||
@ -198,7 +198,7 @@ export function AcceptInvestmentOffer(corporation: Corporation): void {
|
|||||||
corporation.investorShares += investShares;
|
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 (price === "") price = "0";
|
||||||
if (amount === "") amount = "0";
|
if (amount === "") amount = "0";
|
||||||
let cost = price.replace(/\s+/g, "");
|
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
|
//Parse price
|
||||||
// initliaze newPrice with oldPrice as default
|
// initliaze newPrice with oldPrice as default
|
||||||
let newPrice = product.cityData[city].desiredSellPrice;
|
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;
|
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;
|
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)) {
|
if (!isRelevantMaterial(material.name, division)) {
|
||||||
throw new Error(`${material.name} is not a relevant material for industry ${division.type}`);
|
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;
|
material.buyAmount = amt;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BulkPurchase(
|
export function bulkPurchase(
|
||||||
corp: Corporation,
|
corp: Corporation,
|
||||||
division: Division,
|
division: Division,
|
||||||
warehouse: Warehouse,
|
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);
|
const failureReason = sellSharesFailureReason(corporation, numShares);
|
||||||
if (failureReason) throw new Error(failureReason);
|
if (failureReason) throw new Error(failureReason);
|
||||||
|
|
||||||
@ -383,7 +383,7 @@ export function SellShares(corporation: Corporation, numShares: number): number
|
|||||||
return profit;
|
return profit;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BuyBackShares(corporation: Corporation, numShares: number): boolean {
|
export function buyBackShares(corporation: Corporation, numShares: number): boolean {
|
||||||
const failureReason = buybackSharesFailureReason(corporation, numShares);
|
const failureReason = buybackSharesFailureReason(corporation, numShares);
|
||||||
if (failureReason) throw new Error(failureReason);
|
if (failureReason) throw new Error(failureReason);
|
||||||
|
|
||||||
@ -397,21 +397,21 @@ export function BuyBackShares(corporation: Corporation, numShares: number): bool
|
|||||||
return true;
|
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);
|
const cost = calculateOfficeSizeUpgradeCost(office.size, increase);
|
||||||
if (corp.funds < cost) return;
|
if (corp.funds < cost) return;
|
||||||
office.size += increase;
|
office.size += increase;
|
||||||
corp.loseFunds(cost, "office");
|
corp.loseFunds(cost, "office");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BuyTea(corp: Corporation, office: OfficeSpace): boolean {
|
export function buyTea(corp: Corporation, office: OfficeSpace): boolean {
|
||||||
const cost = office.getTeaCost();
|
const cost = office.getTeaCost();
|
||||||
if (corp.funds < cost || !office.setTea()) return false;
|
if (corp.funds < cost || !office.setTea()) return false;
|
||||||
corp.loseFunds(cost, "tea");
|
corp.loseFunds(cost, "tea");
|
||||||
return true;
|
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 mult = 1 + costPerEmployee / 10e6;
|
||||||
const cost = costPerEmployee * office.numEmployees;
|
const cost = costPerEmployee * office.numEmployees;
|
||||||
if (corp.funds < cost) {
|
if (corp.funds < cost) {
|
||||||
@ -438,29 +438,29 @@ export function purchaseWarehouse(corp: Corporation, division: Division, city: C
|
|||||||
++corp.numberOfOfficesAndWarehouses;
|
++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(
|
return Array.from(Array(amt).keys()).reduce(
|
||||||
(acc, index) => acc + corpConstants.warehouseSizeUpgradeCostBase * Math.pow(1.07, warehouse.level + 1 + index),
|
(acc, index) => acc + corpConstants.warehouseSizeUpgradeCostBase * Math.pow(1.07, warehouse.level + 1 + index),
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UpgradeWarehouse(corp: Corporation, division: Division, warehouse: Warehouse, amt = 1): void {
|
export function upgradeWarehouse(corp: Corporation, division: Division, warehouse: Warehouse, amt = 1): void {
|
||||||
const sizeUpgradeCost = UpgradeWarehouseCost(warehouse, amt);
|
const sizeUpgradeCost = upgradeWarehouseCost(warehouse, amt);
|
||||||
if (corp.funds < sizeUpgradeCost) return;
|
if (corp.funds < sizeUpgradeCost) return;
|
||||||
warehouse.level += amt;
|
warehouse.level += amt;
|
||||||
warehouse.updateSize(corp, division);
|
warehouse.updateSize(corp, division);
|
||||||
corp.loseFunds(sizeUpgradeCost, "warehouse");
|
corp.loseFunds(sizeUpgradeCost, "warehouse");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HireAdVert(corp: Corporation, division: Division): void {
|
export function hireAdVert(corp: Corporation, division: Division): void {
|
||||||
const cost = division.getAdVertCost();
|
const cost = division.getAdVertCost();
|
||||||
if (corp.funds < cost) return;
|
if (corp.funds < cost) return;
|
||||||
corp.loseFunds(cost, "advert");
|
corp.loseFunds(cost, "advert");
|
||||||
division.applyAdVert(corp);
|
division.applyAdVert(corp);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MakeProduct(
|
export function makeProduct(
|
||||||
corp: Corporation,
|
corp: Corporation,
|
||||||
division: Division,
|
division: Division,
|
||||||
city: CityName,
|
city: CityName,
|
||||||
@ -502,7 +502,7 @@ export function MakeProduct(
|
|||||||
division.products.set(product.name, product);
|
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;
|
const corp = Player.corporation;
|
||||||
if (!corp) return;
|
if (!corp) return;
|
||||||
const researchTree = IndustryResearchTrees[researchingDivision.type];
|
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. */
|
/** Set a new export for a material. Throw on any invalid input. */
|
||||||
export function ExportMaterial(
|
export function exportMaterial(
|
||||||
targetDivision: Division,
|
targetDivision: Division,
|
||||||
targetCity: CityName,
|
targetCity: CityName,
|
||||||
material: Material,
|
material: Material,
|
||||||
@ -592,13 +592,13 @@ Error encountered: ${error}`);
|
|||||||
material.exports.push(exportObj);
|
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);
|
const index = material.exports.findIndex((exp) => exp.division === divisionName && exp.city === cityName);
|
||||||
if (index === -1) return;
|
if (index === -1) return;
|
||||||
material.exports.splice(index, 1);
|
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)) {
|
if (quantity < 0 || isNaN(quantity)) {
|
||||||
product.cityData[cityName].productionLimit = null;
|
product.cityData[cityName].productionLimit = null;
|
||||||
} else {
|
} 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)) {
|
if (quantity < 0 || isNaN(quantity)) {
|
||||||
material.productionLimit = null;
|
material.productionLimit = null;
|
||||||
} else {
|
} 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;
|
material.marketTa1 = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SetMaterialMarketTA2(material: Material, on: boolean): void {
|
export function setMaterialMarketTA2(material: Material, on: boolean): void {
|
||||||
material.marketTa2 = on;
|
material.marketTa2 = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SetProductMarketTA1(product: Product, on: boolean): void {
|
export function setProductMarketTA1(product: Product, on: boolean): void {
|
||||||
product.marketTa1 = on;
|
product.marketTa1 = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SetProductMarketTA2(product: Product, on: boolean): void {
|
export function setProductMarketTA2(product: Product, on: boolean): void {
|
||||||
product.marketTa2 = on;
|
product.marketTa2 = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import React, { useState } from "react";
|
|||||||
|
|
||||||
import { OfficeSpace } from "../OfficeSpace";
|
import { OfficeSpace } from "../OfficeSpace";
|
||||||
import { CorpUnlockName, CorpEmployeeJob, CorpUpgradeName, CorpProductResearchName } from "@enums";
|
import { CorpUnlockName, CorpEmployeeJob, CorpUpgradeName, CorpProductResearchName } from "@enums";
|
||||||
import { BuyTea } from "../Actions";
|
import { buyTea } from "../Actions";
|
||||||
|
|
||||||
import { MoneyCost } from "./MoneyCost";
|
import { MoneyCost } from "./MoneyCost";
|
||||||
import { formatBigNumber, formatCorpStat, formatCorpMultiplier } from "../../ui/formatNumber";
|
import { formatBigNumber, formatCorpStat, formatCorpMultiplier } from "../../ui/formatNumber";
|
||||||
@ -375,7 +375,7 @@ export function DivisionOffice(props: OfficeProps): React.ReactElement {
|
|||||||
<ButtonWithTooltip
|
<ButtonWithTooltip
|
||||||
normalTooltip={"Provide your employees with tea to increase their energy"}
|
normalTooltip={"Provide your employees with tea to increase their energy"}
|
||||||
disabledTooltip={teaDisabledText}
|
disabledTooltip={teaDisabledText}
|
||||||
onClick={() => BuyTea(corp, props.office)}
|
onClick={() => buyTea(corp, props.office)}
|
||||||
>
|
>
|
||||||
{props.office.teaPending ? (
|
{props.office.teaPending ? (
|
||||||
"Buying Tea"
|
"Buying Tea"
|
||||||
|
@ -4,7 +4,7 @@ import React, { useState } from "react";
|
|||||||
import { MathJax } from "better-react-mathjax";
|
import { MathJax } from "better-react-mathjax";
|
||||||
|
|
||||||
import { CorpUnlockName, IndustryType } from "@enums";
|
import { CorpUnlockName, IndustryType } from "@enums";
|
||||||
import { HireAdVert } from "../Actions";
|
import { hireAdVert } from "../Actions";
|
||||||
import { formatBigNumber, formatCorpMultiplier } from "../../ui/formatNumber";
|
import { formatBigNumber, formatCorpMultiplier } from "../../ui/formatNumber";
|
||||||
import { createProgressBarText } from "../../utils/helpers/createProgressBarText";
|
import { createProgressBarText } from "../../utils/helpers/createProgressBarText";
|
||||||
import { MakeProductModal } from "./modals/MakeProductModal";
|
import { MakeProductModal } from "./modals/MakeProductModal";
|
||||||
@ -226,7 +226,7 @@ export function DivisionOverview(props: DivisionOverviewProps): React.ReactEleme
|
|||||||
}
|
}
|
||||||
disabledTooltip={division.getAdVertCost() > corp.funds ? "Insufficient corporation funds" : ""}
|
disabledTooltip={division.getAdVertCost() > corp.funds ? "Insufficient corporation funds" : ""}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
HireAdVert(corp, division);
|
hireAdVert(corp, division);
|
||||||
props.rerender();
|
props.rerender();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -10,7 +10,7 @@ import { dialogBoxCreate } from "../../ui/React/DialogBox";
|
|||||||
import { IndustriesData } from "../data/IndustryData";
|
import { IndustriesData } from "../data/IndustryData";
|
||||||
import { IndustryType } from "@enums";
|
import { IndustryType } from "@enums";
|
||||||
import { useCorporation } from "./Context";
|
import { useCorporation } from "./Context";
|
||||||
import { NewDivision } from "../Actions";
|
import { createDivision } from "../Actions";
|
||||||
|
|
||||||
import { ButtonWithTooltip } from "../../ui/Components/ButtonWithTooltip";
|
import { ButtonWithTooltip } from "../../ui/Components/ButtonWithTooltip";
|
||||||
import { KEY } from "../../utils/helpers/keyCodes";
|
import { KEY } from "../../utils/helpers/keyCodes";
|
||||||
@ -38,7 +38,7 @@ export function NewDivisionTab(props: IProps): React.ReactElement {
|
|||||||
function newDivision(): void {
|
function newDivision(): void {
|
||||||
if (disabledText) return;
|
if (disabledText) return;
|
||||||
try {
|
try {
|
||||||
NewDivision(corp, industry, name);
|
createDivision(corp, industry, name);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
return;
|
return;
|
||||||
|
@ -7,7 +7,7 @@ import { useCorporation } from "../Context";
|
|||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { ButtonWithTooltip } from "../../../ui/Components/ButtonWithTooltip";
|
import { ButtonWithTooltip } from "../../../ui/Components/ButtonWithTooltip";
|
||||||
import { NumberInput } from "../../../ui/React/NumberInput";
|
import { NumberInput } from "../../../ui/React/NumberInput";
|
||||||
import { BuyBackShares } from "../../Actions";
|
import { buyBackShares } from "../../Actions";
|
||||||
import { KEY } from "../../../utils/helpers/keyCodes";
|
import { KEY } from "../../../utils/helpers/keyCodes";
|
||||||
import { buybackSharesFailureReason } from "../../helpers";
|
import { buybackSharesFailureReason } from "../../helpers";
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ export function BuybackSharesModal(props: IProps): React.ReactElement {
|
|||||||
function buy(): void {
|
function buy(): void {
|
||||||
if (disabledText) return;
|
if (disabledText) return;
|
||||||
try {
|
try {
|
||||||
BuyBackShares(corp, shares);
|
buyBackShares(corp, shares);
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
<>
|
<>
|
||||||
<Typography>
|
<Typography>
|
||||||
|
@ -4,7 +4,7 @@ import { dialogBoxCreate } from "../../../ui/React/DialogBox";
|
|||||||
import { Material } from "../../Material";
|
import { Material } from "../../Material";
|
||||||
import { Export } from "../../Export";
|
import { Export } from "../../Export";
|
||||||
import { Division } from "../../Division";
|
import { Division } from "../../Division";
|
||||||
import { ExportMaterial } from "../../Actions";
|
import * as actions from "../../Actions";
|
||||||
import { Modal } from "../../../ui/React/Modal";
|
import { Modal } from "../../../ui/React/Modal";
|
||||||
import { useCorporation } from "../Context";
|
import { useCorporation } from "../Context";
|
||||||
import { isRelevantMaterial } from "../Helpers";
|
import { isRelevantMaterial } from "../Helpers";
|
||||||
@ -58,7 +58,7 @@ export function ExportModal(props: ExportModalProps): React.ReactElement {
|
|||||||
function exportMaterial(): void {
|
function exportMaterial(): void {
|
||||||
try {
|
try {
|
||||||
if (!targetDivision || !targetCity) return;
|
if (!targetDivision || !targetCity) return;
|
||||||
ExportMaterial(targetDivision, targetCity, props.mat, exportAmount);
|
actions.exportMaterial(targetDivision, targetCity, props.mat, exportAmount);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { formatPercent, formatShares } from "../../../ui/formatNumber";
|
|||||||
import { Modal } from "../../../ui/React/Modal";
|
import { Modal } from "../../../ui/React/Modal";
|
||||||
import { Money } from "../../../ui/React/Money";
|
import { Money } from "../../../ui/React/Money";
|
||||||
import { useCorporation } from "../Context";
|
import { useCorporation } from "../Context";
|
||||||
import { AcceptInvestmentOffer } from "../../Actions";
|
import { acceptInvestmentOffer } from "../../Actions";
|
||||||
|
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
@ -23,7 +23,7 @@ export function FindInvestorsModal(props: IProps): React.ReactElement {
|
|||||||
function findInvestors(): void {
|
function findInvestors(): void {
|
||||||
if (shares === 0) return;
|
if (shares === 0) return;
|
||||||
try {
|
try {
|
||||||
AcceptInvestmentOffer(corp);
|
acceptInvestmentOffer(corp);
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
<>
|
<>
|
||||||
<Typography>You accepted the investment offer.</Typography>
|
<Typography>You accepted the investment offer.</Typography>
|
||||||
|
@ -10,7 +10,7 @@ import { NumberInput } from "../../../ui/React/NumberInput";
|
|||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import { KEY } from "../../../utils/helpers/keyCodes";
|
import { KEY } from "../../../utils/helpers/keyCodes";
|
||||||
import { isPositiveInteger } from "../../../types";
|
import { isPositiveInteger } from "../../../types";
|
||||||
import { GoPublic } from "../../Actions";
|
import * as actions from "../../Actions";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -36,7 +36,7 @@ export function GoPublicModal(props: IProps): React.ReactElement {
|
|||||||
function goPublic(): void {
|
function goPublic(): void {
|
||||||
if (disabledText) return;
|
if (disabledText) return;
|
||||||
try {
|
try {
|
||||||
GoPublic(corp, shares);
|
actions.goPublic(corp, shares);
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
<Typography>
|
<Typography>
|
||||||
<b>{corp.name}</b> went public and earned <Money money={shares * initialSharePrice} /> in its IPO.
|
<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 { Money } from "../../../ui/React/Money";
|
||||||
import { MoneyRate } from "../../../ui/React/MoneyRate";
|
import { MoneyRate } from "../../../ui/React/MoneyRate";
|
||||||
import * as corpConstants from "../../data/Constants";
|
import * as corpConstants from "../../data/Constants";
|
||||||
import { IssueDividends } from "../../Actions";
|
import * as actions from "../../Actions";
|
||||||
import { useCorporation } from "../Context";
|
import { useCorporation } from "../Context";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
@ -26,7 +26,7 @@ export function IssueDividendsModal(props: IProps): React.ReactElement {
|
|||||||
if (!canIssue) return;
|
if (!canIssue) return;
|
||||||
if (percent === null) return;
|
if (percent === null) return;
|
||||||
try {
|
try {
|
||||||
IssueDividends(corp, percent / 100);
|
actions.issueDividends(corp, percent / 100);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import Typography from "@mui/material/Typography";
|
|||||||
import { NumberInput } from "../../../ui/React/NumberInput";
|
import { NumberInput } from "../../../ui/React/NumberInput";
|
||||||
import { ButtonWithTooltip } from "../../../ui/Components/ButtonWithTooltip";
|
import { ButtonWithTooltip } from "../../../ui/Components/ButtonWithTooltip";
|
||||||
import { KEY } from "../../../utils/helpers/keyCodes";
|
import { KEY } from "../../../utils/helpers/keyCodes";
|
||||||
import { IssueNewShares } from "../../Actions";
|
import * as actions from "../../Actions";
|
||||||
import * as corpConstants from "../../data/Constants";
|
import * as corpConstants from "../../data/Constants";
|
||||||
import { issueNewSharesFailureReason } from "../../helpers";
|
import { issueNewSharesFailureReason } from "../../helpers";
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ export function IssueNewSharesModal(props: IProps): React.ReactElement {
|
|||||||
function issueNewShares(): void {
|
function issueNewShares(): void {
|
||||||
if (disabledText) return;
|
if (disabledText) return;
|
||||||
try {
|
try {
|
||||||
const [profit, newShares, privateShares] = IssueNewShares(corp, shares);
|
const [profit, newShares, privateShares] = actions.issueNewShares(corp, shares);
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
<>
|
<>
|
||||||
<Typography>
|
<Typography>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { LimitMaterialProduction } from "../../Actions";
|
import * as actions from "../../Actions";
|
||||||
import { Modal } from "../../../ui/React/Modal";
|
import { Modal } from "../../../ui/React/Modal";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
@ -27,7 +27,7 @@ export function LimitMaterialProductionModal(props: IProps): React.ReactElement
|
|||||||
function limitMaterialProduction(): void {
|
function limitMaterialProduction(): void {
|
||||||
let qty = limit;
|
let qty = limit;
|
||||||
if (qty === null) qty = -1;
|
if (qty === null) qty = -1;
|
||||||
LimitMaterialProduction(props.material, qty);
|
actions.limitMaterialProduction(props.material, qty);
|
||||||
props.onClose();
|
props.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import type { CityName } from "@enums";
|
import type { CityName } from "@enums";
|
||||||
import type { Product } from "../../Product";
|
import type { Product } from "../../Product";
|
||||||
import { LimitProductProduction } from "../../Actions";
|
import * as actions from "../../Actions";
|
||||||
import { Modal } from "../../../ui/React/Modal";
|
import { Modal } from "../../../ui/React/Modal";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
@ -29,7 +29,7 @@ export function LimitProductProductionModal(props: IProps): React.ReactElement {
|
|||||||
function limitProductProduction(): void {
|
function limitProductProduction(): void {
|
||||||
let qty = limit;
|
let qty = limit;
|
||||||
if (qty === null) qty = -1;
|
if (qty === null) qty = -1;
|
||||||
LimitProductProduction(props.product, props.city, qty);
|
actions.limitProductProduction(props.product, props.city, qty);
|
||||||
props.onClose();
|
props.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { dialogBoxCreate } from "../../../ui/React/DialogBox";
|
|||||||
import { Modal } from "../../../ui/React/Modal";
|
import { Modal } from "../../../ui/React/Modal";
|
||||||
import { IndustriesData } from "../../data/IndustryData";
|
import { IndustriesData } from "../../data/IndustryData";
|
||||||
import { IndustryType } from "@enums";
|
import { IndustryType } from "@enums";
|
||||||
import { MakeProduct } from "../../Actions";
|
import * as actions from "../../Actions";
|
||||||
import { useCorporation, useDivision } from "../Context";
|
import { useCorporation, useDivision } from "../Context";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
@ -46,7 +46,7 @@ export function MakeProductModal(props: IProps): React.ReactElement {
|
|||||||
function makeProduct(): void {
|
function makeProduct(): void {
|
||||||
if (isNaN(design) || isNaN(marketing)) return;
|
if (isNaN(design) || isNaN(marketing)) return;
|
||||||
try {
|
try {
|
||||||
MakeProduct(corp, division, city, name, design, marketing);
|
actions.makeProduct(corp, division, city, name, design, marketing);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { MaterialInfo } from "../../MaterialInfo";
|
|||||||
import { Warehouse } from "../../Warehouse";
|
import { Warehouse } from "../../Warehouse";
|
||||||
import { Material } from "../../Material";
|
import { Material } from "../../Material";
|
||||||
import { formatMatPurchaseAmount } from "../../../ui/formatNumber";
|
import { formatMatPurchaseAmount } from "../../../ui/formatNumber";
|
||||||
import { BulkPurchase, BuyMaterial } from "../../Actions";
|
import * as actions from "../../Actions";
|
||||||
import { Modal } from "../../../ui/React/Modal";
|
import { Modal } from "../../../ui/React/Modal";
|
||||||
import { Money } from "../../../ui/React/Money";
|
import { Money } from "../../../ui/React/Money";
|
||||||
import { useCorporation, useDivision } from "../Context";
|
import { useCorporation, useDivision } from "../Context";
|
||||||
@ -66,7 +66,7 @@ function BulkPurchaseSection(props: IBPProps): React.ReactElement {
|
|||||||
|
|
||||||
function bulkPurchase(): void {
|
function bulkPurchase(): void {
|
||||||
try {
|
try {
|
||||||
BulkPurchase(corp, division, props.warehouse, props.mat, parseFloat(buyAmt));
|
actions.bulkPurchase(corp, division, props.warehouse, props.mat, parseFloat(buyAmt));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ export function PurchaseMaterialModal(props: IProps): React.ReactElement {
|
|||||||
function purchaseMaterial(): void {
|
function purchaseMaterial(): void {
|
||||||
if (buyAmt === null) return;
|
if (buyAmt === null) return;
|
||||||
try {
|
try {
|
||||||
BuyMaterial(division, props.mat, buyAmt);
|
actions.buyMaterial(division, props.mat, buyAmt);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import { formatCorpMultiplier } from "../../../ui/formatNumber";
|
|||||||
import { IndustryResearchTrees } from "../../data/IndustryData";
|
import { IndustryResearchTrees } from "../../data/IndustryData";
|
||||||
import * as corpConstants from "../../data/Constants";
|
import * as corpConstants from "../../data/Constants";
|
||||||
import { Division } from "../../Division";
|
import { Division } from "../../Division";
|
||||||
import { Research } from "../../Actions";
|
import * as actions from "../../Actions";
|
||||||
import { Node } from "../../ResearchTree";
|
import { Node } from "../../ResearchTree";
|
||||||
import { ResearchMap } from "../../ResearchMap";
|
import { ResearchMap } from "../../ResearchMap";
|
||||||
import { Settings } from "../../../Settings/Settings";
|
import { Settings } from "../../../Settings/Settings";
|
||||||
@ -38,7 +38,7 @@ function Upgrade({ n, division }: INodeProps): React.ReactElement {
|
|||||||
function research(): void {
|
function research(): void {
|
||||||
if (n === null || disabled) return;
|
if (n === null || disabled) return;
|
||||||
try {
|
try {
|
||||||
Research(division, n.researchName);
|
actions.research(division, n.researchName);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
return;
|
return;
|
||||||
|
@ -6,7 +6,7 @@ import { Button, FormControlLabel, Switch, TextField, Tooltip, Typography } from
|
|||||||
import { Modal } from "../../../ui/React/Modal";
|
import { Modal } from "../../../ui/React/Modal";
|
||||||
import { dialogBoxCreate } from "../../../ui/React/DialogBox";
|
import { dialogBoxCreate } from "../../../ui/React/DialogBox";
|
||||||
|
|
||||||
import { SellMaterial } from "../../Actions";
|
import * as actions from "../../Actions";
|
||||||
import { KEY } from "../../../utils/helpers/keyCodes";
|
import { KEY } from "../../../utils/helpers/keyCodes";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
@ -23,7 +23,7 @@ export function SellMaterialModal(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
function sellMaterial(): void {
|
function sellMaterial(): void {
|
||||||
try {
|
try {
|
||||||
SellMaterial(props.mat, amt, price);
|
actions.sellMaterial(props.mat, amt, price);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import { Button, FormControlLabel, Switch, TextField, Tooltip, Typography } from
|
|||||||
import { Modal } from "../../../ui/React/Modal";
|
import { Modal } from "../../../ui/React/Modal";
|
||||||
import { dialogBoxCreate } from "../../../ui/React/DialogBox";
|
import { dialogBoxCreate } from "../../../ui/React/DialogBox";
|
||||||
|
|
||||||
import { SellProduct } from "../../Actions";
|
import * as actions from "../../Actions";
|
||||||
import { KEY } from "../../../utils/helpers/keyCodes";
|
import { KEY } from "../../../utils/helpers/keyCodes";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
@ -30,7 +30,7 @@ export function SellProductModal(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
function sellProduct(): void {
|
function sellProduct(): void {
|
||||||
try {
|
try {
|
||||||
SellProduct(props.product, props.city, iQty, px, checked);
|
actions.sellProduct(props.product, props.city, iQty, px, checked);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import { useCorporation } from "../Context";
|
|||||||
import * as corpConstants from "../../data/Constants";
|
import * as corpConstants from "../../data/Constants";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { ButtonWithTooltip } from "../../../ui/Components/ButtonWithTooltip";
|
import { ButtonWithTooltip } from "../../../ui/Components/ButtonWithTooltip";
|
||||||
import { SellShares } from "../../Actions";
|
import { sellShares } from "../../Actions";
|
||||||
import { KEY } from "../../../utils/helpers/keyCodes";
|
import { KEY } from "../../../utils/helpers/keyCodes";
|
||||||
import { NumberInput } from "../../../ui/React/NumberInput";
|
import { NumberInput } from "../../../ui/React/NumberInput";
|
||||||
import { sellSharesFailureReason } from "../../helpers";
|
import { sellSharesFailureReason } from "../../helpers";
|
||||||
@ -30,7 +30,7 @@ export function SellSharesModal(props: IProps): React.ReactElement {
|
|||||||
function sell(): void {
|
function sell(): void {
|
||||||
if (disabledText) return;
|
if (disabledText) return;
|
||||||
try {
|
try {
|
||||||
SellShares(corp, shares);
|
sellShares(corp, shares);
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
<>
|
<>
|
||||||
<Typography>
|
<Typography>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
|
||||||
import { Warehouse } from "../../Warehouse";
|
import { Warehouse } from "../../Warehouse";
|
||||||
import { SetSmartSupply, SetSmartSupplyOption } from "../../Actions";
|
import { setSmartSupply, setSmartSupplyOption } from "../../Actions";
|
||||||
import { dialogBoxCreate } from "../../../ui/React/DialogBox";
|
import { dialogBoxCreate } from "../../../ui/React/DialogBox";
|
||||||
import { Modal } from "../../../ui/React/Modal";
|
import { Modal } from "../../../ui/React/Modal";
|
||||||
import { useDivision } from "../Context";
|
import { useDivision } from "../Context";
|
||||||
@ -26,7 +26,7 @@ function SSoption(props: ISSoptionProps): React.ReactElement {
|
|||||||
try {
|
try {
|
||||||
const matName = props.matName;
|
const matName = props.matName;
|
||||||
const material = props.warehouse.materials[matName];
|
const material = props.warehouse.materials[matName];
|
||||||
SetSmartSupplyOption(props.warehouse, material, newValue);
|
setSmartSupplyOption(props.warehouse, material, newValue);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ function SSoption(props: ISSoptionProps): React.ReactElement {
|
|||||||
try {
|
try {
|
||||||
const matName = props.matName;
|
const matName = props.matName;
|
||||||
const material = props.warehouse.materials[matName];
|
const material = props.warehouse.materials[matName];
|
||||||
SetSmartSupplyOption(props.warehouse, material, newValue);
|
setSmartSupplyOption(props.warehouse, material, newValue);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ export function SmartSupplyModal(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
// Smart Supply Checkbox
|
// Smart Supply Checkbox
|
||||||
function smartSupplyOnChange(e: React.ChangeEvent<HTMLInputElement>): void {
|
function smartSupplyOnChange(e: React.ChangeEvent<HTMLInputElement>): void {
|
||||||
SetSmartSupply(props.warehouse, e.target.checked);
|
setSmartSupply(props.warehouse, e.target.checked);
|
||||||
rerender();
|
rerender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import React, { useState } from "react";
|
|||||||
import { formatMultiplier, formatPercent } from "../../../ui/formatNumber";
|
import { formatMultiplier, formatPercent } from "../../../ui/formatNumber";
|
||||||
import { dialogBoxCreate } from "../../../ui/React/DialogBox";
|
import { dialogBoxCreate } from "../../../ui/React/DialogBox";
|
||||||
import { OfficeSpace } from "../../OfficeSpace";
|
import { OfficeSpace } from "../../OfficeSpace";
|
||||||
import { ThrowParty } from "../../Actions";
|
import * as actions from "../../Actions";
|
||||||
import { MoneyCost } from "../MoneyCost";
|
import { MoneyCost } from "../MoneyCost";
|
||||||
import { Modal } from "../../../ui/React/Modal";
|
import { Modal } from "../../../ui/React/Modal";
|
||||||
import { useCorporation } from "../Context";
|
import { useCorporation } from "../Context";
|
||||||
@ -37,7 +37,7 @@ export function ThrowPartyModal(props: IProps): React.ReactElement {
|
|||||||
} else if (!canParty) {
|
} else if (!canParty) {
|
||||||
dialogBoxCreate("You don't have enough company funds to throw a party!");
|
dialogBoxCreate("You don't have enough company funds to throw a party!");
|
||||||
} else {
|
} 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.
|
// 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;
|
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 * as corpConstants from "../../data/Constants";
|
||||||
import { OfficeSpace } from "../../OfficeSpace";
|
import { OfficeSpace } from "../../OfficeSpace";
|
||||||
import { Corporation } from "../../Corporation";
|
import { Corporation } from "../../Corporation";
|
||||||
import { UpgradeOfficeSize } from "../../Actions";
|
import { upgradeOfficeSize } from "../../Actions";
|
||||||
import { Modal } from "../../../ui/React/Modal";
|
import { Modal } from "../../../ui/React/Modal";
|
||||||
import { useCorporation } from "../Context";
|
import { useCorporation } from "../Context";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
@ -29,7 +29,7 @@ function UpgradeSizeButton(props: IUpgradeButton): React.ReactElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpgradeOfficeSize(corp, props.office, increase);
|
upgradeOfficeSize(corp, props.office, increase);
|
||||||
props.rerender();
|
props.rerender();
|
||||||
props.onClose();
|
props.onClose();
|
||||||
}
|
}
|
||||||
|
@ -19,37 +19,37 @@ import {
|
|||||||
} from "@nsdefs";
|
} from "@nsdefs";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NewDivision,
|
createDivision,
|
||||||
purchaseOffice,
|
purchaseOffice,
|
||||||
IssueDividends,
|
issueDividends,
|
||||||
GoPublic,
|
goPublic,
|
||||||
IssueNewShares,
|
issueNewShares,
|
||||||
AcceptInvestmentOffer,
|
acceptInvestmentOffer,
|
||||||
SellMaterial,
|
sellMaterial,
|
||||||
SellProduct,
|
sellProduct,
|
||||||
SetSmartSupply,
|
setSmartSupply,
|
||||||
BuyMaterial,
|
buyMaterial,
|
||||||
UpgradeOfficeSize,
|
upgradeOfficeSize,
|
||||||
purchaseWarehouse,
|
purchaseWarehouse,
|
||||||
UpgradeWarehouse,
|
upgradeWarehouse,
|
||||||
BuyTea,
|
buyTea,
|
||||||
ThrowParty,
|
throwParty,
|
||||||
HireAdVert,
|
hireAdVert,
|
||||||
MakeProduct,
|
makeProduct,
|
||||||
Research,
|
research,
|
||||||
ExportMaterial,
|
exportMaterial,
|
||||||
CancelExportMaterial,
|
cancelExportMaterial,
|
||||||
SetMaterialMarketTA1,
|
setMaterialMarketTA1,
|
||||||
SetMaterialMarketTA2,
|
setMaterialMarketTA2,
|
||||||
SetProductMarketTA1,
|
setProductMarketTA1,
|
||||||
SetProductMarketTA2,
|
setProductMarketTA2,
|
||||||
BulkPurchase,
|
bulkPurchase,
|
||||||
SellShares,
|
sellShares,
|
||||||
BuyBackShares,
|
buyBackShares,
|
||||||
SetSmartSupplyOption,
|
setSmartSupplyOption,
|
||||||
LimitMaterialProduction,
|
limitMaterialProduction,
|
||||||
LimitProductProduction,
|
limitProductProduction,
|
||||||
UpgradeWarehouseCost,
|
upgradeWarehouseCost,
|
||||||
createCorporation,
|
createCorporation,
|
||||||
removeDivision,
|
removeDivision,
|
||||||
bribe,
|
bribe,
|
||||||
@ -184,7 +184,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
throw helpers.errorMessage(ctx, "You must provide a positive number");
|
throw helpers.errorMessage(ctx, "You must provide a positive number");
|
||||||
}
|
}
|
||||||
const warehouse = getWarehouse(divisionName, cityName);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
return UpgradeWarehouseCost(warehouse, amt);
|
return upgradeWarehouseCost(warehouse, amt);
|
||||||
},
|
},
|
||||||
hasWarehouse: (ctx) => (_divisionName, _cityName) => {
|
hasWarehouse: (ctx) => (_divisionName, _cityName) => {
|
||||||
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
||||||
@ -273,7 +273,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
if (amt < 1) {
|
if (amt < 1) {
|
||||||
throw helpers.errorMessage(ctx, "You must provide a positive number");
|
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) => {
|
sellMaterial: (ctx) => (_divisionName, _cityName, _materialName, _amt, _price) => {
|
||||||
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
||||||
@ -283,7 +283,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const amt = helpers.string(ctx, "amt", _amt);
|
const amt = helpers.string(ctx, "amt", _amt);
|
||||||
const price = helpers.string(ctx, "price", _price);
|
const price = helpers.string(ctx, "price", _price);
|
||||||
const material = getMaterial(divisionName, cityName, materialName);
|
const material = getMaterial(divisionName, cityName, materialName);
|
||||||
SellMaterial(material, amt, price);
|
sellMaterial(material, amt, price);
|
||||||
},
|
},
|
||||||
sellProduct:
|
sellProduct:
|
||||||
(ctx) =>
|
(ctx) =>
|
||||||
@ -296,7 +296,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const price = helpers.string(ctx, "price", _price);
|
const price = helpers.string(ctx, "price", _price);
|
||||||
const all = !!_all;
|
const all = !!_all;
|
||||||
const product = getProduct(divisionName, productName);
|
const product = getProduct(divisionName, productName);
|
||||||
SellProduct(product, cityName, amt, price, all);
|
sellProduct(product, cityName, amt, price, all);
|
||||||
},
|
},
|
||||||
discontinueProduct: (ctx) => (_divisionName, _productName) => {
|
discontinueProduct: (ctx) => (_divisionName, _productName) => {
|
||||||
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
||||||
@ -312,7 +312,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const warehouse = getWarehouse(divisionName, cityName);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
if (!hasUnlock(CorpUnlockName.SmartSupply))
|
if (!hasUnlock(CorpUnlockName.SmartSupply))
|
||||||
throw helpers.errorMessage(ctx, `You have not purchased the Smart Supply upgrade!`);
|
throw helpers.errorMessage(ctx, `You have not purchased the Smart Supply upgrade!`);
|
||||||
SetSmartSupply(warehouse, enabled);
|
setSmartSupply(warehouse, enabled);
|
||||||
},
|
},
|
||||||
setSmartSupplyOption: (ctx) => (_divisionName, _cityName, _materialName, _option) => {
|
setSmartSupplyOption: (ctx) => (_divisionName, _cityName, _materialName, _option) => {
|
||||||
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
||||||
@ -324,7 +324,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const option = getEnumHelper("SmartSupplyOption").nsGetMember(ctx, _option);
|
const option = getEnumHelper("SmartSupplyOption").nsGetMember(ctx, _option);
|
||||||
if (!hasUnlock(CorpUnlockName.SmartSupply))
|
if (!hasUnlock(CorpUnlockName.SmartSupply))
|
||||||
throw helpers.errorMessage(ctx, `You have not purchased the Smart Supply upgrade!`);
|
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) => {
|
buyMaterial: (ctx) => (_divisionName, _cityName, _materialName, _amt) => {
|
||||||
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
||||||
@ -337,7 +337,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
if (amt < 0 || !Number.isFinite(amt))
|
if (amt < 0 || !Number.isFinite(amt))
|
||||||
throw new Error("Invalid value for amount field! Must be numeric and greater than or equal to 0");
|
throw new Error("Invalid value for amount field! Must be numeric and greater than or equal to 0");
|
||||||
const material = getMaterial(divisionName, cityName, materialName);
|
const material = getMaterial(divisionName, cityName, materialName);
|
||||||
BuyMaterial(division, material, amt);
|
buyMaterial(division, material, amt);
|
||||||
},
|
},
|
||||||
bulkPurchase: (ctx) => (_divisionName, _cityName, _materialName, _amt) => {
|
bulkPurchase: (ctx) => (_divisionName, _cityName, _materialName, _amt) => {
|
||||||
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
||||||
@ -350,7 +350,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const amt = helpers.number(ctx, "amt", _amt);
|
const amt = helpers.number(ctx, "amt", _amt);
|
||||||
const warehouse = getWarehouse(divisionName, cityName);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
const material = getMaterial(divisionName, cityName, materialName);
|
const material = getMaterial(divisionName, cityName, materialName);
|
||||||
BulkPurchase(corporation, division, warehouse, material, amt);
|
bulkPurchase(corporation, division, warehouse, material, amt);
|
||||||
},
|
},
|
||||||
makeProduct:
|
makeProduct:
|
||||||
(ctx) =>
|
(ctx) =>
|
||||||
@ -362,7 +362,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const designInvest = helpers.number(ctx, "designInvest", _designInvest);
|
const designInvest = helpers.number(ctx, "designInvest", _designInvest);
|
||||||
const marketingInvest = helpers.number(ctx, "marketingInvest", _marketingInvest);
|
const marketingInvest = helpers.number(ctx, "marketingInvest", _marketingInvest);
|
||||||
const corporation = getCorporation();
|
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) => {
|
limitProductProduction: (ctx) => (_divisionName, _cityName, _productName, _qty) => {
|
||||||
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
||||||
@ -370,7 +370,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const cityName = getEnumHelper("CityName").nsGetMember(ctx, _cityName);
|
const cityName = getEnumHelper("CityName").nsGetMember(ctx, _cityName);
|
||||||
const productName = helpers.string(ctx, "productName", _productName);
|
const productName = helpers.string(ctx, "productName", _productName);
|
||||||
const qty = helpers.number(ctx, "qty", _qty);
|
const qty = helpers.number(ctx, "qty", _qty);
|
||||||
LimitProductProduction(getProduct(divisionName, productName), cityName, qty);
|
limitProductProduction(getProduct(divisionName, productName), cityName, qty);
|
||||||
},
|
},
|
||||||
exportMaterial:
|
exportMaterial:
|
||||||
(ctx) =>
|
(ctx) =>
|
||||||
@ -386,7 +386,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const materialName = getEnumHelper("CorpMaterialName").nsGetMember(ctx, _materialName, "materialName");
|
const materialName = getEnumHelper("CorpMaterialName").nsGetMember(ctx, _materialName, "materialName");
|
||||||
const amt = helpers.string(ctx, "amt", _amt);
|
const amt = helpers.string(ctx, "amt", _amt);
|
||||||
|
|
||||||
ExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt);
|
exportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt);
|
||||||
},
|
},
|
||||||
cancelExportMaterial:
|
cancelExportMaterial:
|
||||||
(ctx) =>
|
(ctx) =>
|
||||||
@ -400,7 +400,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const targetDivision = helpers.string(ctx, "targetDivision", _targetDivision);
|
const targetDivision = helpers.string(ctx, "targetDivision", _targetDivision);
|
||||||
const targetCity = getEnumHelper("CityName").nsGetMember(ctx, _targetCity, "targetCity");
|
const targetCity = getEnumHelper("CityName").nsGetMember(ctx, _targetCity, "targetCity");
|
||||||
const materialName = getEnumHelper("CorpMaterialName").nsGetMember(ctx, _materialName, "materialName");
|
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) => {
|
limitMaterialProduction: (ctx) => (_divisionName, _cityName, _materialName, _qty) => {
|
||||||
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
||||||
@ -408,7 +408,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const cityName = getEnumHelper("CityName").nsGetMember(ctx, _cityName);
|
const cityName = getEnumHelper("CityName").nsGetMember(ctx, _cityName);
|
||||||
const materialName = getEnumHelper("CorpMaterialName").nsGetMember(ctx, _materialName, "materialName");
|
const materialName = getEnumHelper("CorpMaterialName").nsGetMember(ctx, _materialName, "materialName");
|
||||||
const qty = helpers.number(ctx, "qty", _qty);
|
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) => {
|
setMaterialMarketTA1: (ctx) => (_divisionName, _cityName, _materialName, _on) => {
|
||||||
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
||||||
@ -418,7 +418,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const on = !!_on;
|
const on = !!_on;
|
||||||
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
||||||
throw helpers.errorMessage(ctx, `You have not researched MarketTA.I for division: ${divisionName}`);
|
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) => {
|
setMaterialMarketTA2: (ctx) => (_divisionName, _cityName, _materialName, _on) => {
|
||||||
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
||||||
@ -428,7 +428,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const on = !!_on;
|
const on = !!_on;
|
||||||
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
||||||
throw helpers.errorMessage(ctx, `You have not researched MarketTA.II for division: ${divisionName}`);
|
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) => {
|
setProductMarketTA1: (ctx) => (_divisionName, _productName, _on) => {
|
||||||
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
||||||
@ -437,7 +437,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const on = !!_on;
|
const on = !!_on;
|
||||||
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
||||||
throw helpers.errorMessage(ctx, `You have not researched MarketTA.I for division: ${divisionName}`);
|
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) => {
|
setProductMarketTA2: (ctx) => (_divisionName, _productName, _on) => {
|
||||||
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
checkAccess(ctx, CorpUnlockName.WarehouseAPI);
|
||||||
@ -446,7 +446,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const on = !!_on;
|
const on = !!_on;
|
||||||
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
||||||
throw helpers.errorMessage(ctx, `You have not researched MarketTA.II for division: ${divisionName}`);
|
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 office = getOffice(divisionName, cityName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
UpgradeOfficeSize(corporation, office, size);
|
upgradeOfficeSize(corporation, office, size);
|
||||||
},
|
},
|
||||||
throwParty: (ctx) => (_divisionName, _cityName, _costPerEmployee) => {
|
throwParty: (ctx) => (_divisionName, _cityName, _costPerEmployee) => {
|
||||||
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
||||||
@ -540,7 +540,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
const office = getOffice(divisionName, cityName);
|
const office = getOffice(divisionName, cityName);
|
||||||
|
|
||||||
return ThrowParty(corporation, office, costPerEmployee);
|
return throwParty(corporation, office, costPerEmployee);
|
||||||
},
|
},
|
||||||
buyTea: (ctx) => (_divisionName, _cityName) => {
|
buyTea: (ctx) => (_divisionName, _cityName) => {
|
||||||
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
||||||
@ -549,19 +549,19 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
|
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
const office = getOffice(divisionName, cityName);
|
const office = getOffice(divisionName, cityName);
|
||||||
return BuyTea(corporation, office);
|
return buyTea(corporation, office);
|
||||||
},
|
},
|
||||||
hireAdVert: (ctx) => (_divisionName) => {
|
hireAdVert: (ctx) => (_divisionName) => {
|
||||||
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
||||||
const divisionName = helpers.string(ctx, "divisionName", _divisionName);
|
const divisionName = helpers.string(ctx, "divisionName", _divisionName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
HireAdVert(corporation, getDivision(divisionName));
|
hireAdVert(corporation, getDivision(divisionName));
|
||||||
},
|
},
|
||||||
research: (ctx) => (_divisionName, _researchName) => {
|
research: (ctx) => (_divisionName, _researchName) => {
|
||||||
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
||||||
const divisionName = helpers.string(ctx, "divisionName", _divisionName);
|
const divisionName = helpers.string(ctx, "divisionName", _divisionName);
|
||||||
const researchName = getEnumHelper("CorpResearchName").nsGetMember(ctx, _researchName, "researchName");
|
const researchName = getEnumHelper("CorpResearchName").nsGetMember(ctx, _researchName, "researchName");
|
||||||
Research(getDivision(divisionName), researchName);
|
research(getDivision(divisionName), researchName);
|
||||||
},
|
},
|
||||||
getOffice: (ctx) => (_divisionName, _cityName) => {
|
getOffice: (ctx) => (_divisionName, _cityName) => {
|
||||||
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
||||||
@ -611,7 +611,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const industryName = getEnumHelper("IndustryType").nsGetMember(ctx, _industryName, "industryName");
|
const industryName = getEnumHelper("IndustryType").nsGetMember(ctx, _industryName, "industryName");
|
||||||
const divisionName = helpers.string(ctx, "divisionName", _divisionName);
|
const divisionName = helpers.string(ctx, "divisionName", _divisionName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
NewDivision(corporation, industryName, divisionName);
|
createDivision(corporation, industryName, divisionName);
|
||||||
},
|
},
|
||||||
expandCity: (ctx) => (_divisionName, _cityName) => {
|
expandCity: (ctx) => (_divisionName, _cityName) => {
|
||||||
checkAccess(ctx);
|
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}`);
|
throw new Error(`Invalid value for rate field! Must be numeric, greater than 0, and less than ${max}`);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
if (!corporation.public) throw helpers.errorMessage(ctx, `Your company has not gone public!`);
|
if (!corporation.public) throw helpers.errorMessage(ctx, `Your company has not gone public!`);
|
||||||
IssueDividends(corporation, rate);
|
issueDividends(corporation, rate);
|
||||||
},
|
},
|
||||||
issueNewShares: (ctx) => (_amount) => {
|
issueNewShares: (ctx) => (_amount) => {
|
||||||
checkAccess(ctx);
|
checkAccess(ctx);
|
||||||
@ -651,7 +651,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const maxNewShares = corporation.calculateMaxNewShares();
|
const maxNewShares = corporation.calculateMaxNewShares();
|
||||||
if (_amount == undefined) _amount = maxNewShares;
|
if (_amount == undefined) _amount = maxNewShares;
|
||||||
const amount = helpers.number(ctx, "amount", _amount);
|
const amount = helpers.number(ctx, "amount", _amount);
|
||||||
const [funds] = IssueNewShares(corporation, amount);
|
const [funds] = issueNewShares(corporation, amount);
|
||||||
return funds;
|
return funds;
|
||||||
},
|
},
|
||||||
getDivision: (ctx) => (_divisionName) => {
|
getDivision: (ctx) => (_divisionName) => {
|
||||||
@ -728,7 +728,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
checkAccess(ctx);
|
checkAccess(ctx);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
try {
|
try {
|
||||||
AcceptInvestmentOffer(corporation);
|
acceptInvestmentOffer(corporation);
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return false;
|
return false;
|
||||||
@ -739,18 +739,18 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
|||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
if (corporation.public) throw helpers.errorMessage(ctx, "Corporation is already public");
|
if (corporation.public) throw helpers.errorMessage(ctx, "Corporation is already public");
|
||||||
const numShares = helpers.number(ctx, "numShares", _numShares);
|
const numShares = helpers.number(ctx, "numShares", _numShares);
|
||||||
GoPublic(corporation, numShares);
|
goPublic(corporation, numShares);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
sellShares: (ctx) => (_numShares) => {
|
sellShares: (ctx) => (_numShares) => {
|
||||||
checkAccess(ctx);
|
checkAccess(ctx);
|
||||||
const numShares = helpers.number(ctx, "numShares", _numShares);
|
const numShares = helpers.number(ctx, "numShares", _numShares);
|
||||||
return SellShares(getCorporation(), numShares);
|
return sellShares(getCorporation(), numShares);
|
||||||
},
|
},
|
||||||
buyBackShares: (ctx) => (_numShares) => {
|
buyBackShares: (ctx) => (_numShares) => {
|
||||||
checkAccess(ctx);
|
checkAccess(ctx);
|
||||||
const numShares = helpers.number(ctx, "numShares", _numShares);
|
const numShares = helpers.number(ctx, "numShares", _numShares);
|
||||||
return BuyBackShares(getCorporation(), numShares);
|
return buyBackShares(getCorporation(), numShares);
|
||||||
},
|
},
|
||||||
bribe: (ctx) => (_factionName, _amountCash) => {
|
bribe: (ctx) => (_factionName, _amountCash) => {
|
||||||
checkAccess(ctx);
|
checkAccess(ctx);
|
||||||
|
@ -36,7 +36,7 @@ import { v2APIBreak } from "./utils/v2APIBreak";
|
|||||||
import { Corporation } from "./Corporation/Corporation";
|
import { Corporation } from "./Corporation/Corporation";
|
||||||
import { Terminal } from "./Terminal";
|
import { Terminal } from "./Terminal";
|
||||||
import { getRecordValues } from "./Types/Record";
|
import { getRecordValues } from "./Types/Record";
|
||||||
import { ExportMaterial } from "./Corporation/Actions";
|
import { exportMaterial } from "./Corporation/Actions";
|
||||||
import { getGoSave, loadGo } from "./Go/SaveLoad";
|
import { getGoSave, loadGo } from "./Go/SaveLoad";
|
||||||
import { SaveData } from "./types";
|
import { SaveData } from "./types";
|
||||||
import { SaveDataError, canUseBinaryFormat, decodeSaveData, encodeJsonSaveString } from "./utils/SaveDataUtils";
|
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);
|
const targetDivision = Player.corporation.divisions.get(originalExport.division);
|
||||||
if (!targetDivision) throw new Error(`Target division ${originalExport.division} did not exist`);
|
if (!targetDivision) throw new Error(`Target division ${originalExport.division} did not exist`);
|
||||||
// Set the export again. ExportMaterial throws on failure
|
// Set the export again. ExportMaterial throws on failure
|
||||||
ExportMaterial(targetDivision, originalExport.city, material, originalExport.amount);
|
exportMaterial(targetDivision, originalExport.city, material, originalExport.amount);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
anyExportsFailed = true;
|
anyExportsFailed = true;
|
||||||
// We just need the text error, not a full stack trace
|
// We just need the text error, not a full stack trace
|
||||||
|
@ -9,11 +9,11 @@ import {
|
|||||||
import { Player, setPlayer } from "../../src/Player";
|
import { Player, setPlayer } from "../../src/Player";
|
||||||
import { PlayerObject } from "../../src/PersonObjects/Player/PlayerObject";
|
import { PlayerObject } from "../../src/PersonObjects/Player/PlayerObject";
|
||||||
import {
|
import {
|
||||||
AcceptInvestmentOffer,
|
acceptInvestmentOffer,
|
||||||
BuyBackShares,
|
buyBackShares,
|
||||||
GoPublic,
|
goPublic,
|
||||||
IssueNewShares,
|
issueNewShares,
|
||||||
SellShares,
|
sellShares,
|
||||||
} from "../../src/Corporation/Actions";
|
} from "../../src/Corporation/Actions";
|
||||||
|
|
||||||
describe("Corporation", () => {
|
describe("Corporation", () => {
|
||||||
@ -87,32 +87,32 @@ describe("Corporation", () => {
|
|||||||
expectSharesToAddUp(Player.corporation!);
|
expectSharesToAddUp(Player.corporation!);
|
||||||
});
|
});
|
||||||
it("should be preserved by acceptInvestmentOffer", () => {
|
it("should be preserved by acceptInvestmentOffer", () => {
|
||||||
AcceptInvestmentOffer(corporation);
|
acceptInvestmentOffer(corporation);
|
||||||
expectSharesToAddUp(corporation);
|
expectSharesToAddUp(corporation);
|
||||||
});
|
});
|
||||||
it("should be preserved by goPublic", () => {
|
it("should be preserved by goPublic", () => {
|
||||||
const numShares = 1e8;
|
const numShares = 1e8;
|
||||||
GoPublic(corporation, numShares);
|
goPublic(corporation, numShares);
|
||||||
expectSharesToAddUp(corporation);
|
expectSharesToAddUp(corporation);
|
||||||
});
|
});
|
||||||
it("should be preserved by IssueNewShares", () => {
|
it("should be preserved by IssueNewShares", () => {
|
||||||
const numShares = 1e8;
|
const numShares = 1e8;
|
||||||
GoPublic(corporation, numShares);
|
goPublic(corporation, numShares);
|
||||||
corporation.issueNewSharesCooldown = 0;
|
corporation.issueNewSharesCooldown = 0;
|
||||||
IssueNewShares(corporation, numShares);
|
issueNewShares(corporation, numShares);
|
||||||
expectSharesToAddUp(corporation);
|
expectSharesToAddUp(corporation);
|
||||||
});
|
});
|
||||||
it("should be preserved by BuyBackShares", () => {
|
it("should be preserved by BuyBackShares", () => {
|
||||||
const numShares = 1e8;
|
const numShares = 1e8;
|
||||||
GoPublic(corporation, numShares);
|
goPublic(corporation, numShares);
|
||||||
BuyBackShares(corporation, numShares);
|
buyBackShares(corporation, numShares);
|
||||||
expectSharesToAddUp(corporation);
|
expectSharesToAddUp(corporation);
|
||||||
});
|
});
|
||||||
it("should be preserved by SellShares", () => {
|
it("should be preserved by SellShares", () => {
|
||||||
const numShares = 1e8;
|
const numShares = 1e8;
|
||||||
GoPublic(corporation, numShares);
|
goPublic(corporation, numShares);
|
||||||
corporation.shareSaleCooldown = 0;
|
corporation.shareSaleCooldown = 0;
|
||||||
SellShares(corporation, numShares);
|
sellShares(corporation, numShares);
|
||||||
expectSharesToAddUp(corporation);
|
expectSharesToAddUp(corporation);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user