bitburner-src/src/Locations/ui/GenericLocation.tsx
hydroflame 925e96345d
v0.51.2 (#838)
* infiltration use buttons instead of a links

* minor accessibility patch

* Hospitalization will not cost more than 10% of the players money.

* Adde hospitalization netscript function

* Removed the suggestion that the combat path will lead to Daedalus, it still will. But new players should not be told that this is a viable path to completing a BitNode.

* getMemberInformation now returns everything about the member.

* New netscript function to get the players hacknet server hash capacity

* yesno dialog box will not keep older messages anymore

* v0.51.1

* Casino part 1

* Discord link in options, documentation for getMemberInformation updated, dev menu has more money options, tech vendors now handle max cores or max ram better

* Removed text under Factiosn referencing rejected factions.

* Removed html element forgotten in plain text

* Casino implementation

* v0.51.2
2021-04-09 18:12:31 -04:00

159 lines
4.8 KiB
TypeScript

/**
* React Component for displaying a location's UI
*
* This is a "router" component of sorts, meaning it deduces the type of
* location that is being rendered and then creates the proper component(s) for that.
*/
import * as React from "react";
import { CompanyLocation } from "./CompanyLocation";
import { GymLocation } from "./GymLocation";
import { HospitalLocation } from "./HospitalLocation";
import { SlumsLocation } from "./SlumsLocation";
import { SpecialLocation } from "./SpecialLocation";
import { TechVendorLocation } from "./TechVendorLocation";
import { TravelAgencyLocation } from "./TravelAgencyLocation";
import { UniversityLocation } from "./UniversityLocation";
import { CasinoLocation } from "./CasinoLocation";
import { Location } from "../Location";
import { LocationType } from "../LocationTypeEnum";
import { CityName } from "../data/CityNames";
import { IEngine } from "../../IEngine";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { StdButton } from "../../ui/React/StdButton";
type IProps = {
engine: IEngine;
loc: Location;
p: IPlayer;
returnToCity: () => void;
travel: (to: CityName) => void;
}
export class GenericLocation extends React.Component<IProps, any> {
/**
* Stores button styling that sets them all to block display
*/
btnStyle: object;
constructor(props: IProps) {
super(props);
this.btnStyle = { display: "block" };
}
/**
* Determine what needs to be rendered for this location based on the locations
* type. Returns an array of React components that should be rendered
*/
getLocationSpecificContent(): React.ReactNode[] {
const content: React.ReactNode[] = [];
if (this.props.loc.types.includes(LocationType.Company)) {
content.push(
<CompanyLocation
engine={this.props.engine}
key={"companylocation"}
locName={this.props.loc.name}
p={this.props.p}
/>
)
}
if (this.props.loc.types.includes(LocationType.Gym)) {
content.push(
<GymLocation
key={"gymlocation"}
loc={this.props.loc}
p={this.props.p}
/>
)
}
if (this.props.loc.types.includes(LocationType.Hospital)) {
content.push(
<HospitalLocation
key={"hospitallocation"}
p={this.props.p}
/>
)
}
if (this.props.loc.types.includes(LocationType.Slums)) {
content.push(
<SlumsLocation
key={"slumslocation"}
p={this.props.p}
/>
)
}
if (this.props.loc.types.includes(LocationType.Special)) {
content.push(
<SpecialLocation
engine={this.props.engine}
key={"speciallocation"}
loc={this.props.loc}
p={this.props.p}
/>
)
}
if (this.props.loc.types.includes(LocationType.TechVendor)) {
content.push(
<TechVendorLocation
key={"techvendorlocation"}
loc={this.props.loc}
p={this.props.p}
/>
)
}
if (this.props.loc.types.includes(LocationType.TravelAgency)) {
content.push(
<TravelAgencyLocation
key={"travelagencylocation"}
p={this.props.p}
travel={this.props.travel}
/>
)
}
if (this.props.loc.types.includes(LocationType.University)) {
content.push(
<UniversityLocation
key={"universitylocation"}
loc={this.props.loc}
p={this.props.p}
/>
)
}
if (this.props.loc.types.includes(LocationType.Casino)) {
content.push(
<CasinoLocation
key={"casinoLocation"}
p={this.props.p}
/>
)
}
return content;
}
render() {
const locContent: React.ReactNode[] = this.getLocationSpecificContent();
return (
<div>
<StdButton onClick={this.props.returnToCity} style={this.btnStyle} text={"Return to World"} />
<h1>{this.props.loc.name}</h1>
{locContent}
</div>
)
}
}