import { PlayerId } from "dusk-games-sdk/multiplayer" import { useEffect, useState } from "react" import selectSoundAudio from "./assets/select.wav" import { GameState } from "./logic.ts" const selectSound = new Audio(selectSoundAudio) function App() { const [game, setGame] = useState() const [yourPlayerId, setYourPlayerId] = useState() useEffect(() => { Dusk.initClient({ onChange: ({ game, action, yourPlayerId }) => { setGame(game) setYourPlayerId(yourPlayerId) if (action && action.name === "claimCell") selectSound.play() }, }) }, []) if (!game) { // Dusk only shows your game after an onChange() so no need for loading screen return } const { winCombo, cells, lastMovePlayerId, playerIds, freeCells } = game return ( <>
{cells.map((cell, cellIndex) => { const cellValue = cells[cellIndex] return (
) } export default App