Fix garbage row visibility by pushing current piece up

When garbage rows are added to a player's board, the current falling
piece was not being adjusted, causing it to appear stuck while the
board shifted. This fix increments the piece's Y position when garbage
is received and eliminates the player if the piece is pushed above
the visible board.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-20 21:35:51 +00:00
parent 6f24cfad30
commit 27b0adcc90
+9 -1
View File
@@ -395,7 +395,15 @@ function addGarbageToPlayer(player) {
const garbageRow = Array(BOARD_WIDTH).fill(GARBAGE_COLOR);
garbageRow[Math.floor(Math.random() * BOARD_WIDTH)] = 0;
player.board.push(garbageRow);
// Elimination is handled by spawnPiece when a new piece can't fit
// Push current piece up by 1 row if it exists
if (player.currentPiece) {
player.currentPiece.y++;
// Eliminate if the piece is pushed above the board
if (!isValidPosition(player.currentPiece, player.currentPiece.x, player.currentPiece.y, player.board)) {
player.eliminated = true;
}
}
}
function getGhostY(piece, board) {