diff --git a/app/[gameID]/page.tsx b/app/[gameID]/page.tsx index 38a3dec..eb9afbe 100644 --- a/app/[gameID]/page.tsx +++ b/app/[gameID]/page.tsx @@ -6,13 +6,13 @@ import { socket } from "@/socket"; import Card from '@/components/Card'; -import type { GameCard, GameUpdate, ClientUpdate } from '@/types'; +import type { GameUpdate, ClientUpdate, StandardGameCard, TarokkaGameCard } from '@/types'; export default function GamePage() { const { gameID: gameIDParam } = useParams(); const [gameID, setGameID] = useState(''); - const [cards, setCards] = useState([]); + const [cards, setCards] = useState([]); useEffect(() => { if (gameIDParam) { @@ -51,15 +51,15 @@ export default function GamePage() { }; return cards.length ? ( -
+

Game ID: {gameID}

-
+
{Array.from({ length: 9 }).map((_, i) => { const cardIndex = [1, 3, 4, 5, 7].indexOf(i); return ( -
+
{cardIndex !== -1 && flipCard(cardIndex)} />}
) diff --git a/components/Card.tsx b/components/Card.tsx index 84f0887..12547ce 100644 --- a/components/Card.tsx +++ b/components/Card.tsx @@ -10,10 +10,11 @@ type CardProps = { export default function Card({ card: { aria, url }, flipAction }: CardProps) { return (
{aria} diff --git a/lib/GameStore.ts b/lib/GameStore.ts index efeaff8..91b1413 100644 --- a/lib/GameStore.ts +++ b/lib/GameStore.ts @@ -1,6 +1,6 @@ import Deck from './TarokkaDeck' -import { GameState, GameUpdate } from '../types' +import { GameState, GameUpdate, TarokkaGameCard } from '../types' const deck = new Deck(); @@ -66,7 +66,7 @@ export default class GameStore { gameUpdate(game: GameState): GameUpdate { const { id, cards } = game; - return { id, cards: cards.map(card => card.flipped ? card : deck.getBack()) }; + return { id, cards: (cards as TarokkaGameCard[]).map((card: TarokkaGameCard) => card.flipped ? card : { ...deck.getBack(), flipped: false }) }; } deleteGame(gameID: string): void {