mirror of
https://github.com/cmclark00/mintris.git
synced 2025-05-18 10:25:19 +01:00
refactor: Rename Tetris to Quad and fix related compilation errors
This commit is contained in:
parent
ce85debfe5
commit
eb962268ca
14 changed files with 139 additions and 57 deletions
16
README.md
16
README.md
|
@ -26,10 +26,10 @@ A modern Tetris implementation for Android, featuring smooth animations, respons
|
||||||
The game features a comprehensive scoring system:
|
The game features a comprehensive scoring system:
|
||||||
|
|
||||||
#### Base Scores
|
#### Base Scores
|
||||||
- Single line: 40 points
|
- Single line: 100 points
|
||||||
- Double: 100 points
|
- Double: 300 points
|
||||||
- Triple: 300 points
|
- Triple: 500 points
|
||||||
- Tetris (4 lines): 1200 points
|
- Quad (4 lines): 1200 points
|
||||||
|
|
||||||
#### Multipliers
|
#### Multipliers
|
||||||
|
|
||||||
|
@ -48,15 +48,15 @@ The game features a comprehensive scoring system:
|
||||||
- 4 combos: 2.5x
|
- 4 combos: 2.5x
|
||||||
- 5+ combos: 3.0x
|
- 5+ combos: 3.0x
|
||||||
|
|
||||||
3. **Back-to-Back Tetris**
|
3. **Back-to-Back Quad**
|
||||||
- 50% bonus (1.5x) for consecutive Tetris clears
|
- 50% bonus (1.5x) for consecutive Quad clears
|
||||||
- Resets if a non-Tetris clear is performed
|
- Resets if a non-Quad clear is performed
|
||||||
|
|
||||||
4. **Perfect Clear**
|
4. **Perfect Clear**
|
||||||
- 2x for single line
|
- 2x for single line
|
||||||
- 3x for double
|
- 3x for double
|
||||||
- 4x for triple
|
- 4x for triple
|
||||||
- 5x for Tetris
|
- 5x for Quad
|
||||||
- Awarded when clearing lines without leaving blocks
|
- Awarded when clearing lines without leaving blocks
|
||||||
|
|
||||||
5. **All Clear**
|
5. **All Clear**
|
||||||
|
|
|
@ -214,6 +214,7 @@ class MainActivity : AppCompatActivity(),
|
||||||
// Set up game view
|
// Set up game view
|
||||||
gameView.setGameBoard(gameBoard)
|
gameView.setGameBoard(gameBoard)
|
||||||
gameView.setHaptics(gameHaptics)
|
gameView.setHaptics(gameHaptics)
|
||||||
|
gameBoard.setStatsManager(statsManager)
|
||||||
|
|
||||||
// Set up theme selector
|
// Set up theme selector
|
||||||
themeSelector.onThemeSelected = { themeId: String ->
|
themeSelector.onThemeSelected = { themeId: String ->
|
||||||
|
@ -301,7 +302,16 @@ class MainActivity : AppCompatActivity(),
|
||||||
statsManager.updateSessionStats(finalScore, gameBoard.lines, piecesPlaced, timePlayedMs, currentLevel)
|
statsManager.updateSessionStats(finalScore, gameBoard.lines, piecesPlaced, timePlayedMs, currentLevel)
|
||||||
|
|
||||||
// Handle progression - XP earned, potential level up
|
// Handle progression - XP earned, potential level up
|
||||||
val xpGained = progressionManager.calculateGameXP(finalScore, gameBoard.lines, currentLevel, timePlayedMs, statsManager.getSessionTetrises(), 0)
|
val xpGained = progressionManager.calculateGameXP(
|
||||||
|
score = finalScore,
|
||||||
|
linesCleared = gameBoard.lines,
|
||||||
|
level = currentLevel,
|
||||||
|
gameTime = timePlayedMs,
|
||||||
|
tSpins = statsManager.getSessionTSpins(),
|
||||||
|
combos = statsManager.getSessionMaxCombo(),
|
||||||
|
quadCount = statsManager.getSessionQuads(),
|
||||||
|
perfectClearCount = statsManager.getSessionPerfectClears()
|
||||||
|
)
|
||||||
val newRewards = progressionManager.addXP(xpGained)
|
val newRewards = progressionManager.addXP(xpGained)
|
||||||
|
|
||||||
// Show progression screen if player earned XP
|
// Show progression screen if player earned XP
|
||||||
|
@ -468,12 +478,14 @@ class MainActivity : AppCompatActivity(),
|
||||||
|
|
||||||
// Calculate XP earned
|
// Calculate XP earned
|
||||||
val xpGained = progressionManager.calculateGameXP(
|
val xpGained = progressionManager.calculateGameXP(
|
||||||
score = score,
|
score = statsManager.getSessionScore(),
|
||||||
lines = gameBoard.lines,
|
linesCleared = statsManager.getSessionLines(),
|
||||||
level = currentLevel,
|
level = currentLevel,
|
||||||
gameTime = gameTime,
|
gameTime = gameTime,
|
||||||
tetrisCount = statsManager.getSessionTetrises(),
|
tSpins = statsManager.getSessionTSpins(),
|
||||||
perfectClearCount = 0 // Implement perfect clear tracking if needed
|
combos = statsManager.getSessionMaxCombo(),
|
||||||
|
quadCount = statsManager.getSessionQuads(),
|
||||||
|
perfectClearCount = statsManager.getSessionPerfectClears()
|
||||||
)
|
)
|
||||||
|
|
||||||
// Add XP and check for rewards
|
// Add XP and check for rewards
|
||||||
|
@ -496,7 +508,7 @@ class MainActivity : AppCompatActivity(),
|
||||||
binding.sessionSinglesText.text = getString(R.string.singles, statsManager.getSessionSingles())
|
binding.sessionSinglesText.text = getString(R.string.singles, statsManager.getSessionSingles())
|
||||||
binding.sessionDoublesText.text = getString(R.string.doubles, statsManager.getSessionDoubles())
|
binding.sessionDoublesText.text = getString(R.string.doubles, statsManager.getSessionDoubles())
|
||||||
binding.sessionTriplesText.text = getString(R.string.triples, statsManager.getSessionTriples())
|
binding.sessionTriplesText.text = getString(R.string.triples, statsManager.getSessionTriples())
|
||||||
binding.sessionTetrisesText.text = getString(R.string.tetrises, statsManager.getSessionTetrises())
|
binding.sessionQuadsText.text = getString(R.string.quads, statsManager.getSessionQuads())
|
||||||
|
|
||||||
// Flag to track if high score screen will be shown
|
// Flag to track if high score screen will be shown
|
||||||
var showingHighScore = false
|
var showingHighScore = false
|
||||||
|
@ -911,7 +923,16 @@ class MainActivity : AppCompatActivity(),
|
||||||
statsManager.updateSessionStats(finalScore, gameBoard.lines, piecesPlaced, timePlayedMs, currentLevel)
|
statsManager.updateSessionStats(finalScore, gameBoard.lines, piecesPlaced, timePlayedMs, currentLevel)
|
||||||
|
|
||||||
// Handle progression - XP earned, potential level up
|
// Handle progression - XP earned, potential level up
|
||||||
val xpGained = progressionManager.calculateGameXP(finalScore, gameBoard.lines, currentLevel, timePlayedMs, statsManager.getSessionTetrises(), 0)
|
val xpGained = progressionManager.calculateGameXP(
|
||||||
|
score = finalScore,
|
||||||
|
linesCleared = gameBoard.lines,
|
||||||
|
level = currentLevel,
|
||||||
|
gameTime = timePlayedMs,
|
||||||
|
tSpins = statsManager.getSessionTSpins(),
|
||||||
|
combos = statsManager.getSessionMaxCombo(),
|
||||||
|
quadCount = statsManager.getSessionQuads(),
|
||||||
|
perfectClearCount = statsManager.getSessionPerfectClears()
|
||||||
|
)
|
||||||
val newRewards = progressionManager.addXP(xpGained)
|
val newRewards = progressionManager.addXP(xpGained)
|
||||||
|
|
||||||
// Show progression screen if player earned XP
|
// Show progression screen if player earned XP
|
||||||
|
|
|
@ -78,7 +78,7 @@ class StatsActivity : AppCompatActivity() {
|
||||||
binding.totalSinglesText.setTextColor(textColor)
|
binding.totalSinglesText.setTextColor(textColor)
|
||||||
binding.totalDoublesText.setTextColor(textColor)
|
binding.totalDoublesText.setTextColor(textColor)
|
||||||
binding.totalTriplesText.setTextColor(textColor)
|
binding.totalTriplesText.setTextColor(textColor)
|
||||||
binding.totalTetrisesText.setTextColor(textColor)
|
binding.totalQuadsText.setTextColor(textColor)
|
||||||
binding.maxLevelText.setTextColor(textColor)
|
binding.maxLevelText.setTextColor(textColor)
|
||||||
binding.maxScoreText.setTextColor(textColor)
|
binding.maxScoreText.setTextColor(textColor)
|
||||||
binding.maxLinesText.setTextColor(textColor)
|
binding.maxLinesText.setTextColor(textColor)
|
||||||
|
@ -116,7 +116,7 @@ class StatsActivity : AppCompatActivity() {
|
||||||
binding.totalSinglesText.text = getString(R.string.singles, statsManager.getTotalSingles())
|
binding.totalSinglesText.text = getString(R.string.singles, statsManager.getTotalSingles())
|
||||||
binding.totalDoublesText.text = getString(R.string.doubles, statsManager.getTotalDoubles())
|
binding.totalDoublesText.text = getString(R.string.doubles, statsManager.getTotalDoubles())
|
||||||
binding.totalTriplesText.text = getString(R.string.triples, statsManager.getTotalTriples())
|
binding.totalTriplesText.text = getString(R.string.triples, statsManager.getTotalTriples())
|
||||||
binding.totalTetrisesText.text = getString(R.string.tetrises, statsManager.getTotalTetrises())
|
binding.totalQuadsText.text = getString(R.string.quads, statsManager.getTotalQuads())
|
||||||
|
|
||||||
// Update best performance stats
|
// Update best performance stats
|
||||||
binding.maxLevelText.text = getString(R.string.max_level, statsManager.getMaxLevel())
|
binding.maxLevelText.text = getString(R.string.max_level, statsManager.getMaxLevel())
|
||||||
|
|
|
@ -53,7 +53,7 @@ class GameHaptics(private val context: Context) {
|
||||||
1 -> (50L * multiplier).toLong() // Single line: short vibration
|
1 -> (50L * multiplier).toLong() // Single line: short vibration
|
||||||
2 -> (80L * multiplier).toLong() // Double line: slightly longer
|
2 -> (80L * multiplier).toLong() // Double line: slightly longer
|
||||||
3 -> (120L * multiplier).toLong() // Triple line: even longer
|
3 -> (120L * multiplier).toLong() // Triple line: even longer
|
||||||
4 -> (200L * multiplier).toLong() // Tetris: longest vibration
|
4 -> (200L * multiplier).toLong() // Quad: longest vibration
|
||||||
else -> (50L * multiplier).toLong()
|
else -> (50L * multiplier).toLong()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class GameHaptics(private val context: Context) {
|
||||||
1 -> (80 * multiplier).toInt().coerceAtMost(255) // Single line: mild vibration
|
1 -> (80 * multiplier).toInt().coerceAtMost(255) // Single line: mild vibration
|
||||||
2 -> (120 * multiplier).toInt().coerceAtMost(255) // Double line: medium vibration
|
2 -> (120 * multiplier).toInt().coerceAtMost(255) // Double line: medium vibration
|
||||||
3 -> (180 * multiplier).toInt().coerceAtMost(255) // Triple line: strong vibration
|
3 -> (180 * multiplier).toInt().coerceAtMost(255) // Triple line: strong vibration
|
||||||
4 -> 255 // Tetris: maximum vibration
|
4 -> 255 // Quad: maximum vibration
|
||||||
else -> (80 * multiplier).toInt().coerceAtMost(255)
|
else -> (80 * multiplier).toInt().coerceAtMost(255)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1262,11 +1262,11 @@ class GameView @JvmOverloads constructor(
|
||||||
// Create new animation
|
// Create new animation
|
||||||
pulseAnimator = ValueAnimator.ofFloat(0f, 1f, 0f).apply {
|
pulseAnimator = ValueAnimator.ofFloat(0f, 1f, 0f).apply {
|
||||||
duration = when (lineCount) {
|
duration = when (lineCount) {
|
||||||
4 -> 2000L // Tetris - longer duration
|
1 -> 500L // Single
|
||||||
3 -> 1600L // Triples
|
2 -> 1000L // Double
|
||||||
2 -> 1200L // Doubles
|
3 -> 1500L // Triple
|
||||||
1 -> 1000L // Singles
|
4 -> 2000L // Quad - longer duration
|
||||||
else -> 1000L
|
else -> 500L
|
||||||
}
|
}
|
||||||
interpolator = LinearInterpolator()
|
interpolator = LinearInterpolator()
|
||||||
addUpdateListener { animation ->
|
addUpdateListener { animation ->
|
||||||
|
|
|
@ -256,7 +256,7 @@ class GamepadController(
|
||||||
1 -> 100
|
1 -> 100
|
||||||
2 -> 150
|
2 -> 150
|
||||||
3 -> 200
|
3 -> 200
|
||||||
else -> 255 // For tetris (4 lines)
|
else -> 255 // For quad (4 lines)
|
||||||
}
|
}
|
||||||
vibrateGamepad(RUMBLE_LINE_CLEAR_DURATION_MS, amplitude)
|
vibrateGamepad(RUMBLE_LINE_CLEAR_DURATION_MS, amplitude)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.pixelmintdrop.model
|
package com.pixelmintdrop.model
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the game board (grid) and manages game state
|
* Represents the game board (grid) and manages game state
|
||||||
|
@ -43,7 +44,7 @@ class GameBoard(
|
||||||
|
|
||||||
// Scoring state
|
// Scoring state
|
||||||
private var combo = 0
|
private var combo = 0
|
||||||
private var lastClearWasTetris = false
|
private var lastClearWasQuad = false
|
||||||
private var lastClearWasPerfect = false
|
private var lastClearWasPerfect = false
|
||||||
private var lastClearWasAllClear = false
|
private var lastClearWasAllClear = false
|
||||||
private var lastPieceClearedLines = false // Track if the last piece placed cleared lines
|
private var lastPieceClearedLines = false // Track if the last piece placed cleared lines
|
||||||
|
@ -69,6 +70,15 @@ class GameBoard(
|
||||||
private var pieceSpawnTime = 0L
|
private var pieceSpawnTime = 0L
|
||||||
private val spawnGracePeriod = 250L // Changed from 150ms to 250ms
|
private val spawnGracePeriod = 250L // Changed from 150ms to 250ms
|
||||||
|
|
||||||
|
private var lastClearWasTSpin = false
|
||||||
|
private var lastClearWasMiniTSpin = false
|
||||||
|
private var currentCombo = 0
|
||||||
|
|
||||||
|
private var rng: Random = Random(System.currentTimeMillis())
|
||||||
|
|
||||||
|
// Added for StatsManager
|
||||||
|
private var statsManager: StatsManager? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
spawnNextPiece()
|
spawnNextPiece()
|
||||||
spawnPiece()
|
spawnPiece()
|
||||||
|
@ -541,8 +551,8 @@ class GameBoard(
|
||||||
}
|
}
|
||||||
} else 1.0
|
} else 1.0
|
||||||
|
|
||||||
// Calculate back-to-back Tetris bonus
|
// Calculate back-to-back Quad bonus
|
||||||
val backToBackMultiplier = if (clearedLines == 4 && lastClearWasTetris) 1.5 else 1.0
|
val backToBackMultiplier = if ((clearedLines == 4 && lastClearWasQuad) || (isTSpin() && lastClearWasTSpin)) 1.5 else 1.0
|
||||||
|
|
||||||
// Calculate perfect clear bonus
|
// Calculate perfect clear bonus
|
||||||
val perfectClearMultiplier = if (isPerfectClear) {
|
val perfectClearMultiplier = if (isPerfectClear) {
|
||||||
|
@ -579,7 +589,7 @@ class GameBoard(
|
||||||
}.start()
|
}.start()
|
||||||
|
|
||||||
// Update line clear state
|
// Update line clear state
|
||||||
lastClearWasTetris = clearedLines == 4
|
lastClearWasQuad = clearedLines == 4
|
||||||
lastClearWasPerfect = isPerfectClear
|
lastClearWasPerfect = isPerfectClear
|
||||||
lastClearWasAllClear = isAllClear
|
lastClearWasAllClear = isAllClear
|
||||||
|
|
||||||
|
@ -702,7 +712,7 @@ class GameBoard(
|
||||||
|
|
||||||
// Reset scoring state
|
// Reset scoring state
|
||||||
combo = 0
|
combo = 0
|
||||||
lastClearWasTetris = false
|
lastClearWasQuad = false
|
||||||
lastClearWasPerfect = false
|
lastClearWasPerfect = false
|
||||||
lastClearWasAllClear = false
|
lastClearWasAllClear = false
|
||||||
lastPieceClearedLines = false
|
lastPieceClearedLines = false
|
||||||
|
@ -762,4 +772,11 @@ class GameBoard(
|
||||||
/**
|
/**
|
||||||
* Update the game level
|
* Update the game level
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the StatsManager instance for recording stats
|
||||||
|
*/
|
||||||
|
fun setStatsManager(manager: StatsManager) {
|
||||||
|
statsManager = manager
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -93,24 +93,26 @@ class PlayerProgressionManager(context: Context) {
|
||||||
/**
|
/**
|
||||||
* Calculate XP from a game session based on score, lines, level, etc.
|
* Calculate XP from a game session based on score, lines, level, etc.
|
||||||
*/
|
*/
|
||||||
fun calculateGameXP(score: Int, lines: Int, level: Int, gameTime: Long,
|
fun calculateGameXP(score: Int, linesCleared: Int, level: Int, gameTime: Long,
|
||||||
tetrisCount: Int, perfectClearCount: Int): Long {
|
tSpins: Int, combos: Int, quadCount: Int, perfectClearCount: Int): Long {
|
||||||
// Base XP from score with level multiplier (capped at level 10)
|
// Base XP from score with level multiplier (capped at level 10)
|
||||||
val cappedLevel = min(level, 10)
|
val cappedLevel = min(level, 10)
|
||||||
val scoreXP = (score * (1 + LEVEL_MULTIPLIER * cappedLevel)).toLong()
|
val scoreXP = (score * (1 + LEVEL_MULTIPLIER * cappedLevel)).toLong()
|
||||||
|
|
||||||
// XP from lines cleared (reduced for higher levels)
|
// XP from lines cleared (reduced for higher levels)
|
||||||
val linesXP = lines * XP_PER_LINE * (1 - (level - 1) * 0.05).coerceAtLeast(0.5)
|
val linesXP = linesCleared * XP_PER_LINE * (1 - (level - 1) * 0.05).coerceAtLeast(0.5)
|
||||||
|
|
||||||
// XP from special moves (reduced for higher levels)
|
// XP from special moves (reduced for higher levels)
|
||||||
val tetrisBonus = tetrisCount * TETRIS_XP_BONUS * (1 - (level - 1) * 0.05).coerceAtLeast(0.5)
|
val tSpinXP = tSpins * T_SPIN_XP_BONUS * (1 - (level - 1) * 0.05).coerceAtLeast(0.5)
|
||||||
val perfectClearBonus = perfectClearCount * PERFECT_CLEAR_XP_BONUS * (1 - (level - 1) * 0.05).coerceAtLeast(0.5)
|
val combosXP = combos * COMBO_XP_BONUS
|
||||||
|
val quadBonus = quadCount * QUAD_XP_BONUS * (1 - (level - 1) * 0.05).coerceAtLeast(0.5)
|
||||||
|
val perfectClearBonus = perfectClearCount * PERFECT_CLEAR_XP_BONUS
|
||||||
|
|
||||||
// Time bonus (reduced for longer games)
|
// Time bonus (reduced for longer games)
|
||||||
val timeBonus = (gameTime / 60000) * TIME_XP_PER_MINUTE * (1 - (gameTime / 3600000) * 0.1).coerceAtLeast(0.5)
|
val timeBonus = (gameTime / 60000) * TIME_XP_PER_MINUTE * (1 - (gameTime / 3600000) * 0.1).coerceAtLeast(0.5)
|
||||||
|
|
||||||
// Calculate total XP
|
// Calculate total XP
|
||||||
return (scoreXP + linesXP + tetrisBonus + perfectClearBonus + timeBonus).toLong()
|
return (scoreXP + linesXP + tSpinXP + combosXP + quadBonus + perfectClearBonus + timeBonus).toLong()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -306,8 +308,10 @@ class PlayerProgressionManager(context: Context) {
|
||||||
private const val XP_CURVE_FACTOR = 2.0
|
private const val XP_CURVE_FACTOR = 2.0
|
||||||
private const val LEVEL_MULTIPLIER = 0.03
|
private const val LEVEL_MULTIPLIER = 0.03
|
||||||
private const val XP_PER_LINE = 40L
|
private const val XP_PER_LINE = 40L
|
||||||
private const val TETRIS_XP_BONUS = 150L
|
private const val COMBO_XP_BONUS = 5L
|
||||||
private const val PERFECT_CLEAR_XP_BONUS = 300L
|
private const val PERFECT_CLEAR_XP_BONUS = 200L
|
||||||
|
private const val T_SPIN_XP_BONUS = 80L
|
||||||
|
private const val QUAD_XP_BONUS = 150L
|
||||||
private const val TIME_XP_PER_MINUTE = 20L
|
private const val TIME_XP_PER_MINUTE = 20L
|
||||||
|
|
||||||
// Theme constants
|
// Theme constants
|
||||||
|
|
|
@ -16,11 +16,15 @@ class StatsManager(context: Context) {
|
||||||
private var maxScore: Int = 0
|
private var maxScore: Int = 0
|
||||||
private var maxLines: Int = 0
|
private var maxLines: Int = 0
|
||||||
|
|
||||||
|
// Special move stats (lifetime)
|
||||||
|
private var totalTSpins: Int = 0
|
||||||
|
private var totalPerfectClears: Int = 0
|
||||||
|
|
||||||
// Line clear stats (lifetime)
|
// Line clear stats (lifetime)
|
||||||
private var totalSingles: Int = 0
|
private var totalSingles: Int = 0
|
||||||
private var totalDoubles: Int = 0
|
private var totalDoubles: Int = 0
|
||||||
private var totalTriples: Int = 0
|
private var totalTriples: Int = 0
|
||||||
private var totalTetrises: Int = 0
|
private var totalQuads: Int = 0
|
||||||
|
|
||||||
// Session stats
|
// Session stats
|
||||||
private var sessionScore: Int = 0
|
private var sessionScore: Int = 0
|
||||||
|
@ -29,11 +33,16 @@ class StatsManager(context: Context) {
|
||||||
private var sessionTime: Long = 0
|
private var sessionTime: Long = 0
|
||||||
private var sessionLevel: Int = 0
|
private var sessionLevel: Int = 0
|
||||||
|
|
||||||
|
// Special move stats (session)
|
||||||
|
private var sessionTSpins: Int = 0
|
||||||
|
private var sessionPerfectClears: Int = 0
|
||||||
|
private var sessionMaxCombo: Int = 0
|
||||||
|
|
||||||
// Line clear stats (session)
|
// Line clear stats (session)
|
||||||
private var sessionSingles: Int = 0
|
private var sessionSingles: Int = 0
|
||||||
private var sessionDoubles: Int = 0
|
private var sessionDoubles: Int = 0
|
||||||
private var sessionTriples: Int = 0
|
private var sessionTriples: Int = 0
|
||||||
private var sessionTetrises: Int = 0
|
private var sessionQuads: Int = 0
|
||||||
|
|
||||||
init {
|
init {
|
||||||
loadStats()
|
loadStats()
|
||||||
|
@ -49,11 +58,15 @@ class StatsManager(context: Context) {
|
||||||
maxScore = prefs.getInt(KEY_MAX_SCORE, 0)
|
maxScore = prefs.getInt(KEY_MAX_SCORE, 0)
|
||||||
maxLines = prefs.getInt(KEY_MAX_LINES, 0)
|
maxLines = prefs.getInt(KEY_MAX_LINES, 0)
|
||||||
|
|
||||||
|
// Load special move stats
|
||||||
|
totalTSpins = prefs.getInt(KEY_TOTAL_T_SPINS, 0)
|
||||||
|
totalPerfectClears = prefs.getInt(KEY_TOTAL_PERFECT_CLEARS, 0)
|
||||||
|
|
||||||
// Load line clear stats
|
// Load line clear stats
|
||||||
totalSingles = prefs.getInt(KEY_TOTAL_SINGLES, 0)
|
totalSingles = prefs.getInt(KEY_TOTAL_SINGLES, 0)
|
||||||
totalDoubles = prefs.getInt(KEY_TOTAL_DOUBLES, 0)
|
totalDoubles = prefs.getInt(KEY_TOTAL_DOUBLES, 0)
|
||||||
totalTriples = prefs.getInt(KEY_TOTAL_TRIPLES, 0)
|
totalTriples = prefs.getInt(KEY_TOTAL_TRIPLES, 0)
|
||||||
totalTetrises = prefs.getInt(KEY_TOTAL_TETRISES, 0)
|
totalQuads = prefs.getInt(KEY_TOTAL_QUADS, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveStats() {
|
private fun saveStats() {
|
||||||
|
@ -67,9 +80,11 @@ class StatsManager(context: Context) {
|
||||||
.putInt(KEY_MAX_SCORE, maxScore)
|
.putInt(KEY_MAX_SCORE, maxScore)
|
||||||
.putInt(KEY_MAX_LINES, maxLines)
|
.putInt(KEY_MAX_LINES, maxLines)
|
||||||
.putInt(KEY_TOTAL_SINGLES, totalSingles)
|
.putInt(KEY_TOTAL_SINGLES, totalSingles)
|
||||||
|
.putInt(KEY_TOTAL_T_SPINS, totalTSpins)
|
||||||
|
.putInt(KEY_TOTAL_PERFECT_CLEARS, totalPerfectClears)
|
||||||
.putInt(KEY_TOTAL_DOUBLES, totalDoubles)
|
.putInt(KEY_TOTAL_DOUBLES, totalDoubles)
|
||||||
.putInt(KEY_TOTAL_TRIPLES, totalTriples)
|
.putInt(KEY_TOTAL_TRIPLES, totalTriples)
|
||||||
.putInt(KEY_TOTAL_TETRISES, totalTetrises)
|
.putInt(KEY_TOTAL_QUADS, totalQuads)
|
||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +97,10 @@ class StatsManager(context: Context) {
|
||||||
sessionSingles = 0
|
sessionSingles = 0
|
||||||
sessionDoubles = 0
|
sessionDoubles = 0
|
||||||
sessionTriples = 0
|
sessionTriples = 0
|
||||||
sessionTetrises = 0
|
sessionQuads = 0
|
||||||
|
sessionTSpins = 0
|
||||||
|
sessionPerfectClears = 0
|
||||||
|
sessionMaxCombo = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateSessionStats(score: Int, lines: Int, pieces: Int, time: Long, level: Int) {
|
fun updateSessionStats(score: Int, lines: Int, pieces: Int, time: Long, level: Int) {
|
||||||
|
@ -108,8 +126,8 @@ class StatsManager(context: Context) {
|
||||||
totalTriples++
|
totalTriples++
|
||||||
}
|
}
|
||||||
4 -> {
|
4 -> {
|
||||||
sessionTetrises++
|
sessionQuads++
|
||||||
totalTetrises++
|
totalQuads++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +160,11 @@ class StatsManager(context: Context) {
|
||||||
fun getTotalSingles(): Int = totalSingles
|
fun getTotalSingles(): Int = totalSingles
|
||||||
fun getTotalDoubles(): Int = totalDoubles
|
fun getTotalDoubles(): Int = totalDoubles
|
||||||
fun getTotalTriples(): Int = totalTriples
|
fun getTotalTriples(): Int = totalTriples
|
||||||
fun getTotalTetrises(): Int = totalTetrises
|
fun getTotalQuads(): Int = totalQuads
|
||||||
|
|
||||||
|
// Getters for special move stats (lifetime)
|
||||||
|
fun getTotalTSpins(): Int = totalTSpins
|
||||||
|
fun getTotalPerfectClears(): Int = totalPerfectClears
|
||||||
|
|
||||||
// Getters for session stats
|
// Getters for session stats
|
||||||
fun getSessionScore(): Int = sessionScore
|
fun getSessionScore(): Int = sessionScore
|
||||||
|
@ -150,12 +172,17 @@ class StatsManager(context: Context) {
|
||||||
fun getSessionPieces(): Int = sessionPieces
|
fun getSessionPieces(): Int = sessionPieces
|
||||||
fun getSessionTime(): Long = sessionTime
|
fun getSessionTime(): Long = sessionTime
|
||||||
fun getSessionLevel(): Int = sessionLevel
|
fun getSessionLevel(): Int = sessionLevel
|
||||||
|
fun getSessionTriples(): Int = sessionTriples
|
||||||
|
fun getSessionQuads(): Int = sessionQuads
|
||||||
|
|
||||||
// Getters for line clear stats (session)
|
// Add missing getters for session line clears
|
||||||
fun getSessionSingles(): Int = sessionSingles
|
fun getSessionSingles(): Int = sessionSingles
|
||||||
fun getSessionDoubles(): Int = sessionDoubles
|
fun getSessionDoubles(): Int = sessionDoubles
|
||||||
fun getSessionTriples(): Int = sessionTriples
|
|
||||||
fun getSessionTetrises(): Int = sessionTetrises
|
// Getters for special move stats (session)
|
||||||
|
fun getSessionTSpins(): Int = sessionTSpins
|
||||||
|
fun getSessionPerfectClears(): Int = sessionPerfectClears
|
||||||
|
fun getSessionMaxCombo(): Int = sessionMaxCombo
|
||||||
|
|
||||||
fun resetStats() {
|
fun resetStats() {
|
||||||
// Reset all lifetime stats
|
// Reset all lifetime stats
|
||||||
|
@ -172,7 +199,11 @@ class StatsManager(context: Context) {
|
||||||
totalSingles = 0
|
totalSingles = 0
|
||||||
totalDoubles = 0
|
totalDoubles = 0
|
||||||
totalTriples = 0
|
totalTriples = 0
|
||||||
totalTetrises = 0
|
totalQuads = 0
|
||||||
|
|
||||||
|
// Reset special move stats
|
||||||
|
totalTSpins = 0
|
||||||
|
totalPerfectClears = 0
|
||||||
|
|
||||||
// Save the reset stats
|
// Save the reset stats
|
||||||
saveStats()
|
saveStats()
|
||||||
|
@ -189,8 +220,10 @@ class StatsManager(context: Context) {
|
||||||
private const val KEY_MAX_SCORE = "max_score"
|
private const val KEY_MAX_SCORE = "max_score"
|
||||||
private const val KEY_MAX_LINES = "max_lines"
|
private const val KEY_MAX_LINES = "max_lines"
|
||||||
private const val KEY_TOTAL_SINGLES = "total_singles"
|
private const val KEY_TOTAL_SINGLES = "total_singles"
|
||||||
|
private const val KEY_TOTAL_T_SPINS = "total_t_spins"
|
||||||
|
private const val KEY_TOTAL_PERFECT_CLEARS = "total_perfect_clears"
|
||||||
private const val KEY_TOTAL_DOUBLES = "total_doubles"
|
private const val KEY_TOTAL_DOUBLES = "total_doubles"
|
||||||
private const val KEY_TOTAL_TRIPLES = "total_triples"
|
private const val KEY_TOTAL_TRIPLES = "total_triples"
|
||||||
private const val KEY_TOTAL_TETRISES = "total_tetrises"
|
private const val KEY_TOTAL_QUADS = "total_quads"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -592,7 +592,7 @@
|
||||||
android:fontFamily="sans-serif" />
|
android:fontFamily="sans-serif" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/sessionTetrisesText"
|
android:id="@+id/sessionQuadsText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
|
|
|
@ -117,7 +117,7 @@
|
||||||
android:layout_marginBottom="4dp"/>
|
android:layout_marginBottom="4dp"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/totalTetrisesText"
|
android:id="@+id/totalQuadsText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
|
|
|
@ -266,14 +266,15 @@
|
||||||
android:fontFamily="sans-serif" />
|
android:fontFamily="sans-serif" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/sessionTetrisesText"
|
android:id="@+id/sessionQuadsText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:fontFamily="sans-serif" />
|
android:fontFamily="sans-serif"
|
||||||
|
android:text="T-Spins: 0" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/playAgainButton"
|
android:id="@+id/playAgainButton"
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
android:layout_marginBottom="4dp"/>
|
android:layout_marginBottom="4dp"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/totalTetrisesText"
|
android:id="@+id/totalQuadsText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
|
|
|
@ -44,9 +44,15 @@
|
||||||
<string name="singles">singles: %d</string>
|
<string name="singles">singles: %d</string>
|
||||||
<string name="doubles">doubles: %d</string>
|
<string name="doubles">doubles: %d</string>
|
||||||
<string name="triples">triples: %d</string>
|
<string name="triples">triples: %d</string>
|
||||||
<string name="tetrises">tetrises: %d</string>
|
<string name="quads">quads: %d</string>
|
||||||
<string name="reset_stats">reset stats</string>
|
<string name="reset_stats">reset stats</string>
|
||||||
<string name="music">music</string>
|
<string name="music">music</string>
|
||||||
<string name="customization">Customization</string>
|
<string name="customization">Customization</string>
|
||||||
<string name="random_mode">Random Mode</string>
|
<string name="random_mode">Random Mode</string>
|
||||||
|
<string name="next_piece">Next</string>
|
||||||
|
<string name="hold_piece">Hold</string>
|
||||||
|
<string name="lines_cleared">lines: %d</string>
|
||||||
|
<string name="t_spins">t-spins: %d</string>
|
||||||
|
<string name="perfect_clears">perfect clears: %d</string>
|
||||||
|
<string name="max_combo">max combo: %d</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Add table
Add a link
Reference in a new issue