mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
expand new city and new industry dont appear if you cant
This commit is contained in:
parent
506122f5b8
commit
66a593e06b
@ -10,6 +10,38 @@ import { OfficeSpace } from "../OfficeSpace";
|
|||||||
import { Industry } from "./Industry";
|
import { Industry } from "./Industry";
|
||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
|
|
||||||
|
interface IExpandButtonProps {
|
||||||
|
corp: ICorporation;
|
||||||
|
division: IIndustry;
|
||||||
|
setCity: (name: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ExpandButton(props: IExpandButtonProps) {
|
||||||
|
function openExpandNewCityModal(): void {
|
||||||
|
const popupId = "cmpy-mgmt-expand-city-popup";
|
||||||
|
createPopup(popupId, ExpandNewCityPopup, {
|
||||||
|
popupId: popupId,
|
||||||
|
corp: props.corp,
|
||||||
|
division: props.division,
|
||||||
|
cityStateSetter: props.setCity,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const possibleCities = Object.keys(props.division.offices).filter(
|
||||||
|
(cityName: string) => props.division.offices[cityName] === 0,
|
||||||
|
);
|
||||||
|
if (possibleCities.length === 0) return <></>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<CityTab
|
||||||
|
current={false}
|
||||||
|
key={"Expand into new City"}
|
||||||
|
name={"Expand into new City"}
|
||||||
|
onClick={openExpandNewCityModal}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
city: string;
|
city: string;
|
||||||
division: IIndustry;
|
division: IIndustry;
|
||||||
@ -20,16 +52,6 @@ interface IProps {
|
|||||||
export function CityTabs(props: IProps): React.ReactElement {
|
export function CityTabs(props: IProps): React.ReactElement {
|
||||||
const [city, setCity] = useState(props.city);
|
const [city, setCity] = useState(props.city);
|
||||||
|
|
||||||
function openExpandNewCityModal(): void {
|
|
||||||
const popupId = "cmpy-mgmt-expand-city-popup";
|
|
||||||
createPopup(popupId, ExpandNewCityPopup, {
|
|
||||||
popupId: popupId,
|
|
||||||
corp: props.corp,
|
|
||||||
division: props.division,
|
|
||||||
cityStateSetter: setCity,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const office = props.division.offices[city];
|
const office = props.division.offices[city];
|
||||||
if (office === 0) {
|
if (office === 0) {
|
||||||
setCity("Sector-12");
|
setCity("Sector-12");
|
||||||
@ -39,7 +61,8 @@ export function CityTabs(props: IProps): React.ReactElement {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{Object.values(props.division.offices).map(
|
{Object.values(props.division.offices).map(
|
||||||
(office: OfficeSpace | 0) => office !== 0 && (
|
(office: OfficeSpace | 0) =>
|
||||||
|
office !== 0 && (
|
||||||
<CityTab
|
<CityTab
|
||||||
current={city === office.loc}
|
current={city === office.loc}
|
||||||
key={office.loc}
|
key={office.loc}
|
||||||
@ -48,11 +71,10 @@ export function CityTabs(props: IProps): React.ReactElement {
|
|||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
)}
|
)}
|
||||||
<CityTab
|
<ExpandButton
|
||||||
current={false}
|
corp={props.corp}
|
||||||
key={"Expand into new City"}
|
division={props.division}
|
||||||
name={"Expand into new City"}
|
setCity={setCity}
|
||||||
onClick={openExpandNewCityModal}
|
|
||||||
/>
|
/>
|
||||||
<Industry
|
<Industry
|
||||||
corp={props.corp}
|
corp={props.corp}
|
||||||
|
@ -9,6 +9,42 @@ import { createPopup } from "../../ui/React/createPopup";
|
|||||||
import { ICorporation } from "../ICorporation";
|
import { ICorporation } from "../ICorporation";
|
||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
import { MainPanel } from "./MainPanel";
|
import { MainPanel } from "./MainPanel";
|
||||||
|
import { Industries } from "../IndustryData";
|
||||||
|
|
||||||
|
interface IExpandButtonProps {
|
||||||
|
corp: ICorporation;
|
||||||
|
setDivisionName: (name: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ExpandButton(props: IExpandButtonProps): React.ReactElement {
|
||||||
|
const allIndustries = Object.keys(Industries).sort();
|
||||||
|
const possibleIndustries = allIndustries
|
||||||
|
.filter(
|
||||||
|
(industryType: string) =>
|
||||||
|
props.corp.divisions.find(
|
||||||
|
(division: IIndustry) => division.type === industryType,
|
||||||
|
) === undefined,
|
||||||
|
)
|
||||||
|
.sort();
|
||||||
|
if (possibleIndustries.length === 0) return <></>;
|
||||||
|
|
||||||
|
function openNewIndustryPopup(): void {
|
||||||
|
const popupId = "cmpy-mgmt-expand-industry-popup";
|
||||||
|
createPopup(popupId, NewIndustryPopup, {
|
||||||
|
corp: props.corp,
|
||||||
|
setDivisionName: props.setDivisionName,
|
||||||
|
popupId: popupId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<HeaderTab
|
||||||
|
current={false}
|
||||||
|
onClick={openNewIndustryPopup}
|
||||||
|
text={"Expand into new Industry"}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
corp: ICorporation;
|
corp: ICorporation;
|
||||||
@ -18,15 +54,6 @@ interface IProps {
|
|||||||
export function HeaderTabs(props: IProps): React.ReactElement {
|
export function HeaderTabs(props: IProps): React.ReactElement {
|
||||||
const [divisionName, setDivisionName] = useState("Overview");
|
const [divisionName, setDivisionName] = useState("Overview");
|
||||||
|
|
||||||
function openNewIndustryPopup(): void {
|
|
||||||
const popupId = "cmpy-mgmt-expand-industry-popup";
|
|
||||||
createPopup(popupId, NewIndustryPopup, {
|
|
||||||
corp: props.corp,
|
|
||||||
setDivisionName: setDivisionName,
|
|
||||||
popupId: popupId,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
@ -44,11 +71,7 @@ export function HeaderTabs(props: IProps): React.ReactElement {
|
|||||||
text={division.name}
|
text={division.name}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<HeaderTab
|
<ExpandButton corp={props.corp} setDivisionName={setDivisionName} />
|
||||||
current={false}
|
|
||||||
onClick={openNewIndustryPopup}
|
|
||||||
text={"Expand into new Industry"}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<MainPanel
|
<MainPanel
|
||||||
corp={props.corp}
|
corp={props.corp}
|
||||||
|
Loading…
Reference in New Issue
Block a user