From f9cafe630c39d158a1b3ab888bd4db90d9ffa3ee Mon Sep 17 00:00:00 2001 From: Josue Zamudio Date: Fri, 20 Mar 2026 07:53:08 -0700 Subject: [PATCH] Fix game over condition and garbage row placement - Remove premature elimination in addGarbageToPlayer (top rows check) - Remove redundant y < 0 elimination check in lockPiece - Players are only eliminated when spawnPiece fails (board full) - Garbage rows now added to bottom of board, pushing blocks up --- server/index.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/server/index.js b/server/index.js index cc172b7..cb04953 100644 --- a/server/index.js +++ b/server/index.js @@ -250,8 +250,6 @@ function lockPiece(player) { } } - if (player.currentPiece.y <= 0) player.eliminated = true; - const rowsCleared = clearRows(player); if (!spawnPiece(player)) player.eliminated = true; @@ -293,19 +291,12 @@ function sendGarbage(sender, rowsCleared) { } function addGarbageToPlayer(player) { - player.board.pop(); + // Remove top row and add garbage to bottom + player.board.shift(); const garbageRow = Array(BOARD_WIDTH).fill(GARBAGE_COLOR); garbageRow[Math.floor(Math.random() * BOARD_WIDTH)] = 0; - player.board.unshift(garbageRow); - - for (let row = 0; row < 2; row++) { - for (let col = 0; col < BOARD_WIDTH; col++) { - if (player.board[row][col] !== 0) { - player.eliminated = true; - return; - } - } - } + player.board.push(garbageRow); + // Elimination is handled by spawnPiece when a new piece can't fit } function startGame() {