2019-04-01 11:23:25 +02:00
|
|
|
/**
|
|
|
|
* React Subcomponent for displaying a location's UI, when that location has special
|
|
|
|
* actions/options/properties
|
|
|
|
*
|
|
|
|
* Examples:
|
|
|
|
* - Bladeburner @ NSA
|
|
|
|
* - Re-sleeving @ VitaLife
|
|
|
|
* - Create Corporation @ City Hall
|
|
|
|
*
|
|
|
|
* This subcomponent creates all of the buttons for interacting with those special
|
|
|
|
* properties
|
|
|
|
*/
|
2021-09-18 09:00:07 +02:00
|
|
|
import React, { useState } from "react";
|
2021-09-25 21:34:12 +02:00
|
|
|
import Typography from "@mui/material/Typography";
|
|
|
|
import Button from "@mui/material/Button";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
import { Location } from "../Location";
|
2021-09-29 01:38:51 +02:00
|
|
|
import { CreateCorporationModal } from "../../Corporation/ui/CreateCorporationModal";
|
2021-09-05 01:09:30 +02:00
|
|
|
import { LocationName } from "../data/LocationNames";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
2021-09-18 09:00:07 +02:00
|
|
|
import { use } from "../../ui/Context";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
2021-09-25 20:42:57 +02:00
|
|
|
import { dialogBoxCreate } from "../../ui/React/DialogBox";
|
2021-10-22 21:30:13 +02:00
|
|
|
import { SnackbarEvents } from "../../ui/React/Snackbar";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
|
|
|
type IProps = {
|
2021-09-05 01:09:30 +02:00
|
|
|
loc: Location;
|
|
|
|
};
|
2019-04-01 11:23:25 +02:00
|
|
|
|
2021-09-18 09:00:07 +02:00
|
|
|
export function SpecialLocation(props: IProps): React.ReactElement {
|
|
|
|
const player = use.Player();
|
|
|
|
const router = use.Router();
|
2021-09-20 05:29:02 +02:00
|
|
|
const setRerender = useState(false)[1];
|
2021-09-18 09:00:07 +02:00
|
|
|
const inBladeburner = player.inBladeburner();
|
2021-09-05 01:09:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Click handler for Bladeburner button at Sector-12 NSA
|
|
|
|
*/
|
2021-09-18 09:00:07 +02:00
|
|
|
function handleBladeburner(): void {
|
|
|
|
const p = player;
|
2021-09-05 01:09:30 +02:00
|
|
|
if (p.inBladeburner()) {
|
|
|
|
// Enter Bladeburner division
|
2021-09-18 09:00:07 +02:00
|
|
|
router.toBladeburner();
|
2021-09-05 01:09:30 +02:00
|
|
|
} else {
|
|
|
|
// Apply for Bladeburner division
|
2021-09-09 05:47:34 +02:00
|
|
|
if (p.strength >= 100 && p.defense >= 100 && p.dexterity >= 100 && p.agility >= 100) {
|
2021-09-05 01:09:30 +02:00
|
|
|
p.startBladeburner({ new: true });
|
2021-09-09 05:47:34 +02:00
|
|
|
dialogBoxCreate("You have been accepted into the Bladeburner division!");
|
2021-09-18 09:00:07 +02:00
|
|
|
setRerender((old) => !old);
|
2021-09-05 01:09:30 +02:00
|
|
|
|
|
|
|
const worldHeader = document.getElementById("world-menu-header");
|
|
|
|
if (worldHeader instanceof HTMLElement) {
|
|
|
|
worldHeader.click();
|
|
|
|
worldHeader.click();
|
2019-04-01 11:23:25 +02:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
} else {
|
2021-09-09 05:47:34 +02:00
|
|
|
dialogBoxCreate("Rejected! Please apply again when you have 100 of each combat stat (str, def, dex, agi)");
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-04-01 11:23:25 +02:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Click handler for Resleeving button at New Tokyo VitaLife
|
|
|
|
*/
|
2021-09-18 09:00:07 +02:00
|
|
|
function handleResleeving(): void {
|
|
|
|
router.toResleeves();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
|
|
|
|
2021-09-18 09:00:07 +02:00
|
|
|
function renderBladeburner(): React.ReactElement {
|
|
|
|
if (!player.canAccessBladeburner()) {
|
|
|
|
return <></>;
|
2019-04-01 11:23:25 +02:00
|
|
|
}
|
2021-09-18 09:00:07 +02:00
|
|
|
const text = inBladeburner ? "Enter Bladeburner Headquarters" : "Apply to Bladeburner Division";
|
2021-09-25 21:34:12 +02:00
|
|
|
return <Button onClick={handleBladeburner}>{text}</Button>;
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
|
|
|
|
2021-09-18 09:00:07 +02:00
|
|
|
function renderNoodleBar(): React.ReactElement {
|
2021-09-05 01:09:30 +02:00
|
|
|
function EatNoodles(): void {
|
2021-10-22 21:30:13 +02:00
|
|
|
SnackbarEvents.emit("You ate some delicious noodles and feel refreshed", "success");
|
|
|
|
}
|
2019-04-01 11:23:25 +02:00
|
|
|
|
2021-09-25 21:34:12 +02:00
|
|
|
return <Button onClick={EatNoodles}>Eat noodles</Button>;
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
|
|
|
|
2021-09-29 01:38:51 +02:00
|
|
|
function CreateCorporation(): React.ReactElement {
|
|
|
|
const [open, setOpen] = useState(false);
|
2021-09-18 09:00:07 +02:00
|
|
|
if (!player.canAccessCorporation()) {
|
2021-09-05 01:09:30 +02:00
|
|
|
return (
|
|
|
|
<>
|
2021-09-25 21:34:12 +02:00
|
|
|
<Typography>
|
2021-09-09 05:47:34 +02:00
|
|
|
<i>A business man is yelling at a clerk. You should come back later.</i>
|
2021-09-25 21:34:12 +02:00
|
|
|
</Typography>
|
2021-09-05 01:09:30 +02:00
|
|
|
</>
|
|
|
|
);
|
2021-08-19 22:37:59 +02:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
return (
|
2021-09-29 01:38:51 +02:00
|
|
|
<>
|
|
|
|
<Button disabled={!player.canAccessCorporation() || player.hasCorporation()} onClick={() => setOpen(true)}>
|
|
|
|
Create a Corporation
|
|
|
|
</Button>
|
|
|
|
<CreateCorporationModal open={open} onClose={() => setOpen(false)} />
|
|
|
|
</>
|
2021-09-05 01:09:30 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-18 09:00:07 +02:00
|
|
|
function renderResleeving(): React.ReactElement {
|
|
|
|
if (!player.canAccessResleeving()) {
|
|
|
|
return <></>;
|
2019-04-01 11:23:25 +02:00
|
|
|
}
|
2021-09-25 21:34:12 +02:00
|
|
|
return <Button onClick={handleResleeving}>Re-Sleeve</Button>;
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
|
|
|
|
2021-10-04 03:33:48 +02:00
|
|
|
function renderCotMG(): React.ReactElement {
|
|
|
|
// prettier-ignore
|
|
|
|
const symbol = <Typography sx={{lineHeight: '1em',whiteSpace: 'pre'}}>
|
|
|
|
{" `` "}<br />
|
|
|
|
{" -odmmNmds: "}<br />
|
|
|
|
{" `hNmo:..-omNh. "}<br />
|
|
|
|
{" yMd` `hNh "}<br />
|
|
|
|
{" mMd oNm "}<br />
|
|
|
|
{" oMNo .mM/ "}<br />
|
|
|
|
{" `dMN+ -mM+ "}<br />
|
|
|
|
{" -mMNo -mN+ "}<br />
|
|
|
|
{" .+- :mMNo/mN/ "}<br />
|
|
|
|
{":yNMd. :NMNNN/ "}<br />
|
|
|
|
{"-mMMMh. /NMMh` "}<br />
|
|
|
|
{" .dMMMd. /NMMMy` "}<br />
|
|
|
|
{" `yMMMd. /NNyNMMh` "}<br />
|
|
|
|
{" `sMMMd. +Nm: +NMMh. "}<br />
|
|
|
|
{" oMMMm- oNm: /NMMd. "}<br />
|
|
|
|
{" +NMMmsMm- :mMMd. "}<br />
|
|
|
|
{" /NMMMm- -mMMd. "}<br />
|
|
|
|
{" /MMMm- -mMMd. "}<br />
|
|
|
|
{" `sMNMMm- .mMmo "}<br />
|
|
|
|
{" `sMd:hMMm. ./. "}<br />
|
|
|
|
{" `yMy` `yNMd` "}<br />
|
|
|
|
{" `hMs` oMMy "}<br />
|
|
|
|
{" `hMh sMN- "}<br />
|
|
|
|
{" /MM- .NMo "}<br />
|
|
|
|
{" +MM: :MM+ "}<br />
|
|
|
|
{" sNNo-.`.-omNy` "}<br />
|
|
|
|
{" -smNNNNmdo- "}<br />
|
|
|
|
{" `..` "}</Typography>
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Typography>
|
|
|
|
A decrepit altar stands in the middle of a dilapidated church.
|
|
|
|
<br />
|
|
|
|
<br />A symbol is carved in the altar.
|
|
|
|
</Typography>
|
|
|
|
<br />
|
|
|
|
{symbol}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-18 09:00:07 +02:00
|
|
|
switch (props.loc.name) {
|
|
|
|
case LocationName.NewTokyoVitaLife: {
|
|
|
|
return renderResleeving();
|
|
|
|
}
|
|
|
|
case LocationName.Sector12CityHall: {
|
2021-09-29 01:38:51 +02:00
|
|
|
return <CreateCorporation />;
|
2021-09-18 09:00:07 +02:00
|
|
|
}
|
|
|
|
case LocationName.Sector12NSA: {
|
|
|
|
return renderBladeburner();
|
|
|
|
}
|
|
|
|
case LocationName.NewTokyoNoodleBar: {
|
|
|
|
return renderNoodleBar();
|
2019-04-01 11:23:25 +02:00
|
|
|
}
|
2021-10-04 03:33:48 +02:00
|
|
|
case LocationName.ChongqingChurchOfTheMachineGod: {
|
|
|
|
return renderCotMG();
|
|
|
|
}
|
2021-09-18 09:00:07 +02:00
|
|
|
default:
|
|
|
|
console.error(`Location ${props.loc.name} doesn't have any special properties`);
|
|
|
|
return <></>;
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-04-01 11:23:25 +02:00
|
|
|
}
|