Fix: Add piece placement tracking to update session stats correctly

This commit is contained in:
cmclark00 2025-03-31 20:30:06 -04:00
parent 6958a864c1
commit 5cf8aec02a
2 changed files with 7 additions and 0 deletions

View file

@ -267,6 +267,9 @@ class MainActivity : AppCompatActivity(),
gameBoard.onPieceMove = {
binding.holdPieceView.invalidate()
}
gameBoard.onPiecePlaced = {
piecesPlaced++
}
// Set up music toggle
binding.musicToggle.setOnClickListener {

View file

@ -60,6 +60,7 @@ class GameBoard(
var onPieceLock: (() -> Unit)? = null
var onNextPieceChanged: (() -> Unit)? = null
var onLineClear: ((Int, List<Int>) -> Unit)? = null
var onPiecePlaced: (() -> Unit)? = null // New callback for when a piece is placed
// Store the last cleared lines
private val lastClearedLines = mutableListOf<Int>()
@ -414,6 +415,9 @@ class GameBoard(
// Trigger the piece lock vibration
onPieceLock?.invoke()
// Notify that a piece was placed
onPiecePlaced?.invoke()
// Find and clear lines immediately
findAndClearLines()