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

@ -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);
}

@ -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 = (
<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;

@ -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 && <Tab label={"Expand"} value={-1} />}
</Tabs>
{divisionName === "Overview" && <Overview rerender={rerender} />}
{divisionName === -1 && <ExpandIndustryTab setDivisionName={setDivisionName} />}
{divisionName === -1 && <NewDivisionTab setDivisionName={setDivisionName} />}
{typeof divisionName === "string" && divisionName !== "Overview" && (
<MainPanel rerender={rerender} divisionName={divisionName + ""} />
)}

@ -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 (
<Box display="flex">
<Box sx={{ width: "50%" }}>
<IndustryOverview rerender={props.rerender} />
<IndustryOffice rerender={props.rerender} office={props.office} />
<DivisionOverview rerender={props.rerender} />
<DivisionOffice rerender={props.rerender} office={props.office} />
</Box>
<Box sx={{ width: "50%" }}>
<IndustryWarehouse
<DivisionWarehouse
rerender={props.rerender}
corp={corp}
currentCity={props.city}

@ -28,7 +28,7 @@ import TableRow from "@mui/material/TableRow";
import { TableCell } from "../../ui/React/Table";
import { Box } from "@mui/material";
interface IProps {
interface OfficeProps {
office: OfficeSpace;
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 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") && (
<ButtonWithTooltip
normalTooltip={
"Provide your employees with tea, increasing their energy by half the difference to 100%, plus 1.5%"
}
normalTooltip={"Provide your employees with tea to increase their energy"}
disabledTooltip={teaDisabledText}
onClick={() => BuyTea(corp, props.office)}
>

@ -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);

@ -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 <WarehouseRoot {...props} />;
} else {

@ -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<HTMLInputElement>): 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 {
<Box display="flex" alignItems="center">
<TextField autoFocus={true} value={name} onChange={onNameChange} onKeyDown={onKeyDown} type="text"></TextField>{" "}
<ButtonWithTooltip disabledTooltip={disabledText} onClick={newIndustry}>
<ButtonWithTooltip disabledTooltip={disabledText} onClick={newDivision}>
Expand
</ButtonWithTooltip>
</Box>

@ -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";

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