diff --git a/frontend/src/pages/ttt/ttt.ts b/frontend/src/pages/ttt/ttt.ts index 4e068e2..9863b1e 100644 --- a/frontend/src/pages/ttt/ttt.ts +++ b/frontend/src/pages/ttt/ttt.ts @@ -74,7 +74,17 @@ async function handleTTT(): Promise { } if (type === 'win') { - const youWin = (curGame?.playerX === user.id); + let youWin: boolean; + switch(player) { + case 'X': + youWin = (curGame?.playerX === user.id); + break ; + case 'O': + youWin = (curGame?.playerO === user.id); + break; + default: + return; + } if (youWin) showSuccess('You won the game !'); else @@ -118,7 +128,9 @@ async function handleTTT(): Promise { cells?.forEach(function(c, idx) { c.addEventListener("click", () => { + if (socket) { socket.emit("gameMove", { index: idx }); + } }); }); }, diff --git a/src/tic-tac-toe/src/state.ts b/src/tic-tac-toe/src/state.ts index 24b0d2e..0b5877d 100644 --- a/src/tic-tac-toe/src/state.ts +++ b/src/tic-tac-toe/src/state.ts @@ -95,6 +95,7 @@ export class StateI { socket.on('debugInfo', () => this.debugSocket(socket)); socket.on('gameMove', (e) => this.gameMove(socket, e)); + if (socket) {console.log('Socket:', socket.id);}; } private updateClient(socket: SSocket): void {