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";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
import { Location } from "../Location";
|
2021-09-11 09:19:52 +02:00
|
|
|
import { CreateCorporationPopup } from "../../Corporation/ui/CreateCorporationPopup";
|
|
|
|
import { createPopup } from "../../ui/React/createPopup";
|
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-05 01:09:30 +02:00
|
|
|
import { AutoupdatingStdButton } from "../../ui/React/AutoupdatingStdButton";
|
|
|
|
import { StdButton } from "../../ui/React/StdButton";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
import { dialogBoxCreate } from "../../../utils/DialogBox";
|
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 "Create Corporation" button at Sector-12 City Hall
|
|
|
|
*/
|
2021-09-18 09:00:07 +02:00
|
|
|
function createCorporationPopup(): void {
|
2021-09-11 09:19:52 +02:00
|
|
|
const popupId = `create-start-corporation-popup`;
|
|
|
|
createPopup(popupId, CreateCorporationPopup, {
|
2021-09-18 09:00:07 +02:00
|
|
|
player: player,
|
2021-09-11 09:19:52 +02:00
|
|
|
popupId: popupId,
|
2021-09-21 23:38:51 +02:00
|
|
|
router: router,
|
2021-09-11 09:19:52 +02:00
|
|
|
});
|
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";
|
|
|
|
return <StdButton onClick={handleBladeburner} style={{ display: "block" }} text={text} />;
|
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 {
|
|
|
|
dialogBoxCreate(<>You ate some delicious noodles and feel refreshed.</>);
|
2019-04-01 11:23:25 +02:00
|
|
|
}
|
|
|
|
|
2021-09-18 09:00:07 +02:00
|
|
|
return <StdButton onClick={EatNoodles} style={{ display: "block" }} text={"Eat noodles"} />;
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
|
|
|
|
2021-09-18 09:00:07 +02:00
|
|
|
function renderCreateCorporation(): React.ReactElement {
|
|
|
|
if (!player.canAccessCorporation()) {
|
2021-09-05 01:09:30 +02:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<p>
|
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-05 01:09:30 +02:00
|
|
|
</p>
|
|
|
|
</>
|
|
|
|
);
|
2021-08-19 22:37:59 +02:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
return (
|
|
|
|
<AutoupdatingStdButton
|
2021-09-18 09:00:07 +02:00
|
|
|
disabled={!player.canAccessCorporation() || player.hasCorporation()}
|
|
|
|
onClick={createCorporationPopup}
|
|
|
|
style={{ display: "block" }}
|
2021-09-05 01:09:30 +02:00
|
|
|
text={"Create a Corporation"}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
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-18 09:00:07 +02:00
|
|
|
return <StdButton onClick={handleResleeving} style={{ display: "block" }} text={"Re-Sleeve"} />;
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
|
|
|
|
2021-09-18 09:00:07 +02:00
|
|
|
switch (props.loc.name) {
|
|
|
|
case LocationName.NewTokyoVitaLife: {
|
|
|
|
return renderResleeving();
|
|
|
|
}
|
|
|
|
case LocationName.Sector12CityHall: {
|
|
|
|
return renderCreateCorporation();
|
|
|
|
}
|
|
|
|
case LocationName.Sector12NSA: {
|
|
|
|
return renderBladeburner();
|
|
|
|
}
|
|
|
|
case LocationName.NewTokyoNoodleBar: {
|
|
|
|
return renderNoodleBar();
|
2019-04-01 11:23:25 +02:00
|
|
|
}
|
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
|
|
|
}
|