(null);
const [numEmployees, setNumEmployees] = useState(0);
const [numOperations, setNumOperations] = useState(0);
@@ -51,28 +49,8 @@ export function IndustryOffice(props: IProps): React.ReactElement {
}
function updateEmployeeCount(): void {
- const division = props.routing.currentDivision;
- if (division == null) {
- throw new Error(
- `Routing does not hold reference to the current Industry`,
- );
- }
- const office = division.offices[props.currentCity];
- if (!(office instanceof OfficeSpace)) {
- throw new Error(
- `Current City (${props.currentCity}) for UI does not have an OfficeSpace object`,
- );
- }
-
- // If we're in a new city, we have to reset the state
- if (division.name !== divisionName || props.currentCity !== city) {
- resetEmployeeCount();
- setDivisionName(division.name);
- setCity(props.currentCity);
- }
-
// Calculate how many NEW employees we need to account for
- const currentNumEmployees = office.employees.length;
+ const currentNumEmployees = props.office.employees.length;
let newOperations = numOperations;
let newEngineers = numEngineers;
@@ -83,8 +61,8 @@ export function IndustryOffice(props: IProps): React.ReactElement {
let newTraining = numTraining;
// Record the number of employees in each position, for NEW employees only
- for (let i = numEmployees; i < office.employees.length; ++i) {
- switch (office.employees[i].pos) {
+ for (let i = numEmployees; i < props.office.employees.length; ++i) {
+ switch (props.office.employees[i].pos) {
case EmployeePositions.Operations:
newOperations++;
break;
@@ -108,7 +86,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
break;
default:
console.error(
- "Unrecognized employee position: " + office.employees[i].pos,
+ "Unrecognized employee position: " + props.office.employees[i].pos,
);
break;
}
@@ -139,10 +117,6 @@ export function IndustryOffice(props: IProps): React.ReactElement {
}
function renderAutomaticEmployeeManagement(): React.ReactElement {
- const division = props.routing.currentDivision; // Validated in constructor
- if (division === null) return <>>;
- const office = division.offices[props.currentCity]; // Validated in constructor
- if (office === 0) return <>>;
const vechain = props.corp.unlockUpgrades[4] === 1; // Has Vechain upgrade
function switchModeOnClick(): void {
@@ -156,26 +130,24 @@ export function IndustryOffice(props: IProps): React.ReactElement {
totalHappiness = 0,
totalEnergy = 0,
totalSalary = 0;
- for (let i = 0; i < office.employees.length; ++i) {
- totalMorale += office.employees[i].mor;
- totalHappiness += office.employees[i].hap;
- totalEnergy += office.employees[i].ene;
- totalSalary += office.employees[i].sal;
+ for (let i = 0; i < props.office.employees.length; ++i) {
+ totalMorale += props.office.employees[i].mor;
+ totalHappiness += props.office.employees[i].hap;
+ totalEnergy += props.office.employees[i].ene;
+ totalSalary += props.office.employees[i].sal;
}
let avgMorale = 0,
avgHappiness = 0,
avgEnergy = 0;
- if (office.employees.length > 0) {
- avgMorale = totalMorale / office.employees.length;
- avgHappiness = totalHappiness / office.employees.length;
- avgEnergy = totalEnergy / office.employees.length;
+ if (props.office.employees.length > 0) {
+ avgMorale = totalMorale / props.office.employees.length;
+ avgHappiness = totalHappiness / props.office.employees.length;
+ avgEnergy = totalEnergy / props.office.employees.length;
}
// Helper functions for (re-)assigning employees to different positions
function assignEmployee(to: string): void {
- if (office === 0) return;
- if (division === null) return;
if (numUnassigned <= 0) {
console.warn(
"Cannot assign employee. No unassigned employees available",
@@ -211,14 +183,12 @@ export function IndustryOffice(props: IProps): React.ReactElement {
}
setNumUnassigned((n) => n - 1);
- office.assignEmployeeToJob(to);
- office.calculateEmployeeProductivity(props.corp, division);
+ props.office.assignEmployeeToJob(to);
+ props.office.calculateEmployeeProductivity(props.corp, props.division);
props.corp.rerender(props.player);
}
function unassignEmployee(from: string): void {
- if (office === 0) return;
- if (division === null) return;
function logWarning(pos: string): void {
console.warn(
`Cannot unassign from ${pos} because there is nobody assigned to that position`,
@@ -271,8 +241,8 @@ export function IndustryOffice(props: IProps): React.ReactElement {
}
setNumUnassigned((n) => n + 1);
- office.unassignEmployeeFromJob(from);
- office.calculateEmployeeProductivity(props.corp, division);
+ props.office.unassignEmployeeFromJob(from);
+ props.office.calculateEmployeeProductivity(props.corp, props.division);
props.corp.rerender(props.player);
}
@@ -375,7 +345,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
Material Production:{" "}
{numeralWrapper.format(
- division.getOfficeProductivity(office),
+ props.division.getOfficeProductivity(props.office),
"0.000",
)}
@@ -391,7 +361,9 @@ export function IndustryOffice(props: IProps): React.ReactElement {
Product Production:{" "}
{numeralWrapper.format(
- division.getOfficeProductivity(office, { forProduct: true }),
+ props.division.getOfficeProductivity(props.office, {
+ forProduct: true,
+ }),
"0.000",
)}
@@ -406,7 +378,10 @@ export function IndustryOffice(props: IProps): React.ReactElement {
{vechain && (
Business Multiplier: x
- {numeralWrapper.format(division.getBusinessFactor(office), "0.000")}
+ {numeralWrapper.format(
+ props.division.getBusinessFactor(props.office),
+ "0.000",
+ )}
The effect this office's 'Business' employees has on boosting
sales
@@ -542,12 +517,6 @@ export function IndustryOffice(props: IProps): React.ReactElement {
}
function renderManualEmployeeManagement(): React.ReactElement {
- const corp = props.corp;
- const division = props.routing.currentDivision; // Validated in constructor
- if (division === null) return <>>;
- const office = division.offices[props.currentCity]; // Validated in constructor
- if (office === 0) return <>>;
-
function switchModeOnClick(): void {
setEmployeeManualAssignMode(false);
props.corp.rerender(props.player);
@@ -561,10 +530,10 @@ export function IndustryOffice(props: IProps): React.ReactElement {
// Employee Selector
const employees = [];
- for (let i = 0; i < office.employees.length; ++i) {
+ for (let i = 0; i < props.office.employees.length; ++i) {
employees.push(
- ,
);
}
@@ -572,16 +541,15 @@ export function IndustryOffice(props: IProps): React.ReactElement {
function employeeSelectorOnChange(
e: React.ChangeEvent,
): void {
- if (office === 0) return;
const name = getSelectText(e.target);
- for (let i = 0; i < office.employees.length; ++i) {
- if (name === office.employees[i].name) {
- setEmployee(office.employees[i]);
+ for (let i = 0; i < props.office.employees.length; ++i) {
+ if (name === props.office.employees[i].name) {
+ setEmployee(props.office.employees[i]);
break;
}
}
- corp.rerender(props.player);
+ props.corp.rerender(props.player);
}
// Employee Positions Selector
@@ -607,7 +575,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
const pos = getSelectText(e.target);
employee.pos = pos;
resetEmployeeCount();
- corp.rerender(props.player);
+ props.corp.rerender(props.player);
}
// Numeraljs formatter
@@ -616,23 +584,23 @@ export function IndustryOffice(props: IProps): React.ReactElement {
// Employee stats (after applying multipliers)
const effCre = emp
? emp.cre *
- corp.getEmployeeCreMultiplier() *
- division.getEmployeeCreMultiplier()
+ props.corp.getEmployeeCreMultiplier() *
+ props.division.getEmployeeCreMultiplier()
: 0;
const effCha = emp
? emp.cha *
- corp.getEmployeeChaMultiplier() *
- division.getEmployeeChaMultiplier()
+ props.corp.getEmployeeChaMultiplier() *
+ props.division.getEmployeeChaMultiplier()
: 0;
const effInt = emp
? emp.int *
- corp.getEmployeeIntMultiplier() *
- division.getEmployeeIntMultiplier()
+ props.corp.getEmployeeIntMultiplier() *
+ props.division.getEmployeeIntMultiplier()
: 0;
const effEff = emp
? emp.eff *
- corp.getEmployeeEffMultiplier() *
- division.getEmployeeEffMultiplier()
+ props.corp.getEmployeeEffMultiplier() *
+ props.division.getEmployeeEffMultiplier()
: 0;
return (
@@ -682,30 +650,25 @@ export function IndustryOffice(props: IProps): React.ReactElement {
);
}
- const division = props.routing.currentDivision; // Validated in constructor
- if (division === null) return <>>;
- const office = division.offices[props.currentCity]; // Validated in constructor
- if (office === 0) return <>>;
const buttonStyle = {
fontSize: "13px",
};
// Hire Employee button
let hireEmployeeButtonClass = "tooltip";
- if (office.atCapacity()) {
+ if (props.office.atCapacity()) {
hireEmployeeButtonClass += " a-link-button-inactive";
} else {
hireEmployeeButtonClass += " std-button";
- if (office.employees.length === 0) {
+ if (props.office.employees.length === 0) {
hireEmployeeButtonClass += " flashing-button";
}
}
function openHireEmployeePopup(): void {
- if (office === 0) return;
const popupId = "cmpy-mgmt-hire-employee-popup";
createPopup(popupId, HireEmployeePopup, {
- office: office,
+ office: props.office,
corp: props.corp,
popupId: popupId,
player: props.player,
@@ -714,23 +677,21 @@ export function IndustryOffice(props: IProps): React.ReactElement {
// Autohire employee button
let autohireEmployeeButtonClass = "tooltip";
- if (office.atCapacity()) {
+ if (props.office.atCapacity()) {
autohireEmployeeButtonClass += " a-link-button-inactive";
} else {
autohireEmployeeButtonClass += " std-button";
}
function autohireEmployeeButtonOnClick(): void {
- if (office === 0) return;
- if (office.atCapacity()) return;
- office.hireRandomEmployee();
+ if (props.office.atCapacity()) return;
+ props.office.hireRandomEmployee();
props.corp.rerender(props.player);
}
function openUpgradeOfficeSizePopup(): void {
- if (office === 0) return;
const popupId = "cmpy-mgmt-upgrade-office-size-popup";
createPopup(popupId, UpgradeOfficeSizePopup, {
- office: office,
+ office: props.office,
corp: props.corp,
popupId: popupId,
player: props.player,
@@ -738,10 +699,9 @@ export function IndustryOffice(props: IProps): React.ReactElement {
}
function openThrowPartyPopup(): void {
- if (office === 0) return;
const popupId = "cmpy-mgmt-throw-office-party-popup";
createPopup(popupId, ThrowPartyPopup, {
- office: office,
+ office: props.office,
corp: props.corp,
popupId: popupId,
});
@@ -751,7 +711,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
Office Space
- Size: {office.employees.length} / {office.size} employees
+ Size: {props.office.employees.length} / {props.office.size} employees
- {!division.hasResearch("AutoPartyManager") && (
+ {!props.division.hasResearch("AutoPartyManager") && (
@@ -119,16 +117,13 @@ export function IndustryOverview(props: IProps): React.ReactElement {
}
function renderText(): React.ReactElement {
- const corp = props.corp;
- const division = props.routing.currentDivision; // Validated inside render()
- if (division === null) return <>>;
- const vechain = corp.unlockUpgrades[4] === 1;
- const profit = division.lastCycleRevenue
- .minus(division.lastCycleExpenses)
+ const vechain = props.corp.unlockUpgrades[4] === 1;
+ const profit = props.division.lastCycleRevenue
+ .minus(props.division.lastCycleExpenses)
.toNumber();
let advertisingInfo = false;
- const advertisingFactors = division.getAdvertisingFactors();
+ const advertisingFactors = props.division.getAdvertisingFactors();
const awarenessFac = advertisingFactors[1];
const popularityFac = advertisingFactors[2];
const ratioFac = advertisingFactors[3];
@@ -138,7 +133,6 @@ export function IndustryOverview(props: IProps): React.ReactElement {
}
function productionMultHelpTipOnClick(): void {
- if (division === null) return;
// Wrapper for createProgressBarText()
// Converts the industry's "effectiveness factors"
// into a graphic (string) depicting how high that effectiveness is
@@ -163,34 +157,41 @@ export function IndustryOverview(props: IProps): React.ReactElement {
"Below are approximations for how effective each material is at boosting " +
"this industry's production multiplier (Bigger bars = more effective):
" +
`Hardware: ${convertEffectFacToGraphic(
- division.hwFac,
+ props.division.hwFac,
)}
` +
`Robots: ${convertEffectFacToGraphic(
- division.robFac,
+ props.division.robFac,
)}
` +
`AI Cores: ${convertEffectFacToGraphic(
- division.aiFac,
+ props.division.aiFac,
)}
` +
- `Real Estate: ${convertEffectFacToGraphic(division.reFac)}`,
+ `Real Estate: ${convertEffectFacToGraphic(props.division.reFac)}`,
);
}
function openResearchPopup(): void {
- if (division === null) return;
const popupId = "corporation-research-popup-box";
createPopup(popupId, ResearchPopup, {
- industry: division,
+ industry: props.division,
popupId: popupId,
});
}
return (
- Industry: {division.type} (Corp Funds:{" "}
-
)
+ Industry: {props.division.type} (Corp Funds:{" "}
+
)
- Awareness: {numeralWrapper.format(division.awareness, "0.000")}
- Popularity: {numeralWrapper.format(division.popularity, "0.000")}
+ Awareness: {numeralWrapper.format(
+ props.division.awareness,
+ "0.000",
+ )}{" "}
+
+ Popularity: {numeralWrapper.format(
+ props.division.popularity,
+ "0.000",
+ )}{" "}
+
{advertisingInfo !== false && (
Advertising Multiplier: x
@@ -213,16 +214,17 @@ export function IndustryOverview(props: IProps): React.ReactElement {
{advertisingInfo}
- Revenue: / s{" "}
-
+ Revenue: /
+ s
Expenses: /s
+ money={props.division.lastCycleExpenses.toNumber()}
+ />{" "}
+ /s
Profit: / s
Production Multiplier:{" "}
- {numeralWrapper.format(division.prodMult, "0.00")}
+ {numeralWrapper.format(props.division.prodMult, "0.00")}
Production gain from owning production-boosting materials such as
hardware, Robots, AI Cores, and Real Estate
@@ -234,7 +236,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
Scientific Research:{" "}
- {numeralWrapper.format(division.sciResearch.qty, "0.000a")}
+ {numeralWrapper.format(props.division.sciResearch.qty, "0.000a")}
Scientific Research increases the quality of the materials and
products that you produce.
@@ -248,22 +250,12 @@ export function IndustryOverview(props: IProps): React.ReactElement {
}
function renderUpgrades(): React.ReactElement[] {
- const corp = props.corp;
- const division = props.routing.currentDivision; // Validated inside render()
- if (division === null) return [<>>];
- const office = division.offices[props.currentCity];
- if (!(office instanceof OfficeSpace)) {
- throw new Error(
- `Current City (${props.currentCity}) for UI does not have an OfficeSpace object`,
- );
- }
-
const upgrades = [];
for (const index in IndustryUpgrades) {
const upgrade = IndustryUpgrades[index];
// AutoBrew research disables the Coffee upgrade
- if (division.hasResearch("AutoBrew") && upgrade[4] === "Coffee") {
+ if (props.division.hasResearch("AutoBrew") && upgrade[4] === "Coffee") {
continue;
}
@@ -273,26 +265,24 @@ export function IndustryOverview(props: IProps): React.ReactElement {
let cost = 0;
switch (i) {
case 0: //Coffee, cost is static per employee
- cost = office.employees.length * baseCost;
+ cost = props.office.employees.length * baseCost;
break;
default:
- cost = baseCost * Math.pow(priceMult, division.upgrades[i]);
+ cost = baseCost * Math.pow(priceMult, props.division.upgrades[i]);
break;
}
function onClick(): void {
- if (office === 0) return;
- if (division === null) return;
- if (corp.funds.lt(cost)) {
+ if (props.corp.funds.lt(cost)) {
dialogBoxCreate("Insufficient funds");
} else {
- corp.funds = corp.funds.minus(cost);
- division.upgrade(upgrade, {
- corporation: corp,
- office: office,
+ props.corp.funds = props.corp.funds.minus(cost);
+ props.division.upgrade(upgrade, {
+ corporation: props.corp,
+ office: props.office,
});
// corp.displayDivisionContent(division, city);
- corp.rerender(props.player);
+ props.corp.rerender(props.player);
}
}
@@ -335,11 +325,6 @@ export function IndustryOverview(props: IProps): React.ReactElement {
);
}
- const division = props.routing.currentDivision;
- if (division == null) {
- throw new Error(`Routing does not hold reference to the current Industry`);
- }
-
const makeProductButton = renderMakeProductButton();
return (
@@ -351,7 +336,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
{renderUpgrades()}
- {division.makesProducts && makeProductButton}
+ {props.division.makesProducts && makeProductButton}
);
}
diff --git a/src/Corporation/ui/IndustryWarehouse.tsx b/src/Corporation/ui/IndustryWarehouse.tsx
index ff150d49d..11a3feb36 100644
--- a/src/Corporation/ui/IndustryWarehouse.tsx
+++ b/src/Corporation/ui/IndustryWarehouse.tsx
@@ -23,7 +23,6 @@ import { createPopup } from "../../ui/React/createPopup";
import { isString } from "../../../utils/helpers/isString";
import { ICorporation } from "../ICorporation";
import { IIndustry } from "../IIndustry";
-import { CorporationRouting } from "./Routing";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { SetSmartSupply } from "../Actions";
@@ -438,7 +437,8 @@ function MaterialComponent(props: IMaterialProps): React.ReactElement {
interface IProps {
corp: ICorporation;
- routing: CorporationRouting;
+ division: IIndustry;
+ warehouse: Warehouse | 0;
currentCity: string;
player: IPlayer;
}
@@ -464,53 +464,49 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
}
function renderWarehouseUI(): React.ReactElement {
- const corp = props.corp;
- const division = props.routing.currentDivision; // Validated in render()
- if (division === null) return <>>;
- const warehouse = division.warehouses[props.currentCity]; // Validated in render()
- if (warehouse === 0) return <>>;
-
+ if (props.warehouse === 0) return <>>;
// General Storage information at the top
const sizeUsageStyle = {
- color: warehouse.sizeUsed >= warehouse.size ? "red" : "white",
+ color: props.warehouse.sizeUsed >= props.warehouse.size ? "red" : "white",
margin: "5px",
};
// Upgrade Warehouse size button
const sizeUpgradeCost =
CorporationConstants.WarehouseUpgradeBaseCost *
- Math.pow(1.07, warehouse.level + 1);
- const canAffordUpgrade = corp.funds.gt(sizeUpgradeCost);
+ Math.pow(1.07, props.warehouse.level + 1);
+ const canAffordUpgrade = props.corp.funds.gt(sizeUpgradeCost);
const upgradeWarehouseClass = canAffordUpgrade
? "std-button"
: "a-link-button-inactive";
function upgradeWarehouseOnClick(): void {
- if (division === null) return;
- if (warehouse === 0) return;
- ++warehouse.level;
- warehouse.updateSize(corp, division);
- corp.funds = corp.funds.minus(sizeUpgradeCost);
- corp.rerender(props.player);
+ if (props.division === null) return;
+ if (props.warehouse === 0) return;
+ ++props.warehouse.level;
+ props.warehouse.updateSize(props.corp, props.division);
+ props.corp.funds = props.corp.funds.minus(sizeUpgradeCost);
+ props.corp.rerender(props.player);
}
// Industry material Requirements
let generalReqsText =
"This Industry uses [" +
- Object.keys(division.reqMats).join(", ") +
+ Object.keys(props.division.reqMats).join(", ") +
"] in order to ";
- if (division.prodMats.length > 0) {
- generalReqsText += "produce [" + division.prodMats.join(", ") + "] ";
- if (division.makesProducts) {
- generalReqsText += " and " + division.getProductDescriptionText();
+ if (props.division.prodMats.length > 0) {
+ generalReqsText +=
+ "produce [" + props.division.prodMats.join(", ") + "] ";
+ if (props.division.makesProducts) {
+ generalReqsText += " and " + props.division.getProductDescriptionText();
}
- } else if (division.makesProducts) {
- generalReqsText += division.getProductDescriptionText() + ".";
+ } else if (props.division.makesProducts) {
+ generalReqsText += props.division.getProductDescriptionText() + ".";
}
const ratioLines = [];
- for (const matName in division.reqMats) {
- if (division.reqMats.hasOwnProperty(matName)) {
- const text = [" *", division.reqMats[matName], matName].join(" ");
+ for (const matName in props.division.reqMats) {
+ if (props.division.reqMats.hasOwnProperty(matName)) {
+ const text = [" *", props.division.reqMats[matName], matName].join(" ");
ratioLines.push(
{text}
@@ -520,19 +516,21 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
}
let createdItemsText = "in order to create ";
- if (division.prodMats.length > 0) {
+ if (props.division.prodMats.length > 0) {
createdItemsText +=
- "one of each produced Material (" + division.prodMats.join(", ") + ") ";
- if (division.makesProducts) {
+ "one of each produced Material (" +
+ props.division.prodMats.join(", ") +
+ ") ";
+ if (props.division.makesProducts) {
createdItemsText += "or to create one of its Products";
}
- } else if (division.makesProducts) {
+ } else if (props.division.makesProducts) {
createdItemsText += "one of its Products";
}
// Current State:
let stateText;
- switch (division.state) {
+ switch (props.division.state) {
case "START":
stateText = "Current state: Preparing...";
break;
@@ -549,32 +547,32 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
stateText = "Current state: Exporting materials and/or products...";
break;
default:
- console.error(`Invalid state: ${division.state}`);
+ console.error(`Invalid state: ${props.division.state}`);
break;
}
// Smart Supply Checkbox
const smartSupplyCheckboxId = "cmpy-mgmt-smart-supply-checkbox";
function smartSupplyOnChange(e: React.ChangeEvent
): void {
- if (warehouse === 0) return;
- SetSmartSupply(warehouse, e.target.checked);
- corp.rerender(props.player);
+ if (props.warehouse === 0) return;
+ SetSmartSupply(props.warehouse, e.target.checked);
+ props.corp.rerender(props.player);
}
// Create React components for materials
const mats = [];
- for (const matName in warehouse.materials) {
- if (warehouse.materials[matName] instanceof Material) {
+ for (const matName in props.warehouse.materials) {
+ if (props.warehouse.materials[matName] instanceof Material) {
// Only create UI for materials that are relevant for the industry
- if (isRelevantMaterial(matName, division)) {
+ if (isRelevantMaterial(matName, props.division)) {
mats.push(
,
);
}
@@ -583,16 +581,19 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
// Create React components for products
const products = [];
- if (division.makesProducts && Object.keys(division.products).length > 0) {
- for (const productName in division.products) {
- const product = division.products[productName];
+ if (
+ props.division.makesProducts &&
+ Object.keys(props.division.products).length > 0
+ ) {
+ for (const productName in props.division.products) {
+ const product = props.division.products[productName];
if (product instanceof Product) {
products.push(
,
@@ -604,11 +605,11 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
return (
- Storage: {numeralWrapper.formatBigNumber(warehouse.sizeUsed)} /{" "}
- {numeralWrapper.formatBigNumber(warehouse.size)}
+ Storage: {numeralWrapper.formatBigNumber(props.warehouse.sizeUsed)} /{" "}
+ {numeralWrapper.formatBigNumber(props.warehouse.size)}
@@ -632,7 +633,7 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
{stateText}
- {corp.unlockUpgrades[1] && (
+ {props.corp.unlockUpgrades[1] && (
)}
@@ -654,12 +655,6 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
);
}
- const division = props.routing.currentDivision;
- if (division == null) {
- throw new Error(`Routing does not hold reference to the current Industry`);
- }
- const warehouse = division.warehouses[props.currentCity];
-
function purchaseWarehouse(division: IIndustry, city: string): void {
if (props.corp.funds.lt(CorporationConstants.WarehouseInitialCost)) {
dialogBoxCreate("You do not have enough funds to do this!");
@@ -677,14 +672,14 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
}
}
- if (warehouse instanceof Warehouse) {
+ if (props.warehouse instanceof Warehouse) {
return renderWarehouseUI();
} else {
return (
);
}
diff --git a/src/Corporation/ui/Routing.ts b/src/Corporation/ui/Routing.ts
deleted file mode 100644
index fe0d97083..000000000
--- a/src/Corporation/ui/Routing.ts
+++ /dev/null
@@ -1,90 +0,0 @@
-import { ICorporation } from "../ICorporation";
-import { IIndustry } from "../IIndustry";
-
-export const overviewPage = "Overview";
-
-/**
- * Keeps track of what content is currently being displayed for the Corporation UI
- */
-export class CorporationRouting {
- private currentPage: string = overviewPage;
-
- // Stores a reference to the Corporation instance
- private corp: ICorporation;
-
- // Stores a reference to the Division instance that the routing is currently on
- // This will be null if routing is on the overview page
- currentDivision: IIndustry | null = null;
-
- constructor(corp: ICorporation) {
- this.corp = corp;
- }
-
- current(): string {
- return this.currentPage;
- }
-
- /**
- * Checks that the specified page has a valid value
- */
- isValidPage(page: string): boolean {
- if (page === overviewPage) {
- return true;
- }
-
- for (const division of this.corp.divisions) {
- if (division.name === page) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Returns a boolean indicating whether or not the player is on the given page
- */
- isOn(page: string): boolean {
- if (!this.isValidPage(page)) {
- return false;
- }
-
- return page === this.currentPage;
- }
-
- isOnOverviewPage(): boolean {
- return this.currentPage === overviewPage;
- }
-
- /**
- * Routes to the specified page
- */
- routeTo(page: string): void {
- if (!this.isValidPage(page)) {
- return;
- }
-
- this.currentDivision = null;
- if (page !== overviewPage) {
- // Iterate through Corporation data to get a reference to the current division
- for (let i = 0; i < this.corp.divisions.length; ++i) {
- if (this.corp.divisions[i].name === page) {
- this.currentDivision = this.corp.divisions[i];
- }
- }
-
- // 'currentDivision' should not be null, since the routing is either on
- // the overview page or a division page
- if (this.currentDivision == null) {
- console.warn(`Routing could not find division ${page}`);
- }
- }
-
- this.currentPage = page;
- }
-
- routeToOverviewPage(): void {
- this.currentPage = overviewPage;
- this.currentDivision = null;
- }
-}
diff --git a/src/Corporation/ui/SellProductPopup.tsx b/src/Corporation/ui/SellProductPopup.tsx
index 101d8369a..b50d7b49a 100644
--- a/src/Corporation/ui/SellProductPopup.tsx
+++ b/src/Corporation/ui/SellProductPopup.tsx
@@ -1,7 +1,6 @@
import React, { useState } from "react";
import { dialogBoxCreate } from "../../../utils/DialogBox";
import { removePopup } from "../../ui/React/createPopup";
-import { Cities } from "../../Locations/Cities";
import { Product } from "../Product";
import { SellProduct } from "../Actions";
diff --git a/src/Corporation/ui/UnlockUpgrade.tsx b/src/Corporation/ui/UnlockUpgrade.tsx
index a14466e5b..6198f5c5d 100644
--- a/src/Corporation/ui/UnlockUpgrade.tsx
+++ b/src/Corporation/ui/UnlockUpgrade.tsx
@@ -1,7 +1,6 @@
// React Components for the Unlock upgrade buttons on the overview page
import React from "react";
-import { numeralWrapper } from "../../ui/numeralFormat";
import { dialogBoxCreate } from "../../../utils/DialogBox";
import { CorporationUnlockUpgrade } from "../data/CorporationUnlockUpgrades";
import { ICorporation } from "../ICorporation";
diff --git a/src/DevMenu.jsx b/src/DevMenu.jsx
index bbcb9bd52..010d221db 100644
--- a/src/DevMenu.jsx
+++ b/src/DevMenu.jsx
@@ -746,8 +746,7 @@ class DevMenuComponent extends Component {
}
let sourceFiles = [];
- validSFN.forEach((i) =>
- sourceFiles.push(
+ validSFN.forEach((i) => sourceFiles.push(
|
SF-{i}:
diff --git a/src/Diagnostic/FileDiagnosticPopup.tsx b/src/Diagnostic/FileDiagnosticPopup.tsx
index 7287a1d87..9f456c914 100644
--- a/src/Diagnostic/FileDiagnosticPopup.tsx
+++ b/src/Diagnostic/FileDiagnosticPopup.tsx
@@ -1,7 +1,5 @@
import React from "react";
import { AllServers } from "../Server/AllServers";
-import { Script } from "../Script/Script";
-import { TextFile } from "../TextFile";
import { Accordion } from "../ui/React/Accordion";
import { numeralWrapper } from "../ui/numeralFormat";
@@ -61,9 +59,7 @@ export function ServerAccordion(props: IServerProps): React.ReactElement {
);
}
-interface IProps {}
-
-export function FileDiagnosticPopup(props: IProps): React.ReactElement {
+export function FileDiagnosticPopup(): React.ReactElement {
const ips: string[] = [];
for (const ip of Object.keys(AllServers)) {
ips.push(ip);
diff --git a/src/Faction/Faction.ts b/src/Faction/Faction.ts
index 368ff91d4..79dab3ca0 100644
--- a/src/Faction/Faction.ts
+++ b/src/Faction/Faction.ts
@@ -1,4 +1,3 @@
-import { CONSTANTS } from "../Constants";
import { FactionInfo, FactionInfos } from "./FactionInfo";
import { favorToRep, repToFavor } from "./formulas/favor";
import {
diff --git a/src/Faction/ui/AugmentationsPage.tsx b/src/Faction/ui/AugmentationsPage.tsx
index a0505b913..3c55e44ed 100644
--- a/src/Faction/ui/AugmentationsPage.tsx
+++ b/src/Faction/ui/AugmentationsPage.tsx
@@ -124,8 +124,7 @@ export class AugmentationsPage extends React.Component {
render(): React.ReactNode {
const augs = this.getAugsSorted();
const purchasable = augs.filter(
- (aug: string) =>
- aug === AugmentationNames.NeuroFluxGovernor ||
+ (aug: string) => aug === AugmentationNames.NeuroFluxGovernor ||
(!this.props.p.augmentations.some((a) => a.name === aug) &&
!this.props.p.queuedAugmentations.some((a) => a.name === aug)),
);
@@ -142,8 +141,7 @@ export class AugmentationsPage extends React.Component {
);
};
- const augListElems = purchasable.map((aug) =>
- purchaseableAugmentation(aug),
+ const augListElems = purchasable.map((aug) => purchaseableAugmentation(aug),
);
let ownedElem = <>>;
@@ -172,20 +170,17 @@ export class AugmentationsPage extends React.Component {
will enhance your abilities.
- this.switchSortOrder(PurchaseAugmentationsOrderSetting.Cost)
+ onClick={() => this.switchSortOrder(PurchaseAugmentationsOrderSetting.Cost)
}
text={"Sort by Cost"}
/>
- this.switchSortOrder(PurchaseAugmentationsOrderSetting.Reputation)
+ onClick={() => this.switchSortOrder(PurchaseAugmentationsOrderSetting.Reputation)
}
text={"Sort by Reputation"}
/>
- this.switchSortOrder(PurchaseAugmentationsOrderSetting.Default)
+ onClick={() => this.switchSortOrder(PurchaseAugmentationsOrderSetting.Default)
}
text={"Sort by Default Order"}
/>
diff --git a/src/Faction/ui/DonateOption.tsx b/src/Faction/ui/DonateOption.tsx
index 56043a114..aedfd7a1d 100644
--- a/src/Faction/ui/DonateOption.tsx
+++ b/src/Faction/ui/DonateOption.tsx
@@ -31,8 +31,6 @@ const inputStyleMarkup = {
height: "26px",
};
-const blockStyle = { display: "block" };
-
export function DonateOption(props: IProps): React.ReactElement {
const [donateAmt, setDonateAmt] = useState(null);
const digits = (CONSTANTS.DonateMoneyToRepDivisor + "").length - 1;
diff --git a/src/Gang/ui/GangMemberList.tsx b/src/Gang/ui/GangMemberList.tsx
index 8815f1a89..ecb5b36c9 100644
--- a/src/Gang/ui/GangMemberList.tsx
+++ b/src/Gang/ui/GangMemberList.tsx
@@ -33,8 +33,7 @@ export function GangMemberList(props: IProps): React.ReactElement {
}
const members = props.gang.members.filter(
- (member: GangMember) =>
- member.name.indexOf(filter) > -1 || member.task.indexOf(filter) > -1,
+ (member: GangMember) => member.name.indexOf(filter) > -1 || member.task.indexOf(filter) > -1,
);
return (
diff --git a/src/Gang/ui/TerritorySubpage.tsx b/src/Gang/ui/TerritorySubpage.tsx
index 52b50c76a..c3467909d 100644
--- a/src/Gang/ui/TerritorySubpage.tsx
+++ b/src/Gang/ui/TerritorySubpage.tsx
@@ -90,8 +90,7 @@ export function TerritorySubpage(props: IProps): React.ReactElement {
id="warfare"
type="checkbox"
style={{ display: "inline-block", margin: "2px" }}
- onChange={(event) =>
- (props.gang.territoryWarfareEngaged = event.target.checked)
+ onChange={(event) => (props.gang.territoryWarfareEngaged = event.target.checked)
}
/>
|