Arcade Daily: one free challenge a day across the games, a star on the day, no streaks; stars awarded as runs end

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 11:24:51 +00:00
co-authored by Claude Opus 5.5
parent 111a9f5d5b
commit d4d9c80746
7 changed files with 232 additions and 8 deletions
@@ -16,7 +16,7 @@ class KidsArcadeTest {
@Test fun grownUpsSeeEveryGame() {
assertEquals(ArcadeGames.all.map { it.id }, ids(grown))
assertEquals(16, ids(grown).size)
assertEquals(17, ids(grown).size)
// A grown-up's Arcade for Kids setting means nothing.
assertEquals(ArcadeGames.all.map { it.id }, ids(grown.withKidsArcade(KidsArcade.Off)))
assertEquals(ArcadeGames.all.map { it.id }, ids(null))
@@ -70,16 +70,16 @@ class KidsArcadeTest {
@Test fun theFamilyLineSaysWhatKidsReallySee() {
// The audit: "On: the games chosen for Kids" promised a choice that didn't exist.
assertEquals("Off: no Arcade for Kids", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Off)))
assertEquals("Kids-suitable games: 14 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.KidsSuitable)))
assertEquals("Kids-suitable games: 15 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.KidsSuitable)))
assertEquals("Chosen games: 2 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Chosen, setOf("Pairs", "Sky", "Retired"))))
assertEquals("Chosen games: none chosen yet, so no Arcade", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Chosen, emptySet())))
}
@Test fun everyGameIsDescribed() {
assertEquals(ArcadeGames.all.size, ArcadeGames.all.map { it.id }.toSet().size)
assertEquals(8, ArcadeGames.originals.size); assertEquals(8, ArcadeGames.classics.size)
assertEquals(9, ArcadeGames.originals.size); assertEquals(8, ArcadeGames.classics.size)
// All five Originals play now (Orbiteroids, the last, 9 November 2026); every Classic does.
assertEquals(listOf("OrbiRaiders", "ChannelChaos", "Hive", "NightShift", "Orbiteroids", "QuizNight", "TestCardTangle", "Codebreaker"), ArcadeGames.originals.filter { it.launchable }.map { it.id })
assertEquals(listOf("OrbiRaiders", "ChannelChaos", "Hive", "NightShift", "Orbiteroids", "QuizNight", "TestCardTangle", "Codebreaker", "ArcadeDaily"), ArcadeGames.originals.filter { it.launchable }.map { it.id })
assertTrue(ArcadeGames.classics.all { it.launchable })
ArcadeGames.all.forEach { g ->
assertTrue(g.id, g.controls.isNotEmpty()); assertTrue(g.id, g.title.isNotBlank()); assertTrue(g.id, g.goal.isNotBlank())
@@ -0,0 +1,52 @@
package tv.orbit.classic.arcade.daily
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.RunEnd
import tv.orbit.classic.arcade.ScoreKind
import tv.orbit.classic.arcade.bestOf
class ArcadeDailyTest {
private val day = java.time.LocalDate.of(2026, 11, 9)
private val all = playableIds(ArcadeGames.all)
@Test fun everyChallengeIsForARealGameAndTheDayPicksOne() {
assertTrue(DailyChallenges.all { ArcadeGames.byId(it.gameId)?.launchable == true })
assertFalse(ARCADE_DAILY_ID in all)
assertEquals(dailyFor(day, all)!!.text, dailyFor(day, all)!!.text)
// Over a fortnight it moves round the games.
assertTrue((0L until 14L).map { dailyFor(day.plusDays(it), all)!!.gameId }.toSet().size >= 8)
// Only from the games a profile can play: a Kids profile without Blast Off never gets it.
val kids = all - "Blast" - "Sky"
assertTrue((0L until 60L).none { dailyFor(day.plusDays(it), kids)!!.gameId in setOf("Blast", "Sky") })
assertNull(dailyFor(day, emptySet()))
}
@Test fun meetingTheChallengeStarsTheDayOnceAndMissingItCostsNothing() {
val ch = dailyFor(day, all)!!
var d = ArcadeProfileData(profileId = "p1")
// A run in another game does nothing.
val other = DailyChallenges.first { it.gameId != ch.gameId }.gameId
d = awardDaily(d, other, RunEnd(999_999, true), day, all, 1)
assertNull(d.game(ARCADE_DAILY_ID).level[starKey(day)])
// A run that meets it stars the day, once.
d = awardDaily(d, ch.gameId, RunEnd(999_999, true), day, all, 2)
assertEquals(ch.gameId, d.game(ARCADE_DAILY_ID).level[starKey(day)])
d = awardDaily(d, ch.gameId, RunEnd(999_999, true), day, all, 3)
assertEquals(1, bestOf(d.game(ARCADE_DAILY_ID), ScoreKind.Solved))
// The week shows it; there is no streak to lose.
val week = weekStars(d.game(ARCADE_DAILY_ID).level, day)
assertEquals(7, week.size); assertEquals(1, week.count { it.second }); assertEquals(java.time.DayOfWeek.MONDAY, week.first().first.dayOfWeek)
}
@Test fun aRunThatFallsShortDoesntCount() {
val pts = DailyChallenges.first { it.gameId == "OrbMan" }
assertFalse(pts.met("OrbMan", RunEnd(1_999, true))); assertTrue(pts.met("OrbMan", RunEnd(2_000, false)))
// Signal Run's table isn't Classic's.
assertFalse(pts.met("OrbManSignal", RunEnd(5_000, true)))
val fin = DailyChallenges.first { it.gameId == "Patience" }
assertFalse(fin.met("Patience", RunEnd(80, false))); assertTrue(fin.met("Patience", RunEnd(80, true)))
}
}