diff --git a/src/samples/tic-tac-toe.ts b/src/samples/tic-tac-toe.ts index 72e91b2..ffa94d6 100644 --- a/src/samples/tic-tac-toe.ts +++ b/src/samples/tic-tac-toe.ts @@ -77,7 +77,7 @@ export async function start(game: TicTacToeGame) { const turnNumber = game.value.turn + 1; const turnOutput = await turn(game, currentPlayer, turnNumber); - game.produce((state) => { + await game.produceAsync((state) => { state.winner = turnOutput.winner; if (!state.winner) { state.currentPlayer = state.currentPlayer === "X" ? "O" : "X"; @@ -111,7 +111,7 @@ async function turn( game.value.currentPlayer, ); - placePiece(game, row, col, turnPlayer); + await placePiece(game, row, col, turnPlayer); const winner = checkWinner(game); if (winner) return { winner }; @@ -163,7 +163,7 @@ export function checkWinner(host: TicTacToeGame): WinnerType { return null; } -export function placePiece( +export async function placePiece( host: TicTacToeGame, row: number, col: number, @@ -177,7 +177,7 @@ export function placePiece( player, id: `piece-${player}-${moveNumber}`, }; - host.produce((state) => { + await host.produceAsync((state) => { state.parts[piece.id] = piece; board.childIds.push(piece.id); board.partMap[`${row},${col}`] = piece.id;