Fix initial pieces to use shared queue in startGame
All players now receive the same first two pieces from the shared piece queue, with sequence index starting at 2. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+12
-8
@@ -492,12 +492,6 @@ function startGame() {
|
||||
// Initialize shared piece queue
|
||||
lobby.pieceQueue = createPieceQueue(14); // 98 pieces (~14 bags)
|
||||
|
||||
// Initialize sequence index for each player
|
||||
lobby.playerSequenceIndex.clear();
|
||||
for (const player of lobby.players.values()) {
|
||||
lobby.playerSequenceIndex.set(player.id, 0);
|
||||
}
|
||||
|
||||
for (const player of lobby.players.values()) {
|
||||
player.board = createEmptyBoard();
|
||||
player.score = 0;
|
||||
@@ -507,8 +501,18 @@ function startGame() {
|
||||
player.dropInterval = 1000;
|
||||
player.holdPiece = null;
|
||||
player.canHold = true;
|
||||
player.currentPiece = getRandomPiece();
|
||||
player.nextPiece = getRandomPiece();
|
||||
lobby.playerSequenceIndex.set(player.id, 0);
|
||||
}
|
||||
|
||||
// Assign first two pieces from queue to all players
|
||||
const firstPieceType = lobby.pieceQueue[0];
|
||||
const secondPieceType = lobby.pieceQueue[1];
|
||||
|
||||
for (const player of lobby.players.values()) {
|
||||
player.currentPiece = getPieceFromType(firstPieceType);
|
||||
player.nextPiece = getPieceFromType(secondPieceType);
|
||||
// Advance all players to index 2 since we've used first two pieces
|
||||
lobby.playerSequenceIndex.set(player.id, 2);
|
||||
}
|
||||
|
||||
lobby.gameInterval = setInterval(() => gameTick(), 50);
|
||||
|
||||
Reference in New Issue
Block a user