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)
This commit is contained in:
omuretsu
2023-05-17 17:28:24 -04:00
parent 27a6b619eb
commit c1f842e5c7
10 changed files with 34 additions and 36 deletions

View File

@@ -17,7 +17,7 @@ import { CorpResearchName } from "@nsdefs";
import { isInteger } from "lodash"; import { isInteger } from "lodash";
import { getRecordValues } from "../Types/Record"; 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) 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!`);
@@ -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); if (!corporation.divisions.has(name)) throw new Error("There is no division called " + name);
corporation.divisions.delete(name); corporation.divisions.delete(name);
} }

View File

@@ -2,7 +2,7 @@
// These allow player to navigate between different cities for each industry // These allow player to navigate between different cities for each industry
import React, { useState } from "react"; import React, { useState } from "react";
import { OfficeSpace } from "../OfficeSpace"; import { OfficeSpace } from "../OfficeSpace";
import { Industry } from "./Industry"; import { Division } from "./Industry";
import { ExpandNewCity } from "./ExpandNewCity"; import { ExpandNewCity } from "./ExpandNewCity";
import { useDivision } from "./Context"; import { useDivision } from "./Context";
import Tabs from "@mui/material/Tabs"; import Tabs from "@mui/material/Tabs";
@@ -29,7 +29,7 @@ export function CityTabs(props: IProps): React.ReactElement {
return <></>; return <></>;
} }
mainContent = ( mainContent = (
<Industry rerender={props.rerender} city={city} warehouse={division.warehouses[city]} office={office} /> <Division rerender={props.rerender} city={city} warehouse={division.warehouses[city]} office={office} />
); );
} }
const canExpand = Object.values(CityName).length > getRecordKeys(division.offices).length; const canExpand = Object.values(CityName).length > getRecordKeys(division.offices).length;

View File

@@ -3,7 +3,7 @@
// divisions, see an overview of your corporation, or create a new industry // divisions, see an overview of your corporation, or create a new industry
import React, { useState } from "react"; import React, { useState } from "react";
import { MainPanel } from "./MainPanel"; import { MainPanel } from "./MainPanel";
import { ExpandIndustryTab } from "./ExpandIndustryTab"; import { NewDivisionTab } from "./ExpandIndustryTab";
import { Player } from "@player"; import { Player } from "@player";
import { Context } from "./Context"; import { Context } from "./Context";
import { Overview } from "./Overview"; import { Overview } from "./Overview";
@@ -33,7 +33,7 @@ export function CorporationRoot(): React.ReactElement {
{canExpand && <Tab label={"Expand"} value={-1} />} {canExpand && <Tab label={"Expand"} value={-1} />}
</Tabs> </Tabs>
{divisionName === "Overview" && <Overview rerender={rerender} />} {divisionName === "Overview" && <Overview rerender={rerender} />}
{divisionName === -1 && <ExpandIndustryTab setDivisionName={setDivisionName} />} {divisionName === -1 && <NewDivisionTab setDivisionName={setDivisionName} />}
{typeof divisionName === "string" && divisionName !== "Overview" && ( {typeof divisionName === "string" && divisionName !== "Overview" && (
<MainPanel rerender={rerender} divisionName={divisionName + ""} /> <MainPanel rerender={rerender} divisionName={divisionName + ""} />
)} )}

View File

@@ -2,9 +2,9 @@
// This Industry component does NOT include the city tabs at the top // This Industry component does NOT include the city tabs at the top
import React from "react"; import React from "react";
import { IndustryOffice } from "./IndustryOffice"; import { DivisionOffice } from "./DivisionOffice";
import { IndustryOverview } from "./IndustryOverview"; import { DivisionOverview } from "./DivisionOverview";
import { IndustryWarehouse } from "./IndustryWarehouse"; import { DivisionWarehouse } from "./DivisionWarehouse";
import { Warehouse } from "../Warehouse"; import { Warehouse } from "../Warehouse";
import { OfficeSpace } from "../OfficeSpace"; import { OfficeSpace } from "../OfficeSpace";
import { useCorporation, useDivision } from "./Context"; import { useCorporation, useDivision } from "./Context";
@@ -18,17 +18,17 @@ interface IProps {
rerender: () => void; rerender: () => void;
} }
export function Industry(props: IProps): React.ReactElement { export function Division(props: IProps): React.ReactElement {
const corp = useCorporation(); const corp = useCorporation();
const division = useDivision(); const division = useDivision();
return ( return (
<Box display="flex"> <Box display="flex">
<Box sx={{ width: "50%" }}> <Box sx={{ width: "50%" }}>
<IndustryOverview rerender={props.rerender} /> <DivisionOverview rerender={props.rerender} />
<IndustryOffice rerender={props.rerender} office={props.office} /> <DivisionOffice rerender={props.rerender} office={props.office} />
</Box> </Box>
<Box sx={{ width: "50%" }}> <Box sx={{ width: "50%" }}>
<IndustryWarehouse <DivisionWarehouse
rerender={props.rerender} rerender={props.rerender}
corp={corp} corp={corp}
currentCity={props.city} currentCity={props.city}

View File

@@ -28,7 +28,7 @@ import TableRow from "@mui/material/TableRow";
import { TableCell } from "../../ui/React/Table"; import { TableCell } from "../../ui/React/Table";
import { Box } from "@mui/material"; import { Box } from "@mui/material";
interface IProps { interface OfficeProps {
office: OfficeSpace; office: OfficeSpace;
rerender: () => void; rerender: () => 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 corp = useCorporation();
const division = useDivision(); 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 corp = useCorporation();
const division = useDivision(); const division = useDivision();
const [upgradeOfficeSizeOpen, setUpgradeOfficeSizeOpen] = useState(false); const [upgradeOfficeSizeOpen, setUpgradeOfficeSizeOpen] = useState(false);
@@ -300,9 +300,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
{!division.hasResearch("AutoBrew") && ( {!division.hasResearch("AutoBrew") && (
<ButtonWithTooltip <ButtonWithTooltip
normalTooltip={ normalTooltip={"Provide your employees with tea to increase their energy"}
"Provide your employees with tea, increasing their energy by half the difference to 100%, plus 1.5%"
}
disabledTooltip={teaDisabledText} disabledTooltip={teaDisabledText}
onClick={() => BuyTea(corp, props.office)} onClick={() => BuyTea(corp, props.office)}
> >

View File

@@ -1,5 +1,5 @@
// React Component for displaying an Industry's overview information // React Component for displaying an Division's overview information
// (top-left panel in the Industry UI) // (top-left panel in the Division UI)
import React, { useState } from "react"; import React, { useState } from "react";
import { CorpUnlockName, IndustryType } from "../data/Enums"; import { CorpUnlockName, IndustryType } from "../data/Enums";
@@ -90,11 +90,11 @@ function MakeProductButton(): React.ReactElement {
); );
} }
interface IndustryOverviewProps { interface DivisionOverviewProps {
rerender: () => void; rerender: () => void;
} }
export function IndustryOverview(props: IndustryOverviewProps): React.ReactElement { export function DivisionOverview(props: DivisionOverviewProps): React.ReactElement {
const corp = useCorporation(); const corp = useCorporation();
const division = useDivision(); const division = useDivision();
const [helpOpen, setHelpOpen] = useState(false); const [helpOpen, setHelpOpen] = useState(false);

View File

@@ -30,7 +30,7 @@ import createStyles from "@mui/styles/createStyles";
import { CityName } from "../../Enums"; import { CityName } from "../../Enums";
import { CorpUnlockName } from "../data/Enums"; import { CorpUnlockName } from "../data/Enums";
interface IProps { interface WarehouseProps {
corp: Corporation; corp: Corporation;
division: Division; division: Division;
warehouse?: Warehouse; 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 corp = useCorporation();
const division = useDivision(); const division = useDivision();
const [smartSupplyOpen, setSmartSupplyOpen] = useState(false); 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) { if (props.warehouse) {
return <WarehouseRoot {...props} />; return <WarehouseRoot {...props} />;
} else { } else {

View File

@@ -3,7 +3,7 @@ import { dialogBoxCreate } from "../../ui/React/DialogBox";
import { IndustryDescriptions, IndustriesData } from "../IndustryData"; import { IndustryDescriptions, IndustriesData } from "../IndustryData";
import { IndustryType } from "../data/Enums"; import { IndustryType } from "../data/Enums";
import { useCorporation } from "./Context"; import { useCorporation } from "./Context";
import { NewIndustry } from "../Actions"; import { NewDivision } from "../Actions";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import { ButtonWithTooltip } from "../../ui/Components/ButtonWithTooltip"; import { ButtonWithTooltip } from "../../ui/Components/ButtonWithTooltip";
@@ -16,7 +16,7 @@ interface IProps {
setDivisionName: (name: string) => void; setDivisionName: (name: string) => void;
} }
export function ExpandIndustryTab(props: IProps): React.ReactElement { export function NewDivisionTab(props: IProps): React.ReactElement {
const corp = useCorporation(); const corp = useCorporation();
const allIndustries = Object.values(IndustryType).sort(); const allIndustries = Object.values(IndustryType).sort();
const [industry, setIndustry] = useState(allIndustries[0]); const [industry, setIndustry] = useState(allIndustries[0]);
@@ -32,10 +32,10 @@ export function ExpandIndustryTab(props: IProps): React.ReactElement {
? "Insufficient corporation funds" ? "Insufficient corporation funds"
: ""; : "";
function newIndustry(): void { function newDivision(): void {
if (disabledText) return; if (disabledText) return;
try { try {
NewIndustry(corp, industry, name); NewDivision(corp, industry, name);
} catch (err) { } catch (err) {
dialogBoxCreate(err + ""); dialogBoxCreate(err + "");
return; return;
@@ -51,7 +51,7 @@ export function ExpandIndustryTab(props: IProps): React.ReactElement {
} }
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void { function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
if (event.key === KEY.ENTER) newIndustry(); if (event.key === KEY.ENTER) newDivision();
} }
function onIndustryChange(event: SelectChangeEvent): void { function onIndustryChange(event: SelectChangeEvent): void {
@@ -59,7 +59,7 @@ export function ExpandIndustryTab(props: IProps): React.ReactElement {
} }
const desc = IndustryDescriptions(industry, corp); 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 ( return (
<> <>
@@ -82,7 +82,7 @@ export function ExpandIndustryTab(props: IProps): React.ReactElement {
<Box display="flex" alignItems="center"> <Box display="flex" alignItems="center">
<TextField autoFocus={true} value={name} onChange={onNameChange} onKeyDown={onKeyDown} type="text"></TextField>{" "} <TextField autoFocus={true} value={name} onChange={onNameChange} onKeyDown={onKeyDown} type="text"></TextField>{" "}
<ButtonWithTooltip disabledTooltip={disabledText} onClick={newIndustry}> <ButtonWithTooltip disabledTooltip={disabledText} onClick={newDivision}>
Expand Expand
</ButtonWithTooltip> </ButtonWithTooltip>
</Box> </Box>

View File

@@ -9,7 +9,7 @@ import { useCorporation } from "../../ui/Context";
import { CityName } from "../../../Enums"; import { CityName } from "../../../Enums";
import * as corpConstants from "../../data/Constants"; import * as corpConstants from "../../data/Constants";
import { formatMoney } from "../../../ui/formatNumber"; import { formatMoney } from "../../../ui/formatNumber";
import { removeIndustry as removeDivision } from "../../Actions"; import { removeDivision as removeDivision } from "../../Actions";
import { dialogBoxCreate } from "../../../ui/React/DialogBox"; import { dialogBoxCreate } from "../../../ui/React/DialogBox";
import { getRecordKeys } from "../../../Types/Record"; import { getRecordKeys } from "../../../Types/Record";

View File

@@ -19,7 +19,7 @@ import {
} from "@nsdefs"; } from "@nsdefs";
import { import {
NewIndustry, NewDivision,
purchaseOffice, purchaseOffice,
IssueDividends, IssueDividends,
IssueNewShares, IssueNewShares,
@@ -712,7 +712,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
} }
const divisionName = helpers.string(ctx, "divisionName", _divisionName); const divisionName = helpers.string(ctx, "divisionName", _divisionName);
const corporation = getCorporation(); const corporation = getCorporation();
NewIndustry(corporation, industryName, divisionName); NewDivision(corporation, industryName, divisionName);
}, },
expandCity: (ctx) => (_divisionName, _cityName) => { expandCity: (ctx) => (_divisionName, _cityName) => {
checkAccess(ctx); checkAccess(ctx);