|
@@ -1,6 +1,21 @@
|
|
import React from 'react';
|
|
import React from 'react';
|
|
import styled from 'styled-components';
|
|
import styled from 'styled-components';
|
|
-import Game from "./components/Game";
|
|
|
|
|
|
+import {
|
|
|
|
+ PRE_GAME,
|
|
|
|
+ PRE_ROUND,
|
|
|
|
+ IN_ROUND,
|
|
|
|
+ POST_ROUND,
|
|
|
|
+ POST_GAME,
|
|
|
|
+ ERROR,
|
|
|
|
+} from "./domain/GameState";
|
|
|
|
+import { useGameState } from './domain/gameStore';
|
|
|
|
+import useDirectGameLinks from './hooks/useDirectGameLinks';
|
|
|
|
+import ApiInfo from './components/util/ApiInfo';
|
|
|
|
+import HomePage from "./components/screens/HomePage";
|
|
|
|
+import Lobby from "./components/screens/Lobby";
|
|
|
|
+import GamePanel from "./components/screens/GamePanel";
|
|
|
|
+import RoundSummary from "./components/screens/RoundSummary";
|
|
|
|
+import PlayerScores from "./components/screens/PlayerScores";
|
|
|
|
|
|
const Wrapper = styled.div`
|
|
const Wrapper = styled.div`
|
|
height: 100%;
|
|
height: 100%;
|
|
@@ -10,10 +25,52 @@ const Wrapper = styled.div`
|
|
justify-content: space-between;
|
|
justify-content: space-between;
|
|
`
|
|
`
|
|
|
|
|
|
-export default () => (
|
|
|
|
- <React.StrictMode>
|
|
|
|
- <Wrapper>
|
|
|
|
- <Game/>
|
|
|
|
- </Wrapper>
|
|
|
|
- </React.StrictMode>
|
|
|
|
-);
|
|
|
|
|
|
+const BlockContainer = styled.div`
|
|
|
|
+ display: block;
|
|
|
|
+ text-align: center;
|
|
|
|
+`
|
|
|
|
+
|
|
|
|
+const screenMap = {
|
|
|
|
+ [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,
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export default () => {
|
|
|
|
+ const gameState = useGameState();
|
|
|
|
+ useDirectGameLinks();
|
|
|
|
+ const Screen = screenMap[gameState];
|
|
|
|
+ const needsHF = needsHeaderFooter[gameState];
|
|
|
|
+
|
|
|
|
+ return (
|
|
|
|
+ <React.StrictMode>
|
|
|
|
+ <Wrapper>
|
|
|
|
+ { needsHF && (
|
|
|
|
+ <BlockContainer>
|
|
|
|
+ <p>TerrAssumptions!</p>
|
|
|
|
+ <hr/>
|
|
|
|
+ </BlockContainer>
|
|
|
|
+ ) }
|
|
|
|
+ <Screen />
|
|
|
|
+ { needsHF && (
|
|
|
|
+ <BlockContainer>
|
|
|
|
+ <hr/>
|
|
|
|
+ <ApiInfo/>
|
|
|
|
+ </BlockContainer>
|
|
|
|
+ ) }
|
|
|
|
+ </Wrapper>
|
|
|
|
+ </React.StrictMode>
|
|
|
|
+ )
|
|
|
|
+};
|