|
@@ -1,73 +0,0 @@
|
|
|
-import React from "react";
|
|
|
-import styled from "styled-components";
|
|
|
-import {
|
|
|
- PRE_GAME,
|
|
|
- PRE_ROUND,
|
|
|
- IN_ROUND,
|
|
|
- POST_ROUND,
|
|
|
- POST_GAME,
|
|
|
- ERROR,
|
|
|
-} from "../domain/GameState";
|
|
|
-import HomePage from "./screens/HomePage";
|
|
|
-import Lobby from "./screens/Lobby";
|
|
|
-import GamePanel from "./screens/GamePanel";
|
|
|
-import RoundSummary from "./screens/RoundSummary";
|
|
|
-import PlayerScores from "./screens/PlayerScores";
|
|
|
-import { useGameState, dispatch } from "../domain/gameStore";
|
|
|
-import useDirectGameLinks from "../hooks/useDirectGameLinks";
|
|
|
-import ApiInfo from "./util/ApiInfo";
|
|
|
-
|
|
|
-const componentMap = {
|
|
|
- [PRE_GAME]: HomePage,
|
|
|
- [PRE_ROUND]: Lobby,
|
|
|
- [IN_ROUND]: GamePanel,
|
|
|
- [POST_ROUND]: RoundSummary,
|
|
|
- [POST_GAME]: PlayerScores,
|
|
|
- [ERROR]: () => <p>Application encountered unrecoverable error, please refresh the page.</p>,
|
|
|
-}
|
|
|
-
|
|
|
-const needsHeaderFooter = {
|
|
|
- [PRE_GAME]: true,
|
|
|
- [PRE_ROUND]: true,
|
|
|
- [IN_ROUND]: false,
|
|
|
- [POST_ROUND]: false,
|
|
|
- [POST_GAME]: true,
|
|
|
- [ERROR]: true,
|
|
|
-}
|
|
|
-
|
|
|
-const paramRouter = {
|
|
|
- join: dispatch.goToLobby,
|
|
|
- summary: dispatch.goToSummary,
|
|
|
-}
|
|
|
-
|
|
|
-const Container = styled.div`
|
|
|
- display: block;
|
|
|
- text-align: center;
|
|
|
-`
|
|
|
-
|
|
|
-const Header = () => (
|
|
|
- <Container>
|
|
|
- <p>TerrAssumptions!</p>
|
|
|
- <hr/>
|
|
|
- </Container>
|
|
|
-)
|
|
|
-
|
|
|
-const Footer = () => (
|
|
|
- <Container>
|
|
|
- <hr/>
|
|
|
- <ApiInfo/>
|
|
|
- </Container>
|
|
|
-)
|
|
|
-
|
|
|
-const Game = () => {
|
|
|
- const gameState = useGameState();
|
|
|
-
|
|
|
- useDirectGameLinks(paramRouter);
|
|
|
-
|
|
|
- const Screen = componentMap[gameState];
|
|
|
- return needsHeaderFooter[gameState]
|
|
|
- ? <><Header/><Screen/><Footer/></>
|
|
|
- : <Screen/>;
|
|
|
-}
|
|
|
-
|
|
|
-export default Game;
|