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
|
|
|
|
*/
|
|
|
|
import * as React from "react";
|
|
|
|
|
|
|
|
import { Location } from "../Location";
|
|
|
|
import { createStartCorporationPopup } from "../LocationsHelpers";
|
|
|
|
import { LocationName } from "../data/LocationNames";
|
|
|
|
|
|
|
|
import { IEngine } from "../../IEngine";
|
|
|
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
|
|
|
|
|
|
|
import { AutoupdatingStdButton } from "../../ui/React/AutoupdatingStdButton";
|
|
|
|
import { StdButton } from "../../ui/React/StdButton";
|
|
|
|
|
|
|
|
import { dialogBoxCreate } from "../../../utils/DialogBox";
|
|
|
|
|
|
|
|
type IProps = {
|
|
|
|
engine: IEngine;
|
|
|
|
loc: Location;
|
|
|
|
p: IPlayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
type IState = {
|
|
|
|
inBladeburner: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class SpecialLocation extends React.Component<IProps, IState> {
|
2019-04-04 02:08:11 +02:00
|
|
|
/**
|
|
|
|
* Stores button styling that sets them all to block display
|
|
|
|
*/
|
2021-05-01 09:17:31 +02:00
|
|
|
btnStyle: any;
|
2019-04-04 02:08:11 +02:00
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
constructor(props: IProps) {
|
|
|
|
super(props);
|
|
|
|
|
2019-04-04 02:08:11 +02:00
|
|
|
this.btnStyle = { display: "block" };
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
this.createCorporationPopup = this.createCorporationPopup.bind(this);
|
|
|
|
this.handleBladeburner = this.handleBladeburner.bind(this);
|
|
|
|
this.handleResleeving = this.handleResleeving.bind(this);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
inBladeburner: this.props.p.inBladeburner(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Click handler for "Create Corporation" button at Sector-12 City Hall
|
|
|
|
*/
|
2021-05-01 09:17:31 +02:00
|
|
|
createCorporationPopup(): void {
|
2019-04-01 11:23:25 +02:00
|
|
|
createStartCorporationPopup(this.props.p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Click handler for Bladeburner button at Sector-12 NSA
|
|
|
|
*/
|
2021-05-01 09:17:31 +02:00
|
|
|
handleBladeburner(): void {
|
2019-04-01 11:23:25 +02:00
|
|
|
const p = this.props.p;
|
|
|
|
if (p.inBladeburner()) {
|
|
|
|
// Enter Bladeburner division
|
|
|
|
this.props.engine.loadBladeburnerContent();
|
|
|
|
} else {
|
|
|
|
// Apply for Bladeburner division
|
|
|
|
if (p.strength >= 100 && p.defense >= 100 && p.dexterity >= 100 && p.agility >= 100) {
|
|
|
|
p.startBladeburner({ new: true });
|
|
|
|
dialogBoxCreate("You have been accepted into the Bladeburner division!");
|
|
|
|
this.setState({
|
|
|
|
inBladeburner: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const worldHeader = document.getElementById("world-menu-header");
|
|
|
|
if (worldHeader instanceof HTMLElement) {
|
|
|
|
worldHeader.click(); worldHeader.click();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dialogBoxCreate("Rejected! Please apply again when you have 100 of each combat stat (str, def, dex, agi)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Click handler for Resleeving button at New Tokyo VitaLife
|
|
|
|
*/
|
2021-05-01 09:17:31 +02:00
|
|
|
handleResleeving(): void {
|
2019-04-01 11:23:25 +02:00
|
|
|
this.props.engine.loadResleevingContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
renderBladeburner(): React.ReactNode {
|
2019-04-04 02:08:11 +02:00
|
|
|
if (!this.props.p.canAccessBladeburner()) { return null; }
|
2019-04-01 11:23:25 +02:00
|
|
|
const text = this.state.inBladeburner ? "Enter Bladeburner Headquarters" : "Apply to Bladeburner Division";
|
|
|
|
return (
|
|
|
|
<StdButton
|
|
|
|
onClick={this.handleBladeburner}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={text}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
renderCreateCorporation(): React.ReactNode {
|
2021-05-17 23:56:31 +02:00
|
|
|
if (!this.props.p.canAccessCorporation()) {
|
|
|
|
return <>
|
|
|
|
<p><i>A business man is yelling at a clerk. You should come back later.</i></p>
|
|
|
|
</>;
|
|
|
|
}
|
2019-04-01 11:23:25 +02:00
|
|
|
return (
|
|
|
|
<AutoupdatingStdButton
|
2019-04-04 02:08:11 +02:00
|
|
|
disabled={!this.props.p.canAccessCorporation() || this.props.p.hasCorporation()}
|
2019-04-01 11:23:25 +02:00
|
|
|
onClick={this.createCorporationPopup}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Create a Corporation"}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
renderResleeving(): React.ReactNode {
|
2019-04-04 02:08:11 +02:00
|
|
|
if (!this.props.p.canAccessResleeving()) { return null; }
|
2019-04-01 11:23:25 +02:00
|
|
|
return (
|
|
|
|
<StdButton
|
|
|
|
onClick={this.handleResleeving}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Re-Sleeve"}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-05-01 09:17:31 +02:00
|
|
|
render(): React.ReactNode {
|
2019-04-01 11:23:25 +02:00
|
|
|
switch (this.props.loc.name) {
|
|
|
|
case LocationName.NewTokyoVitaLife: {
|
|
|
|
return this.renderResleeving();
|
|
|
|
}
|
|
|
|
case LocationName.Sector12CityHall: {
|
|
|
|
return this.renderCreateCorporation();
|
|
|
|
}
|
|
|
|
case LocationName.Sector12NSA: {
|
|
|
|
return this.renderBladeburner();
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
console.error(`Location ${this.props.loc.name} doesn't have any special properties`);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|