bitburner-src/src/Arcade/ui/ArcadeRoot.tsx
Olivier Gagnon 30776e5aca added arcade
2022-03-11 15:19:10 -05:00

44 lines
973 B
TypeScript

import React, { useState } from "react";
import { BBCabinetRoot } from "./BBCabinet";
import Button from "@mui/material/Button";
import { use } from "../../ui/Context";
import { AlertEvents } from "../../ui/React/AlertManager";
enum Page {
None,
Megabyteburner2000,
}
export function ArcadeRoot(): React.ReactElement {
const player = use.Player();
const [page, setPage] = useState(Page.None);
function mbBurner2000(): void {
if (player.sourceFileLvl(1) === 0) {
AlertEvents.emit("This machine is broken.");
} else {
setPage(Page.Megabyteburner2000);
}
}
if (page === Page.None) {
return (
<>
<Button onClick={mbBurner2000}>Megabyte burner 2000</Button>
</>
);
}
let currentGame = <></>;
switch (page) {
case Page.Megabyteburner2000:
currentGame = <BBCabinetRoot />;
}
return (
<>
<Button onClick={() => setPage(Page.None)}>Back</Button>
{currentGame}
</>
);
}