mirror of
https://github.com/DeNNiiInc/Connect-5.git
synced 2026-04-17 20:36:00 +00:00
Fix: Enable session score tracking in multiplayer mode
This commit is contained in:
@@ -402,6 +402,14 @@ class MultiplayerClient {
|
|||||||
this.game.boardSize = data.boardSize;
|
this.game.boardSize = data.boardSize;
|
||||||
this.game.currentPlayer = this.mySymbol; // Set to our symbol
|
this.game.currentPlayer = this.mySymbol; // Set to our symbol
|
||||||
this.game.gameActive = true;
|
this.game.gameActive = true;
|
||||||
|
|
||||||
|
// Reset scores if this is a new opponent, otherwise keep them for rematch
|
||||||
|
if (this.currentOpponentId !== data.opponentId) {
|
||||||
|
this.game.scores = { X: 0, O: 0 };
|
||||||
|
this.game.updateScores();
|
||||||
|
this.currentOpponentId = data.opponentId;
|
||||||
|
}
|
||||||
|
|
||||||
this.game.initializeBoard();
|
this.game.initializeBoard();
|
||||||
|
|
||||||
// Update player identity display (Right Side)
|
// Update player identity display (Right Side)
|
||||||
@@ -555,6 +563,21 @@ class MultiplayerClient {
|
|||||||
message = '🏆 You won! Opponent disconnected';
|
message = '🏆 You won! Opponent disconnected';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update session scores
|
||||||
|
if (this.game) {
|
||||||
|
let winner = null;
|
||||||
|
if (data.reason === 'win' || data.reason === 'opponent_abandoned') {
|
||||||
|
winner = this.mySymbol;
|
||||||
|
} else if (data.reason === 'loss') {
|
||||||
|
winner = this.mySymbol === 'X' ? 'O' : 'X';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (winner) {
|
||||||
|
this.game.scores[winner]++;
|
||||||
|
this.game.updateScores();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update stats
|
// Update stats
|
||||||
if (data.stats) {
|
if (data.stats) {
|
||||||
document.getElementById('playerWins').textContent = data.stats.wins;
|
document.getElementById('playerWins').textContent = data.stats.wins;
|
||||||
|
|||||||
Reference in New Issue
Block a user