diff --git a/src/samples/tic-tac-toe.ts b/src/samples/tic-tac-toe.ts index 442e129..5e7b9fc 100644 --- a/src/samples/tic-tac-toe.ts +++ b/src/samples/tic-tac-toe.ts @@ -125,8 +125,8 @@ export function createTurnRule() { const playCmd = received as Command; if (playCmd.name !== 'play') continue; - const row = playCmd.params[1] as number; - const col = playCmd.params[2] as number; + const row = Number(playCmd.params[1]); + const col = Number(playCmd.params[2]); if (isNaN(row) || isNaN(col) || row < 0 || row > 2 || col < 0 || col > 2) continue; if (isCellOccupied(this, row, col)) continue; diff --git a/tests/samples/tic-tac-toe.test.ts b/tests/samples/tic-tac-toe.test.ts index c80a099..ba0df13 100644 --- a/tests/samples/tic-tac-toe.test.ts +++ b/tests/samples/tic-tac-toe.test.ts @@ -95,17 +95,17 @@ describe('Tic-Tac-Toe', () => { startTicTacToe(game); // Fill board with no winner (cat's game) - // X: (0,0), (0,2), (1,1), (2,0) - // O: (0,1), (1,0), (1,2), (2,1), (2,2) - game.dispatchCommand('play X 0 0'); // X - game.dispatchCommand('play O 0 1'); // O + // X: (1,1), (0,2), (2,2), (1,0), (2,1) + // O: (0,0), (2,0), (0,1), (1,2) + game.dispatchCommand('play X 1 1'); // X + game.dispatchCommand('play O 0 0'); // O game.dispatchCommand('play X 0 2'); // X - game.dispatchCommand('play O 1 0'); // O - game.dispatchCommand('play X 1 1'); // X (center) + game.dispatchCommand('play O 2 0'); // O + game.dispatchCommand('play X 2 2'); // X + game.dispatchCommand('play O 0 1'); // O + game.dispatchCommand('play X 1 0'); // X game.dispatchCommand('play O 1 2'); // O - game.dispatchCommand('play X 2 0'); // X - game.dispatchCommand('play O 2 1'); // O - game.dispatchCommand('play X 2 2'); // X (last move, draw) + game.dispatchCommand('play X 2 1'); // X (last move, draw) const state = getBoardState(game); expect(state.winner).toBe('draw');