StatsRepository

class StatsRepository(context: Context, scope: CoroutineScope)

Scoreboard, profiles and match history, stored as one JSON file in app-private storage. Writes go to a temp file first and are renamed into place so a crash can't corrupt it.

Constructors

Link copied to clipboard
constructor(context: Context, scope: CoroutineScope)

Properties

Link copied to clipboard
val newAwards: SharedFlow<List<MedalAward>>

Medals earned by the round just recorded — used for the in-game celebration.

Link copied to clipboard
val newUnlocks: SharedFlow<List<ArcadeGame>>

Arcade games unlocked by the latest result — celebrated like medals.

Link copied to clipboard
val stats: StateFlow<StatsData>

Functions

Link copied to clipboard
fun addProfile(name: String, color: Long): Profile
Link copied to clipboard
Link copied to clipboard
fun record(result: MatchResult)
Link copied to clipboard
fun recordBlocks(won: Boolean, score: Int, lines: Int)
Link copied to clipboard
fun recordHive(points: Int, words: Int, levelCleared: Boolean)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Clears scores, history and medals — but games you've unlocked stay unlocked.

Link copied to clipboard
fun updateProfile(profile: Profile)
Link copied to clipboard
fun useDemo(game: ArcadeGame)