2021-04-10 00:12:31 +02:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2021-10-01 07:00:50 +02:00
|
|
|
import React, { useState } from "react";
|
2021-09-25 21:42:37 +02:00
|
|
|
import Button from "@mui/material/Button";
|
2021-04-29 02:07:26 +02:00
|
|
|
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";
|
2022-01-15 06:12:16 +01:00
|
|
|
import { Box } from "@mui/material";
|
2021-04-10 00:12:31 +02:00
|
|
|
|
2021-04-29 02:07:26 +02:00
|
|
|
enum GameType {
|
2021-09-05 01:09:30 +02:00
|
|
|
None = "none",
|
|
|
|
Coin = "coin",
|
|
|
|
Slots = "slots",
|
|
|
|
Roulette = "roulette",
|
|
|
|
Blackjack = "blackjack",
|
2021-04-29 02:07:26 +02:00
|
|
|
}
|
2021-04-10 00:12:31 +02:00
|
|
|
|
|
|
|
type IProps = {
|
2021-09-05 01:09:30 +02:00
|
|
|
p: IPlayer;
|
|
|
|
};
|
2021-04-10 00:12:31 +02:00
|
|
|
|
2021-10-01 07:00:50 +02:00
|
|
|
export function CasinoLocation(props: IProps): React.ReactElement {
|
|
|
|
const [game, setGame] = useState(GameType.None);
|
2021-04-10 00:12:31 +02:00
|
|
|
|
2021-10-01 07:00:50 +02:00
|
|
|
function updateGame(game: GameType): void {
|
|
|
|
setGame(game);
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2021-04-10 00:12:31 +02:00
|
|
|
|
2021-10-01 07:00:50 +02:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{game === GameType.None && (
|
2022-01-15 06:12:16 +01:00
|
|
|
<Box sx={{ display: 'grid', width: 'fit-content' }}>
|
2021-10-01 07:00:50 +02:00
|
|
|
<Button onClick={() => updateGame(GameType.Coin)}>Play coin flip</Button>
|
|
|
|
<Button onClick={() => updateGame(GameType.Slots)}>Play slots</Button>
|
|
|
|
<Button onClick={() => updateGame(GameType.Roulette)}>Play roulette</Button>
|
|
|
|
<Button onClick={() => updateGame(GameType.Blackjack)}>Play blackjack</Button>
|
2022-01-15 06:12:16 +01:00
|
|
|
</Box>
|
2021-10-01 07:00:50 +02:00
|
|
|
)}
|
|
|
|
{game !== GameType.None && (
|
|
|
|
<>
|
|
|
|
<Button onClick={() => updateGame(GameType.None)}>Stop playing</Button>
|
|
|
|
{game === GameType.Coin && <CoinFlip p={props.p} />}
|
|
|
|
{game === GameType.Slots && <SlotMachine p={props.p} />}
|
|
|
|
{game === GameType.Roulette && <Roulette p={props.p} />}
|
|
|
|
{game === GameType.Blackjack && <Blackjack p={props.p} />}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|