Fix: Add missing socket listeners and fix database calls for surrender/rematch

- server.js: Added missing listeners for surrender, send_rematch, accept_rematch, decline_rematch events (previously missing, causing features to simple do nothing)
- gameManager.js: Removed invalid calls to non-existent incrementWins/incrementLosses methods (abandonGame already handles this internally)
This commit is contained in:
2025-12-22 19:19:30 +11:00
parent 04860c3e39
commit f879050b0c
2 changed files with 18 additions and 4 deletions

View File

@@ -472,10 +472,6 @@ class GameManager {
try {
await this.db.abandonGame(data.gameId, winnerId);
// Update player stats
await this.db.incrementLosses(player.id);
await this.db.incrementWins(winnerId);
// Get updated stats
const loserStats = await this.db.getPlayerById(player.id);
const winnerStats = await this.db.getPlayerById(winnerId);

View File

@@ -154,6 +154,24 @@ io.on('connection', (socket) => {
await gameManager.heartbeat(socket);
});
// Surrender
socket.on('surrender', async (data) => {
await gameManager.handleSurrender(socket, data);
});
// Rematch
socket.on('send_rematch', (data) => {
gameManager.sendRematch(socket, data);
});
socket.on('accept_rematch', async (data) => {
await gameManager.acceptRematch(socket, data);
});
socket.on('decline_rematch', (data) => {
gameManager.declineRematch(socket, data);
});
// Request active players
socket.on('request_active_players', async () => {
const activePlayers = await db.getActivePlayers();