Fix garbage elimination bug and align board with header

- Change y-- instead of y++ when pushing piece up on garbage
- Add y < 0 check to properly detect piece pushed off top
- Remove margin-top from battle grid to align with header

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 01:07:21 +00:00
parent 27b0adcc90
commit bdeb6c8849
2 changed files with 4 additions and 5 deletions
-1
View File
@@ -197,7 +197,6 @@ button:active {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
margin-top: 20px;
} }
/* Main player board - centered and large */ /* Main player board - centered and large */
+4 -4
View File
@@ -396,11 +396,11 @@ function addGarbageToPlayer(player) {
garbageRow[Math.floor(Math.random() * BOARD_WIDTH)] = 0; garbageRow[Math.floor(Math.random() * BOARD_WIDTH)] = 0;
player.board.push(garbageRow); player.board.push(garbageRow);
// Push current piece up by 1 row if it exists // Push current piece up by 1 row if it exists (y decreases when moving up)
if (player.currentPiece) { if (player.currentPiece) {
player.currentPiece.y++; player.currentPiece.y--;
// Eliminate if the piece is pushed above the board // Eliminate if the piece is pushed above the board or collides
if (!isValidPosition(player.currentPiece, player.currentPiece.x, player.currentPiece.y, player.board)) { if (player.currentPiece.y < 0 || !isValidPosition(player.currentPiece, player.currentPiece.x, player.currentPiece.y, player.board)) {
player.eliminated = true; player.eliminated = true;
} }
} }