diff --git a/packages/wonders-client/src/components/Game/Game.tsx b/packages/wonders-client/src/components/Game/Game.tsx index 7e7185a..247efdc 100644 --- a/packages/wonders-client/src/components/Game/Game.tsx +++ b/packages/wonders-client/src/components/Game/Game.tsx @@ -1,9 +1,9 @@ import { Dispatch } from 'ketchup-react' -import { Action, chooseWonderAction, maxPlayers, minPlayers, Player, startGameAction, State, structures, wonders } from 'wonders-common' +import { Action, maxPlayers, minPlayers, Player, startGameAction, State, structures } from 'wonders-common' import Civ from '../Civ/Civ' import Card from '../Card/Card' -import { ErrorMessage, Field, Form, Formik } from 'formik' import './Game.css' +import WonderSelector from '../WonderSelector/WonderSelector' function getDistant(arr: T[], idx: number) { switch (idx) { @@ -22,10 +22,6 @@ export default function Game({ state, playerName, dispatch }: { state: State, pl distant: getDistant(state.players, playerIdx), } - function isWonderInUse(wonder: string) { - return state.players.filter(p => p.name !== playerName).map(p => p.wonder).includes(wonder) - } - let gameElem: JSX.Element if (!player || !started) { gameElem =
@@ -33,35 +29,11 @@ export default function Game({ state, playerName, dispatch }: { state: State, pl )}
- if (!started) { + if (player) { gameElem = <> {gameElem} - { - const errors: Partial = {} - if (values.wonder.length === 0) { - errors.wonder = 'Wonder not selected.' - } - if (isWonderInUse(values.wonder)) { - errors.wonder = 'Wonder already in use.' - } - return errors - }} - onSubmit={({ wonder }) => dispatch(chooseWonderAction(player.name, wonder))}> -
- - {' '} - - {[...wonders.keys()].map(w => - - )} - - {' '} - - -
+ + {' '} + + {[...wonders.keys()].map(w => + + )} + + {' '} + + + +}