BumbleHive: Hard mode gets its own High Scores table
Paul chose a separate list. Hard runs are saved only under their own record (HiveHard) in the profile's Arcade file; Normal's stay under Hive exactly as before, so the "· Hard" marker is gone. High Scores shows a Normal / HARD switch on BumbleHive's row (Left/Right), and the Top 10 says which table it is. Clear high scores for BumbleHive clears both. Kids filtering and per-profile storage are unchanged. 5 new tests (tables never mix, Normal's data untouched, files from before). 853 run, 24 skipped, 0 failed; Node 28 passed; lint unchanged; release APK unchanged in size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
package tv.orbit.classic.arcade.hive
|
||||
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import tv.orbit.classic.arcade.ArcadeGames
|
||||
import tv.orbit.classic.arcade.ArcadeProfileData
|
||||
import tv.orbit.classic.arcade.ArcadeRun
|
||||
import tv.orbit.classic.arcade.GameRecord
|
||||
import tv.orbit.classic.arcade.HIVE_HARD_SCORES
|
||||
import tv.orbit.classic.arcade.ResetAction
|
||||
import tv.orbit.classic.arcade.RunEnd
|
||||
import tv.orbit.classic.arcade.ScoreKind
|
||||
import tv.orbit.classic.arcade.applyReset
|
||||
import tv.orbit.classic.arcade.decodeArcade
|
||||
import tv.orbit.classic.arcade.encodeArcade
|
||||
import tv.orbit.classic.arcade.recordRun
|
||||
import tv.orbit.classic.arcade.scoreTable
|
||||
import tv.orbit.classic.arcade.scoreTableLabel
|
||||
import tv.orbit.classic.arcade.scoreTableTitle
|
||||
import tv.orbit.classic.arcade.scoreTables
|
||||
|
||||
/** BumbleHive Hard has its own High Scores table (Paul, 8 November 2026); Normal's stays exactly as it was. */
|
||||
class HiveScoresTest {
|
||||
/** A profile's file as it is today: Normal BumbleHive runs, levels and settings, and another game. */
|
||||
private val existing = ArcadeProfileData("p2abc9")
|
||||
.withGame("Hive") { GameRecord(runs = listOf(ArcadeRun(2400, 1_000L, "Level 12"), ArcadeRun(1900, 2_000L, "Level 11")), level = mapOf("normal" to "{\"unlocked\":12}"),
|
||||
settings = mapOf("sound" to true), firstRunSeen = true, lastPlayedMs = 2_000L) }
|
||||
.withGame("Snake") { GameRecord(runs = listOf(ArcadeRun(140, 3_000L))) }
|
||||
|
||||
@Test fun eachModeReportsToItsOwnTableOnly() {
|
||||
val normal = ArrayList<RunEnd>(); val tables = ArrayList<Pair<String, RunEnd>>()
|
||||
val router = HiveRunRouter({ normal += it }, { t, e -> tables += t to e })
|
||||
router.report(HiveMode.Normal, RunEnd(500, true, "Level 3"))
|
||||
router.report(HiveMode.Hard, RunEnd(800, true, "Level 2"))
|
||||
assertEquals(listOf(RunEnd(500, true, "Level 3")), normal)
|
||||
assertEquals(listOf(HIVE_HARD_SCORES to RunEnd(800, true, "Level 2")), tables)
|
||||
}
|
||||
|
||||
@Test fun hardRunsNeverReachNormalsTableAndNormalsDataIsUntouched() {
|
||||
val before = existing.game("Hive")
|
||||
val beforeFile = JSONObject(encodeArcade(existing)).getJSONObject("games").getJSONObject("Hive").toString()
|
||||
var d = existing
|
||||
for (i in 1..12) d = recordRun(d, HIVE_HARD_SCORES, ScoreKind.Points, RunEnd(9000 + i, true, "Level $i"), 10_000L + i)
|
||||
// Normal's record is the same object's worth, field for field, and the same in the file.
|
||||
assertEquals(before, d.game("Hive"))
|
||||
val back = decodeArcade(encodeArcade(d), "p2abc9")!!
|
||||
assertEquals(beforeFile, JSONObject(encodeArcade(back)).getJSONObject("games").getJSONObject("Hive").toString())
|
||||
assertEquals(listOf(2400, 1900), back.game("Hive").runs.map { it.score })
|
||||
// Hard's table has its own top 10, with no Normal run in it, and no "· Hard" marker needed.
|
||||
val hard = back.game(HIVE_HARD_SCORES).runs
|
||||
assertEquals(10, hard.size)
|
||||
assertTrue(hard.all { it.score > 9000 && it.detail?.contains("Hard") == false })
|
||||
// And Normal runs never reach Hard's.
|
||||
val n = recordRun(back, "Hive", ScoreKind.Points, RunEnd(3000, true, "Level 13"), 99_999L)
|
||||
assertEquals(back.game(HIVE_HARD_SCORES), n.game(HIVE_HARD_SCORES))
|
||||
assertEquals(3000, n.game("Hive").runs.first().score)
|
||||
}
|
||||
|
||||
@Test fun aFileFromBeforeHasAnEmptyHardTable() {
|
||||
val old = decodeArcade(encodeArcade(existing), "p2abc9")!!
|
||||
assertTrue(old.game(HIVE_HARD_SCORES).runs.isEmpty())
|
||||
assertEquals(existing.game("Hive"), old.game("Hive"))
|
||||
}
|
||||
|
||||
@Test fun theHighScoresRowSwitchesTablesAndSaysWhichIsShowing() {
|
||||
val hive = ArcadeGames.Hive
|
||||
assertEquals(listOf("Hive", HIVE_HARD_SCORES), scoreTables("Hive"))
|
||||
assertEquals("Hive", scoreTable(hive, hard = false)); assertEquals(HIVE_HARD_SCORES, scoreTable(hive, hard = true))
|
||||
assertEquals("◀ Normal ▶", scoreTableLabel(hive, false)); assertEquals("◀ HARD ▶", scoreTableLabel(hive, true))
|
||||
assertEquals("BUMBLEHIVE HARD · TOP 10", scoreTableTitle(hive, true)); assertEquals("BUMBLEHIVE · TOP 10", scoreTableTitle(hive, false))
|
||||
// Every other game has one table and no switch.
|
||||
for (g in ArcadeGames.all.filter { it.id != "Hive" }) {
|
||||
assertEquals(listOf(g.id), scoreTables(g.id)); assertEquals(g.id, scoreTable(g, true)); assertNull(scoreTableLabel(g, true))
|
||||
}
|
||||
// Hard's table is not a game: no card, nothing for Kids filtering to show or hide on its own.
|
||||
assertNull(ArcadeGames.byId(HIVE_HARD_SCORES))
|
||||
}
|
||||
|
||||
@Test fun clearingBumbleHiveScoresClearsBothTablesAndOnlyThem() {
|
||||
val d = recordRun(existing, HIVE_HARD_SCORES, ScoreKind.Points, RunEnd(700, true, "Level 1"), 5L)
|
||||
val cleared = applyReset(d, "Hive", ResetAction.ClearHighScores, 6L)
|
||||
assertTrue(cleared.game("Hive").runs.isEmpty()); assertTrue(cleared.game(HIVE_HARD_SCORES).runs.isEmpty())
|
||||
assertEquals(existing.game("Hive").level, cleared.game("Hive").level)
|
||||
assertEquals(d.game("Snake"), cleared.game("Snake"))
|
||||
val snake = applyReset(d, "Snake", ResetAction.ClearHighScores, 6L)
|
||||
assertEquals(d.game("Hive"), snake.game("Hive")); assertEquals(d.game(HIVE_HARD_SCORES), snake.game(HIVE_HARD_SCORES))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user