Fixed winx and win0 in tictactoe

This commit is contained in:
NigeParis 2026-01-04 13:25:38 +01:00 committed by Maix0
parent d293185a28
commit 6f89e4a3e1
2 changed files with 14 additions and 1 deletions

View file

@ -74,7 +74,17 @@ async function handleTTT(): Promise<RouteHandlerReturn> {
}
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<RouteHandlerReturn> {
cells?.forEach(function(c, idx) {
c.addEventListener("click", () => {
if (socket) {
socket.emit("gameMove", { index: idx });
}
});
});
},

View file

@ -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 {