/** * React Subcomponent for displaying a location's UI, when that location is a gym * * This subcomponent renders all of the buttons for training at the gym */ import * as React from "react"; import { Blackjack } from "../../Casino/Blackjack"; import { CoinFlip } from "../../Casino/CoinFlip"; import { Roulette } from "../../Casino/Roulette"; import { SlotMachine } from "../../Casino/SlotMachine"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { StdButton } from "../../ui/React/StdButton"; enum GameType { None = 'none', Coin = 'coin', Slots = 'slots', Roulette = 'roulette', Blackjack = 'blackjack', } type IProps = { p: IPlayer; } type IState = { game: GameType; } export class CasinoLocation extends React.Component { constructor(props: IProps) { super(props); this.state = { game: GameType.None, } this.updateGame = this.updateGame.bind(this); } updateGame(game: GameType): void { this.setState({ game, }); } renderGames(): React.ReactNode { return (<> this.updateGame(GameType.Coin)} text={"Play coin flip"} />
this.updateGame(GameType.Slots)} text={"Play slots"} />
this.updateGame(GameType.Roulette)} text={"Play roulette"} />
this.updateGame(GameType.Blackjack)} text={"Play blackjack"} /> ) } renderGame(): React.ReactNode { let elem = null; switch(this.state.game) { case GameType.Coin: elem = break; case GameType.Slots: elem = break; case GameType.Roulette: elem = break; case GameType.Blackjack: elem = break; case GameType.None: break; default: throw new Error(`MissingCaseException: ${this.state.game}`); } return ( <> this.updateGame(GameType.None)} text={"Stop playing"} /> {elem} ) } render(): React.ReactNode { if(this.state.game === GameType.None) { return this.renderGames(); } else { return this.renderGame(); } } }