Fix: Add opponentId to game_started events for surrender/rematch functionality

- Added opponentId field to both game_started socket emissions in acceptChallenge
- This allows client to properly track opponent for rematch requests
- Fixes surrender button not showing issue (client needs opponentId to enable features)
This commit is contained in:
2025-12-22 18:09:55 +11:00
parent 0933644710
commit 62b28beed3

View File

@@ -236,6 +236,7 @@ class GameManager {
this.io.to(challengerSocket).emit('game_started', { this.io.to(challengerSocket).emit('game_started', {
gameId: gameId, gameId: gameId,
opponent: challenge.targetUsername, opponent: challenge.targetUsername,
opponentId: challenge.targetId,
yourSymbol: gameData.player1Symbol, yourSymbol: gameData.player1Symbol,
boardSize: challenge.boardSize, boardSize: challenge.boardSize,
yourTurn: true yourTurn: true
@@ -245,6 +246,7 @@ class GameManager {
this.io.to(socket.id).emit('game_started', { this.io.to(socket.id).emit('game_started', {
gameId: gameId, gameId: gameId,
opponent: challenge.challengerUsername, opponent: challenge.challengerUsername,
opponentId: challenge.challengerId,
yourSymbol: gameData.player2Symbol, yourSymbol: gameData.player2Symbol,
boardSize: challenge.boardSize, boardSize: challenge.boardSize,
yourTurn: false yourTurn: false