/** * 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 { 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 { /** * 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( ) } if (this.props.loc.types.includes(LocationType.Gym)) { content.push( ) } if (this.props.loc.types.includes(LocationType.Hospital)) { content.push( ) } if (this.props.loc.types.includes(LocationType.Slums)) { content.push( ) } if (this.props.loc.types.includes(LocationType.Special)) { content.push( ) } if (this.props.loc.types.includes(LocationType.TechVendor)) { content.push( ) } if (this.props.loc.types.includes(LocationType.TravelAgency)) { content.push( ) } if (this.props.loc.types.includes(LocationType.University)) { content.push( ) } return content; } render() { const locContent: React.ReactNode[] = this.getLocationSpecificContent(); return (

{this.props.loc.name}

{locContent}
) } }