2019-03-29 08:12:41 +01:00
|
|
|
/**
|
|
|
|
* 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";
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
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";
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
import { Location } from "../Location";
|
|
|
|
import { LocationType } from "../LocationTypeEnum";
|
|
|
|
import { CityName } from "../data/CityNames";
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
import { IEngine } from "../../IEngine";
|
|
|
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
|
|
|
|
|
|
|
import { StdButton } from "../../ui/React/StdButton";
|
2019-03-29 08:12:41 +01:00
|
|
|
|
|
|
|
type IProps = {
|
2019-04-01 11:23:25 +02:00
|
|
|
engine: IEngine;
|
|
|
|
loc: Location;
|
2019-03-29 08:12:41 +01:00
|
|
|
p: IPlayer;
|
|
|
|
returnToCity: () => void;
|
2019-04-01 11:23:25 +02:00
|
|
|
travel: (to: CityName) => void;
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export class GenericLocation extends React.Component<IProps, any> {
|
|
|
|
/**
|
|
|
|
* 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[] = [];
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
if (this.props.loc.types.includes(LocationType.Company)) {
|
|
|
|
content.push(
|
|
|
|
<CompanyLocation
|
|
|
|
engine={this.props.engine}
|
|
|
|
locName={this.props.loc.name}
|
|
|
|
p={this.props.p}
|
|
|
|
/>
|
|
|
|
)
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
if (this.props.loc.types.includes(LocationType.Gym)) {
|
|
|
|
content.push(
|
|
|
|
<GymLocation
|
|
|
|
loc={this.props.loc}
|
|
|
|
p={this.props.p}
|
|
|
|
/>
|
|
|
|
)
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
if (this.props.loc.types.includes(LocationType.Hospital)) {
|
|
|
|
content.push(
|
|
|
|
<HospitalLocation
|
|
|
|
p={this.props.p}
|
|
|
|
/>
|
|
|
|
)
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
if (this.props.loc.types.includes(LocationType.Slums)) {
|
|
|
|
content.push(
|
|
|
|
<SlumsLocation
|
|
|
|
p={this.props.p}
|
|
|
|
/>
|
|
|
|
)
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
if (this.props.loc.types.includes(LocationType.Special)) {
|
|
|
|
content.push(
|
|
|
|
<SpecialLocation
|
|
|
|
engine={this.props.engine}
|
|
|
|
loc={this.props.loc}
|
|
|
|
p={this.props.p}
|
|
|
|
/>
|
|
|
|
)
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
if (this.props.loc.types.includes(LocationType.TechVendor)) {
|
|
|
|
content.push(
|
|
|
|
<TechVendorLocation
|
|
|
|
loc={this.props.loc}
|
|
|
|
p={this.props.p}
|
|
|
|
/>
|
|
|
|
)
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
if (this.props.loc.types.includes(LocationType.TravelAgency)) {
|
|
|
|
content.push(
|
|
|
|
<TravelAgencyLocation
|
|
|
|
p={this.props.p}
|
|
|
|
travel={this.props.travel}
|
|
|
|
/>
|
|
|
|
)
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
if (this.props.loc.types.includes(LocationType.University)) {
|
|
|
|
content.push(
|
|
|
|
<UniversityLocation
|
|
|
|
loc={this.props.loc}
|
|
|
|
p={this.props.p}
|
|
|
|
/>
|
|
|
|
)
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
return content;
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const locContent: React.ReactNode[] = this.getLocationSpecificContent();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<StdButton onClick={this.props.returnToCity} text={"Return to world"} />
|
|
|
|
<br />
|
2019-04-01 11:23:25 +02:00
|
|
|
<h1>{this.props.loc.name}</h1>
|
2019-03-29 08:12:41 +01:00
|
|
|
{locContent}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|