From c1f842e5c7ac029819fb3e0b21edca40137d0416 Mon Sep 17 00:00:00 2001 From: omuretsu <84951833+Snarling@users.noreply.github.com> Date: Wed, 17 May 2023 17:28:24 -0400 Subject: [PATCH] More corporation renaming Just renaming files / functions. Industries are the static categories that divisions can operate within, divisions are the actual branches of the company. A lot of stuff was still written as if Industries are the actual branches of the company, which is even less accurate now that a corporation is allowed to have multiple divisions operating in the same industry. Also removed the incorrect tooltip description of what tea does (it's now just a flat +2 increase) --- src/Corporation/Actions.ts | 4 ++-- src/Corporation/ui/CityTabs.tsx | 4 ++-- src/Corporation/ui/CorporationRoot.tsx | 4 ++-- src/Corporation/ui/{Industry.tsx => Division.tsx} | 14 +++++++------- .../ui/{IndustryOffice.tsx => DivisionOffice.tsx} | 10 ++++------ .../{IndustryOverview.tsx => DivisionOverview.tsx} | 8 ++++---- ...IndustryWarehouse.tsx => DivisionWarehouse.tsx} | 6 +++--- .../{ExpandIndustryTab.tsx => NewDivisionTab.tsx} | 14 +++++++------- src/Corporation/ui/modals/SellDivisionModal.tsx | 2 +- src/NetscriptFunctions/Corporation.ts | 4 ++-- 10 files changed, 34 insertions(+), 36 deletions(-) rename src/Corporation/ui/{Industry.tsx => Division.tsx} (70%) rename src/Corporation/ui/{IndustryOffice.tsx => DivisionOffice.tsx} (97%) rename src/Corporation/ui/{IndustryOverview.tsx => DivisionOverview.tsx} (97%) rename src/Corporation/ui/{IndustryWarehouse.tsx => DivisionWarehouse.tsx} (97%) rename src/Corporation/ui/{ExpandIndustryTab.tsx => NewDivisionTab.tsx} (88%) diff --git a/src/Corporation/Actions.ts b/src/Corporation/Actions.ts index b3cef06d5..81521f9ac 100644 --- a/src/Corporation/Actions.ts +++ b/src/Corporation/Actions.ts @@ -17,7 +17,7 @@ import { CorpResearchName } from "@nsdefs"; import { isInteger } from "lodash"; import { getRecordValues } from "../Types/Record"; -export function NewIndustry(corporation: Corporation, industry: IndustryType, name: string): void { +export function NewDivision(corporation: Corporation, industry: IndustryType, name: string): void { if (corporation.divisions.size >= corporation.maxDivisions) throw new Error(`Cannot expand into ${industry} industry, too many divisions!`); @@ -45,7 +45,7 @@ export function NewIndustry(corporation: Corporation, industry: IndustryType, na } } -export function removeIndustry(corporation: Corporation, name: string) { +export function removeDivision(corporation: Corporation, name: string) { if (!corporation.divisions.has(name)) throw new Error("There is no division called " + name); corporation.divisions.delete(name); } diff --git a/src/Corporation/ui/CityTabs.tsx b/src/Corporation/ui/CityTabs.tsx index c7e4fbe65..b9dc17bdf 100644 --- a/src/Corporation/ui/CityTabs.tsx +++ b/src/Corporation/ui/CityTabs.tsx @@ -2,7 +2,7 @@ // These allow player to navigate between different cities for each industry import React, { useState } from "react"; import { OfficeSpace } from "../OfficeSpace"; -import { Industry } from "./Industry"; +import { Division } from "./Industry"; import { ExpandNewCity } from "./ExpandNewCity"; import { useDivision } from "./Context"; import Tabs from "@mui/material/Tabs"; @@ -29,7 +29,7 @@ export function CityTabs(props: IProps): React.ReactElement { return <>; } mainContent = ( - + ); } const canExpand = Object.values(CityName).length > getRecordKeys(division.offices).length; diff --git a/src/Corporation/ui/CorporationRoot.tsx b/src/Corporation/ui/CorporationRoot.tsx index 212b4bb33..f1ad84a6d 100644 --- a/src/Corporation/ui/CorporationRoot.tsx +++ b/src/Corporation/ui/CorporationRoot.tsx @@ -3,7 +3,7 @@ // divisions, see an overview of your corporation, or create a new industry import React, { useState } from "react"; import { MainPanel } from "./MainPanel"; -import { ExpandIndustryTab } from "./ExpandIndustryTab"; +import { NewDivisionTab } from "./ExpandIndustryTab"; import { Player } from "@player"; import { Context } from "./Context"; import { Overview } from "./Overview"; @@ -33,7 +33,7 @@ export function CorporationRoot(): React.ReactElement { {canExpand && } {divisionName === "Overview" && } - {divisionName === -1 && } + {divisionName === -1 && } {typeof divisionName === "string" && divisionName !== "Overview" && ( )} diff --git a/src/Corporation/ui/Industry.tsx b/src/Corporation/ui/Division.tsx similarity index 70% rename from src/Corporation/ui/Industry.tsx rename to src/Corporation/ui/Division.tsx index 323729d59..3dcada66d 100644 --- a/src/Corporation/ui/Industry.tsx +++ b/src/Corporation/ui/Division.tsx @@ -2,9 +2,9 @@ // This Industry component does NOT include the city tabs at the top import React from "react"; -import { IndustryOffice } from "./IndustryOffice"; -import { IndustryOverview } from "./IndustryOverview"; -import { IndustryWarehouse } from "./IndustryWarehouse"; +import { DivisionOffice } from "./DivisionOffice"; +import { DivisionOverview } from "./DivisionOverview"; +import { DivisionWarehouse } from "./DivisionWarehouse"; import { Warehouse } from "../Warehouse"; import { OfficeSpace } from "../OfficeSpace"; import { useCorporation, useDivision } from "./Context"; @@ -18,17 +18,17 @@ interface IProps { rerender: () => void; } -export function Industry(props: IProps): React.ReactElement { +export function Division(props: IProps): React.ReactElement { const corp = useCorporation(); const division = useDivision(); return ( - - + + - void; } @@ -91,7 +91,7 @@ function AutoAssignJob(props: IAutoAssignProps): React.ReactElement { ); } -function AutoManagement(props: IProps): React.ReactElement { +function AutoManagement(props: OfficeProps): React.ReactElement { const corp = useCorporation(); const division = useDivision(); @@ -251,7 +251,7 @@ function AutoManagement(props: IProps): React.ReactElement { ); } -export function IndustryOffice(props: IProps): React.ReactElement { +export function DivisionOffice(props: OfficeProps): React.ReactElement { const corp = useCorporation(); const division = useDivision(); const [upgradeOfficeSizeOpen, setUpgradeOfficeSizeOpen] = useState(false); @@ -300,9 +300,7 @@ export function IndustryOffice(props: IProps): React.ReactElement { {!division.hasResearch("AutoBrew") && ( BuyTea(corp, props.office)} > diff --git a/src/Corporation/ui/IndustryOverview.tsx b/src/Corporation/ui/DivisionOverview.tsx similarity index 97% rename from src/Corporation/ui/IndustryOverview.tsx rename to src/Corporation/ui/DivisionOverview.tsx index 1b71a305b..2e5540d2e 100644 --- a/src/Corporation/ui/IndustryOverview.tsx +++ b/src/Corporation/ui/DivisionOverview.tsx @@ -1,5 +1,5 @@ -// React Component for displaying an Industry's overview information -// (top-left panel in the Industry UI) +// React Component for displaying an Division's overview information +// (top-left panel in the Division UI) import React, { useState } from "react"; import { CorpUnlockName, IndustryType } from "../data/Enums"; @@ -90,11 +90,11 @@ function MakeProductButton(): React.ReactElement { ); } -interface IndustryOverviewProps { +interface DivisionOverviewProps { rerender: () => void; } -export function IndustryOverview(props: IndustryOverviewProps): React.ReactElement { +export function DivisionOverview(props: DivisionOverviewProps): React.ReactElement { const corp = useCorporation(); const division = useDivision(); const [helpOpen, setHelpOpen] = useState(false); diff --git a/src/Corporation/ui/IndustryWarehouse.tsx b/src/Corporation/ui/DivisionWarehouse.tsx similarity index 97% rename from src/Corporation/ui/IndustryWarehouse.tsx rename to src/Corporation/ui/DivisionWarehouse.tsx index 0a0131fb1..338aadd16 100644 --- a/src/Corporation/ui/IndustryWarehouse.tsx +++ b/src/Corporation/ui/DivisionWarehouse.tsx @@ -30,7 +30,7 @@ import createStyles from "@mui/styles/createStyles"; import { CityName } from "../../Enums"; import { CorpUnlockName } from "../data/Enums"; -interface IProps { +interface WarehouseProps { corp: Corporation; division: Division; warehouse?: Warehouse; @@ -46,7 +46,7 @@ const useStyles = makeStyles(() => }), ); -function WarehouseRoot(props: IProps): React.ReactElement { +function WarehouseRoot(props: WarehouseProps): React.ReactElement { const corp = useCorporation(); const division = useDivision(); const [smartSupplyOpen, setSmartSupplyOpen] = useState(false); @@ -188,7 +188,7 @@ function WarehouseRoot(props: IProps): React.ReactElement { ); } -export function IndustryWarehouse(props: IProps): React.ReactElement { +export function DivisionWarehouse(props: WarehouseProps): React.ReactElement { if (props.warehouse) { return ; } else { diff --git a/src/Corporation/ui/ExpandIndustryTab.tsx b/src/Corporation/ui/NewDivisionTab.tsx similarity index 88% rename from src/Corporation/ui/ExpandIndustryTab.tsx rename to src/Corporation/ui/NewDivisionTab.tsx index 9230d74aa..3b0e2200e 100644 --- a/src/Corporation/ui/ExpandIndustryTab.tsx +++ b/src/Corporation/ui/NewDivisionTab.tsx @@ -3,7 +3,7 @@ import { dialogBoxCreate } from "../../ui/React/DialogBox"; import { IndustryDescriptions, IndustriesData } from "../IndustryData"; import { IndustryType } from "../data/Enums"; import { useCorporation } from "./Context"; -import { NewIndustry } from "../Actions"; +import { NewDivision } from "../Actions"; import Typography from "@mui/material/Typography"; import { ButtonWithTooltip } from "../../ui/Components/ButtonWithTooltip"; @@ -16,7 +16,7 @@ interface IProps { setDivisionName: (name: string) => void; } -export function ExpandIndustryTab(props: IProps): React.ReactElement { +export function NewDivisionTab(props: IProps): React.ReactElement { const corp = useCorporation(); const allIndustries = Object.values(IndustryType).sort(); const [industry, setIndustry] = useState(allIndustries[0]); @@ -32,10 +32,10 @@ export function ExpandIndustryTab(props: IProps): React.ReactElement { ? "Insufficient corporation funds" : ""; - function newIndustry(): void { + function newDivision(): void { if (disabledText) return; try { - NewIndustry(corp, industry, name); + NewDivision(corp, industry, name); } catch (err) { dialogBoxCreate(err + ""); return; @@ -51,7 +51,7 @@ export function ExpandIndustryTab(props: IProps): React.ReactElement { } function onKeyDown(event: React.KeyboardEvent): void { - if (event.key === KEY.ENTER) newIndustry(); + if (event.key === KEY.ENTER) newDivision(); } function onIndustryChange(event: SelectChangeEvent): void { @@ -59,7 +59,7 @@ export function ExpandIndustryTab(props: IProps): React.ReactElement { } const desc = IndustryDescriptions(industry, corp); - if (desc === undefined) throw new Error(`Trying to create an industry that doesn't exists: '${industry}'`); + if (desc === undefined) throw new Error(`Desired industry for new division doesn't exists: '${industry}'`); return ( <> @@ -82,7 +82,7 @@ export function ExpandIndustryTab(props: IProps): React.ReactElement { {" "} - + Expand diff --git a/src/Corporation/ui/modals/SellDivisionModal.tsx b/src/Corporation/ui/modals/SellDivisionModal.tsx index f85616965..a861b258d 100644 --- a/src/Corporation/ui/modals/SellDivisionModal.tsx +++ b/src/Corporation/ui/modals/SellDivisionModal.tsx @@ -9,7 +9,7 @@ import { useCorporation } from "../../ui/Context"; import { CityName } from "../../../Enums"; import * as corpConstants from "../../data/Constants"; import { formatMoney } from "../../../ui/formatNumber"; -import { removeIndustry as removeDivision } from "../../Actions"; +import { removeDivision as removeDivision } from "../../Actions"; import { dialogBoxCreate } from "../../../ui/React/DialogBox"; import { getRecordKeys } from "../../../Types/Record"; diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index b38a13eeb..8be73d7a0 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -19,7 +19,7 @@ import { } from "@nsdefs"; import { - NewIndustry, + NewDivision, purchaseOffice, IssueDividends, IssueNewShares, @@ -712,7 +712,7 @@ export function NetscriptCorporation(): InternalAPI { } const divisionName = helpers.string(ctx, "divisionName", _divisionName); const corporation = getCorporation(); - NewIndustry(corporation, industryName, divisionName); + NewDivision(corporation, industryName, divisionName); }, expandCity: (ctx) => (_divisionName, _cityName) => { checkAccess(ctx);