mirror of
https://github.com/cmclark00/mintris.git
synced 2025-05-18 10:35:21 +01:00
Fix: Add piece placement tracking to update session stats correctly
This commit is contained in:
parent
6958a864c1
commit
5cf8aec02a
2 changed files with 7 additions and 0 deletions
|
@ -267,6 +267,9 @@ class MainActivity : AppCompatActivity(),
|
||||||
gameBoard.onPieceMove = {
|
gameBoard.onPieceMove = {
|
||||||
binding.holdPieceView.invalidate()
|
binding.holdPieceView.invalidate()
|
||||||
}
|
}
|
||||||
|
gameBoard.onPiecePlaced = {
|
||||||
|
piecesPlaced++
|
||||||
|
}
|
||||||
|
|
||||||
// Set up music toggle
|
// Set up music toggle
|
||||||
binding.musicToggle.setOnClickListener {
|
binding.musicToggle.setOnClickListener {
|
||||||
|
|
|
@ -60,6 +60,7 @@ class GameBoard(
|
||||||
var onPieceLock: (() -> Unit)? = null
|
var onPieceLock: (() -> Unit)? = null
|
||||||
var onNextPieceChanged: (() -> Unit)? = null
|
var onNextPieceChanged: (() -> Unit)? = null
|
||||||
var onLineClear: ((Int, List<Int>) -> 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
|
// Store the last cleared lines
|
||||||
private val lastClearedLines = mutableListOf<Int>()
|
private val lastClearedLines = mutableListOf<Int>()
|
||||||
|
@ -414,6 +415,9 @@ class GameBoard(
|
||||||
// Trigger the piece lock vibration
|
// Trigger the piece lock vibration
|
||||||
onPieceLock?.invoke()
|
onPieceLock?.invoke()
|
||||||
|
|
||||||
|
// Notify that a piece was placed
|
||||||
|
onPiecePlaced?.invoke()
|
||||||
|
|
||||||
// Find and clear lines immediately
|
// Find and clear lines immediately
|
||||||
findAndClearLines()
|
findAndClearLines()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue