retrowars/retrowars

Tetris: Can drop a block into another block or crash the app

pssandhu opened this issue · 2 comments

Describe the bug
If the drop button is pressed at the correct moment a block can be placed one row inside the blocks beneath it. The app crashes if there is no block underneath.

To Reproduce

  1. Wait until a block naturally falls into its final place
  2. Press the drop button before the next block spawns
  3. If there is already a block underneath, it placed one row deeper than should be possible
  4. If on the bottom row, the app crashes

Expected behavior
Nothing/skip to next block spawning

Smartphone:

  • Android Version: 8.0.0
  • Version: 0.6.1

Additional context
Only tested on singleplayer.
From a quick look at the code the problem might the +1 in the loop condition. Might also need to check for a legal move before storeTetronimoInGrid:

var newY = state.currentY + 1
while (isLegalMove(state.currentPiece, state.currentX, newY + 1)) {
newY ++
}
storeTetronimoInGrid(state.currentPiece, state.currentX, newY)

Can also teleport through blocks if the newY + 1 position is valid and continue dropping.

Can I just say, this is an exceptionally well written bug report, thanks so much for the detail. Very easy to see where the issue is now.

Would you like to have a crack at fixing it? If not I can address it in the coming days.

That's good to hear! I don't have much experience with android development or submitting pull requests but I'll give it a go.