diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index e450484e..10407a24 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -9,8 +9,8 @@ android { applicationId = "tv.orbit.classic" minSdk = 26 targetSdk = 36 - versionCode = 307 - versionName = "0.116.1-orbiteroids" + versionCode = 308 + versionName = "0.117.0-quiz-night" } buildFeatures { compose = true } // The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so diff --git a/android/app/src/main/java/tv/orbit/classic/arcade/ArcadeGames.kt b/android/app/src/main/java/tv/orbit/classic/arcade/ArcadeGames.kt index e745b5fe..5ebc7883 100644 --- a/android/app/src/main/java/tv/orbit/classic/arcade/ArcadeGames.kt +++ b/android/app/src/main/java/tv/orbit/classic/arcade/ArcadeGames.kt @@ -97,6 +97,13 @@ internal object ArcadeGames { listOf(Control("◀▶▲▼", "Fly that way: Zip aims and fires"), BackPause), "Clear each sector, and watch your hull. Fly through power-ups to switch them on.", listOf(GameSetting("sounds", "Sound effects"))) { tv.orbit.classic.arcade.orbiteroids.OrbiteroidsScreen(it) } + // The new Originals (approved 9 November 2026), first Quiz Night: tv.orbit.classic.arcade.quiz. + val QuizNight: ArcadeGame = GameDef("QuizNight", "Quiz Night", "A family quiz, everyone at their level", "General knowledge, movies and TV, for one to four players.", Mascot.Ollie, + kidsSuitable = true, original = true, launchable = true, ScoreKind.Points, keepsLevels = false, legacyRecordKey = null, + listOf(Control("◀▶▲▼", "Choose an answer"), Control("OK", "Answer"), BackPause), "Each player answers at their own level; most right wins.") { + tv.orbit.classic.arcade.quiz.QuizNightScreen(it) + } + // Classics: the eight Kotlin games, unchanged, each in a thin wrapper. val OrbMan: ArcadeGame = GameDef("OrbMan", "Star Chase", "Maze chase starring Ollie", "Help Ollie clear the stars, and dodge Blaze, Zip, Drift and Luna.", Mascot.Ollie, kidsSuitable = true, original = false, launchable = true, ScoreKind.Points, keepsLevels = false, legacyRecordKey = "orb_man_best", @@ -127,7 +134,7 @@ internal object ArcadeGames { listOf(Control("◀▶▲▼", "Point"), Control("OK", "Pick up / put down"), Control("OK twice", "Send a card home"), Control("Back", "Put back, or pause")), "Klondike, one card at a time: build each suit home, ace to king.") { PatienceScreen(it) } - val originals = listOf(OrbiRaiders, ChannelChaos, Hive, NightShift, Orbiteroids) + val originals = listOf(OrbiRaiders, ChannelChaos, Hive, NightShift, Orbiteroids, QuizNight) val classics = listOf(OrbMan, Blast, Sky, Snake, Blocks, Bricks, Pairs, Patience) val all = originals + classics diff --git a/android/app/src/main/java/tv/orbit/classic/arcade/ArcadeHome.kt b/android/app/src/main/java/tv/orbit/classic/arcade/ArcadeHome.kt index 751e2061..66715aeb 100644 --- a/android/app/src/main/java/tv/orbit/classic/arcade/ArcadeHome.kt +++ b/android/app/src/main/java/tv/orbit/classic/arcade/ArcadeHome.kt @@ -3,6 +3,8 @@ package tv.orbit.classic.arcade import androidx.compose.foundation.Canvas import androidx.compose.foundation.Image import androidx.compose.foundation.background +import androidx.compose.foundation.horizontalScroll +import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.focusable @@ -141,7 +143,8 @@ internal fun OrbitArcade(modifier: Modifier, onPlaying: (Boolean) -> Unit, onExi onLeave = { session = SessionState.Exited; playing = null }, difficulty = difficultyFor(data, profile.kind), autoFire = autoFireFor(data), reduceFlashing = reduceFlashingFor(data), kept = record.kept, writeKept = { values -> update { d -> d.withGame(game.id) { it.copy(kept = it.kept + values) } } }, - bests = scoreTableDefs(game.id, game.scoreKind).associate { t -> t.id to bestOf(data.game(t.id), t.kind) }) + bests = scoreTableDefs(game.id, game.scoreKind).associate { t -> t.id to bestOf(data.game(t.id), t.kind) }, + kids = profile.kind == ProfileKind.Kids) key(game.id) { game.Content(play) } return } @@ -264,9 +267,13 @@ private fun GameShelves(visible: List, data: ArcadeProfileData, pick // Focus starts on the game played last, else the Arcade's pick. val start = recentVisible(data.recent, visible).firstOrNull() ?: pick ?: visible.firstOrNull() Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) { - if (originals.isNotEmpty()) Row(Modifier.fillMaxWidth().height(170.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) { - originals.forEach { g -> OriginalCard(g, data.game(g.id), Modifier.weight(1f).fillMaxHeight().then(if (g == start) Modifier.focusRequester(firstCard) else Modifier), onChosen, onPlay, onMenu) } - repeat(5 - originals.size) { Spacer(Modifier.weight(1f)) } + // Five cards fill the row; more than five (Quiz Night and the new games after it) scroll along it, each card the same + // width, the remote's focus bringing the next one into view. + if (originals.isNotEmpty()) BoxWithConstraints(Modifier.fillMaxWidth().height(170.dp)) { + val card = (maxWidth - 8.dp * 4) / 5 + Row(Modifier.fillMaxSize().horizontalScroll(rememberScrollState()), horizontalArrangement = Arrangement.spacedBy(8.dp)) { + originals.forEach { g -> OriginalCard(g, data.game(g.id), Modifier.width(card).fillMaxHeight().then(if (g == start) Modifier.focusRequester(firstCard) else Modifier), onChosen, onPlay, onMenu) } + } } if (classics.isNotEmpty()) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { diff --git a/android/app/src/main/java/tv/orbit/classic/arcade/ArcadePlay.kt b/android/app/src/main/java/tv/orbit/classic/arcade/ArcadePlay.kt index 62e8aaea..a36e473a 100644 --- a/android/app/src/main/java/tv/orbit/classic/arcade/ArcadePlay.kt +++ b/android/app/src/main/java/tv/orbit/classic/arcade/ArcadePlay.kt @@ -38,6 +38,8 @@ internal class ArcadePlay( val onRunEndIn: (String, RunEnd) -> Unit = { _, end -> onRunEnd(end) }, /** The best in each of the game's High Scores tables, by table id ([scoreTables]), for a mode's title and result. */ val bests: Map = emptyMap(), + /** A Kids profile is playing (Quiz Night keeps to its Kid and Older kid questions). */ + val kids: Boolean = false, ) { /** The best in [table], or the game's own best. */ fun bestIn(table: String) = bests[table] ?: best diff --git a/android/app/src/main/java/tv/orbit/classic/arcade/ClassicKit.kt b/android/app/src/main/java/tv/orbit/classic/arcade/ClassicKit.kt index 85a01180..0cfeede8 100644 --- a/android/app/src/main/java/tv/orbit/classic/arcade/ClassicKit.kt +++ b/android/app/src/main/java/tv/orbit/classic/arcade/ClassicKit.kt @@ -67,7 +67,8 @@ private fun Chip(text: String, fill: Color) = Text(text, Modifier.background(fil @Composable internal fun ClassicTitle(game: ArcadeGame, backdrop: ArcadeBackdrop, accent: Color, hostLine: String, stats: List>, timed: Boolean, difficulty: Difficulty, refocus: Boolean, onPlay: () -> Unit, onHowTo: () -> Unit, onBack: () -> Unit, - mode: String = "Classic", modes: Int = 1, onMode: () -> Unit = {}, playLabel: String = "Play", note: String? = null) { + mode: String = "Classic", modes: Int = 1, onMode: () -> Unit = {}, playLabel: String = "Play", note: String? = null, + kicker: String = "AN ORBIT ARCADE CLASSIC", timedLabel: String? = null) { val play = remember { FocusRequester() } LaunchedEffect(refocus) { if (refocus) runCatching { play.requestFocus() } } Box(Modifier.fillMaxSize().onBackKey(action = onBack)) { @@ -76,7 +77,7 @@ internal fun ClassicTitle(game: ArcadeGame, backdrop: ArcadeBackdrop, accent: Co Column(Modifier.fillMaxSize().padding(start = 48.dp, end = 48.dp, top = 24.dp, bottom = 12.dp)) { Row(Modifier.fillMaxWidth().weight(1f)) { Column(Modifier.weight(1f)) { - Text("AN ORBIT ARCADE CLASSIC", color = ArcadeColours.Muted, fontSize = 13.sp, letterSpacing = 5.sp) + Text(kicker, color = ArcadeColours.Muted, fontSize = 13.sp, letterSpacing = 5.sp) Text(game.title.uppercase(), Modifier.padding(top = 2.dp), color = ArcadeColours.Ink, fontFamily = Anton, fontSize = 76.sp, maxLines = 1, style = TextStyle(shadow = Shadow(accent, Offset(5f, 5f), 0f))) Text(game.tagline, color = ArcadeColours.Ink, fontSize = 18.sp, fontWeight = FontWeight.SemiBold) @@ -115,7 +116,7 @@ internal fun ClassicTitle(game: ArcadeGame, backdrop: ArcadeBackdrop, accent: Co Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(14.dp)) { stats.forEach { (label, value) -> Row { Text("$label ", color = ArcadeColours.Muted, fontSize = 14.sp); Text(value, color = ArcadeColours.Ink, fontSize = 14.sp, fontWeight = FontWeight.Bold) } } Chip(mode, ArcadeColours.Yellow) - Chip(if (timed) difficulty.title else "No timer", ArcadeColours.Cyan) + Chip(timedLabel ?: if (timed) difficulty.title else "No timer", ArcadeColours.Cyan) } Spacer(Modifier.height(8.dp)) KeyFooter(listOf(Control("▲▼", "Choose"), Control("OK", "Select"), Control("Back", "Arcade home"))) diff --git a/android/app/src/main/java/tv/orbit/classic/arcade/quiz/QuizGame.kt b/android/app/src/main/java/tv/orbit/classic/arcade/quiz/QuizGame.kt new file mode 100644 index 00000000..c16d8d56 --- /dev/null +++ b/android/app/src/main/java/tv/orbit/classic/arcade/quiz/QuizGame.kt @@ -0,0 +1,74 @@ +package tv.orbit.classic.arcade.quiz + +/** + * Quiz Night (9 November 2026): a family quiz, hosted by Ollie. One to four players share the remote, each at their own + * level (Paul: "play 1 adult, player 2 kid"), taking turns: every round, each player answers one question at their level. + * The game has no screen in it, so it can be tested. + */ +internal class QuizPlayer(val name: String, val level: QuizLevel) + +/** Which questions a game draws from: one category, or all three mixed. */ +internal enum class QuizMix(val title: String, val category: QuizCategory?) { + Mixed("Mixed", null), General("General knowledge", QuizCategory.General), Movies("Movies", QuizCategory.Movies), Tv("TV", QuizCategory.Tv) +} + +internal const val QUIZ_ROUNDS = 5 +internal const val QUIZ_POINTS = 100 +internal const val QUIZ_MAX_PLAYERS = 4 + +/** The levels a profile may choose from: a Kids profile never sees Adult questions. */ +internal fun quizLevels(kids: Boolean) = if (kids) listOf(QuizLevel.Kid, QuizLevel.OlderKid) else QuizLevel.entries + +/** The questions open to [level] in [mix]. */ +internal fun quizPool(level: QuizLevel, mix: QuizMix) = QuizQuestions.filter { it.level == level && (mix.category == null || it.category == mix.category) } + +/** One question as asked: its answers in the order shown, and which is right. */ +internal class QuizAsk(val question: QuizQuestion, val order: IntArray) { + val shown get() = order.map { question.answers[it] } + val rightAt get() = order.indexOf(0) +} + +internal class QuizGame(val players: List, val mix: QuizMix, seed: Long) { + private val random = java.util.Random(seed) + /** Rounds: as many as every player's pool has fresh questions for, at most five. */ + val rounds: Int = players.groupBy { it.level }.minOf { (level, ps) -> quizPool(level, mix).size / ps.size }.coerceIn(1, QUIZ_ROUNDS) + // Each level's questions, shuffled once and dealt in turn, so nobody gets the same question twice in a game. + private val decks = HashMap>().apply { + for (level in players.map { it.level }.distinct()) put(level, ArrayDeque(quizPool(level, mix).shuffled(random))) + } + val scores = IntArray(players.size) + val rights = IntArray(players.size) + var round = 1; private set + var turn = 0; private set + /** The question being asked, and the answer given (null until OK). */ + var ask: QuizAsk = deal(); private set + var answered: Int? = null; private set + val over get() = round > rounds + + private fun deal(): QuizAsk { + val q = decks.getValue(players[turn].level).removeFirst() + val order = intArrayOf(0, 1, 2, 3).also { o -> for (i in 3 downTo 1) { val j = random.nextInt(i + 1); val t = o[i]; o[i] = o[j]; o[j] = t } } + return QuizAsk(q, order) + } + + /** OK on answer [at] (0 to 3, as shown): right scores; either way the answer is shown until [next]. */ + fun answer(at: Int): Boolean { + if (answered != null || over) return false + answered = at + val right = at == ask.rightAt + if (right) { scores[turn] += QUIZ_POINTS; rights[turn]++ } + return right + } + + /** On to the next player's question (and the next round after the last player). */ + fun next() { + if (answered == null || over) return + answered = null + turn++ + if (turn == players.size) { turn = 0; round++ } + if (!over) ask = deal() + } + + /** The winners: everyone with the top score. */ + fun winners(): List { val top = scores.max(); return players.indices.filter { scores[it] == top } } +} diff --git a/android/app/src/main/java/tv/orbit/classic/arcade/quiz/QuizNightScreen.kt b/android/app/src/main/java/tv/orbit/classic/arcade/quiz/QuizNightScreen.kt new file mode 100644 index 00000000..e9b4e5c3 --- /dev/null +++ b/android/app/src/main/java/tv/orbit/classic/arcade/quiz/QuizNightScreen.kt @@ -0,0 +1,254 @@ +package tv.orbit.classic.arcade.quiz + +import androidx.activity.compose.BackHandler +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.focus.onFocusChanged +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.tv.material3.Text +import tv.orbit.classic.Anton +import tv.orbit.classic.ArcadeBackdrop +import tv.orbit.classic.ArcadeBackdropLayer +import tv.orbit.classic.OrbCharacter +import tv.orbit.classic.OrbDir +import tv.orbit.classic.arcade.ArcadeButton +import tv.orbit.classic.arcade.ArcadeColours +import tv.orbit.classic.arcade.ArcadeGames +import tv.orbit.classic.arcade.ArcadePauseMenu +import tv.orbit.classic.arcade.ArcadePlay +import tv.orbit.classic.arcade.ClassicResult +import tv.orbit.classic.arcade.ClassicTitle +import tv.orbit.classic.arcade.Control +import tv.orbit.classic.arcade.HowToPlayCard +import tv.orbit.classic.arcade.KeyFooter +import tv.orbit.classic.arcade.Mascot +import tv.orbit.classic.arcade.RunEnd +import tv.orbit.classic.arcade.SpeechBubble +import tv.orbit.classic.arcade.onBackKey +import tv.orbit.classic.arcade.previousLine +import tv.orbit.classic.drawOrbChaser +import tv.orbit.classic.drawOrbMascot + +private enum class QuizStage { Title, Players, Question, Result } + +/** Each player's colour, from the cast (Ollie's orange, Zip's pink, Drift's cyan, Luna's lilac). */ +private val PlayerColours = listOf(Color(0xFFF7A928), OrbCharacter.Zip.colour, OrbCharacter.Drift.colour, OrbCharacter.Luna.colour) + +/** Who's playing, as the profile last set it up ("Adult,Kid"), kept to the levels this profile may use. */ +internal fun quizPlayersFrom(saved: String?, kids: Boolean): List { + val allowed = quizLevels(kids) + val levels = saved?.split(',')?.mapNotNull { n -> QuizLevel.entries.firstOrNull { it.name == n } }?.map { if (it in allowed) it else allowed.last() }.orEmpty() + return levels.take(QUIZ_MAX_PLAYERS).ifEmpty { listOf(allowed.last()) } +} + +@Composable +internal fun QuizNightScreen(play: ArcadePlay) { + val gameDef = ArcadeGames.QuizNight + val latestPlay by rememberUpdatedState(play) + var stage by remember { mutableStateOf(QuizStage.Title) } + var howTo by remember { mutableStateOf(false) } + var paused by remember { mutableStateOf(false) } + var mix by remember { mutableStateOf(QuizMix.entries.firstOrNull { it.name == play.level["mode"] } ?: QuizMix.Mixed) } + var levels by remember { mutableStateOf(quizPlayersFrom(play.level["quiz.players"], play.kids)) } + var game by remember { mutableStateOf(null) } + var tick by remember { mutableIntStateOf(0) } // the game is a plain object: this redraws it after each answer + var bestBefore by remember { mutableIntStateOf(play.best) } + val backdrop = ArcadeBackdrop.TestCardDusk + + fun start() { + latestPlay.setLevel("quiz.players", levels.joinToString(",") { it.name }) + bestBefore = latestPlay.best + game = QuizGame(levels.mapIndexed { i, l -> QuizPlayer("Player ${i + 1}", l) }, mix, System.nanoTime()) + paused = false; tick++; stage = QuizStage.Question + } + // A game on your own goes in the High Scores; a game for several is everyone's, so it keeps none. + fun finish(g: QuizGame) { + if (g.players.size == 1) latestPlay.onRunEnd(RunEnd(g.scores[0], finished = true, detail = "${g.rights[0]} of ${g.rounds} · ${g.players[0].level.title}")) + stage = QuizStage.Result + } + + when (stage) { + QuizStage.Title -> { + ClassicTitle(gameDef, backdrop, ArcadeColours.Pink, "Who's for a quiz?", listOf("Your best on your own" to if (play.best > 0) "%,d".format(play.best) else "Not played yet"), + timed = false, difficulty = play.difficulty, refocus = !howTo, onPlay = { stage = QuizStage.Players }, onHowTo = { howTo = true }, onBack = { latestPlay.onLeave() }, + mode = mix.title, modes = QuizMix.entries.size, onMode = { mix = QuizMix.entries[(mix.ordinal + 1) % QuizMix.entries.size]; latestPlay.setLevel("mode", mix.name) }, + playLabel = "Who's playing?", kicker = "AN ORBIT ARCADE ORIGINAL", timedLabel = "Up to 4 players", + note = "General knowledge, movies and TV. Everyone picks their own level, so a grown-up and a little one can play together fairly. No timer.") + if (howTo) HowToPlayCard(gameDef, firstRun = false, everyTime = null, onEveryTime = {}, onPlay = { howTo = false }, onBack = { howTo = false }) + } + QuizStage.Players -> QuizPlayers(levels, quizLevels(play.kids), backdrop, onChange = { levels = it }, onStart = ::start, onBack = { stage = QuizStage.Title }) + QuizStage.Question -> game?.let { g -> + tick // read, so each answer and each next question redraw + QuizAskScreen(g, backdrop, paused, onAnswer = { g.answer(it); tick++ }, onNext = { g.next(); tick++; if (g.over) finish(g) }, onPause = { paused = true }) + if (paused) ArcadePauseMenu(gameDef, "Quiz Night · Round ${g.round} of ${g.rounds}", onResume = { paused = false }, onRestart = ::start, onExit = { latestPlay.onLeave() }) + } + QuizStage.Result -> game?.let { g -> + Box(Modifier.fillMaxSize()) { + ArcadeBackdropLayer(backdrop) + if (g.players.size == 1) ClassicResult(gameDef, "QUIZ NIGHT · ${mix.title.uppercase()} · ${g.players[0].level.title.uppercase()}", "SCORE", "%,d".format(g.scores[0]), + newBest = g.scores[0] > bestBefore, previous = "${g.rights[0]} of ${g.rounds} right", detail = previousLine(gameDef.scoreKind, bestBefore, gameDef.title), + heading = quizHeading(g.rights[0], g.rounds), againLabel = "Play again", cheer = Mascot.Luna, onAgain = ::start, onBack = { latestPlay.onLeave() }) + else { + val w = g.winners() + ClassicResult(gameDef, "QUIZ NIGHT · ${g.players.size} PLAYERS · ${mix.title.uppercase()}", "SCORES", + g.players.indices.joinToString(" ") { "P${it + 1} ${g.scores[it]}" }, + newBest = false, previous = if (w.size == 1) "Player ${w[0] + 1} wins!" else "A draw: players ${w.joinToString(" and ") { "${it + 1}" }}!", + detail = "Everyone's game, so no High Scores", heading = "WELL PLAYED!", againLabel = "Play again", cheer = Mascot.Zip, + onAgain = ::start, onBack = { latestPlay.onLeave() }) + } + } + } + } +} + +/** The result's heading on your own, by how many were right. */ +internal fun quizHeading(right: Int, of: Int) = when { + right == of -> "FULL MARKS!" + right * 2 >= of -> "NICELY DONE!" + else -> "GOOD TRY!" +} + +// ---------- Who's playing ---------- + +@Composable +private fun QuizPlayers(levels: List, allowed: List, backdrop: ArcadeBackdrop, onChange: (List) -> Unit, onStart: () -> Unit, onBack: () -> Unit) { + val first = remember { FocusRequester() } + LaunchedEffect(Unit) { runCatching { first.requestFocus() } } + Box(Modifier.fillMaxSize().onBackKey(action = onBack)) { + BackHandler(onBack = onBack) + ArcadeBackdropLayer(backdrop) + Column(Modifier.fillMaxSize().padding(start = 48.dp, end = 48.dp, top = 28.dp, bottom = 12.dp)) { + Row(Modifier.fillMaxWidth().weight(1f), horizontalArrangement = Arrangement.spacedBy(32.dp)) { + Column(Modifier.width(380.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { + Text("QUIZ NIGHT", color = ArcadeColours.Muted, fontSize = 13.sp, letterSpacing = 4.sp) + Text("WHO'S PLAYING?", color = ArcadeColours.Ink, fontFamily = Anton, fontSize = 40.sp) + Text("OK on a player changes their level.", color = ArcadeColours.Muted, fontSize = 14.sp) + Spacer(Modifier.height(4.dp)) + levels.forEachIndexed { i, level -> + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) { + Canvas(Modifier.size(16.dp)) { drawCircle(PlayerColours[i]) } + ArcadeButton("Player ${i + 1}", Modifier.fillMaxWidth().then(if (i == 0) Modifier.focusRequester(first) else Modifier), detail = level.title, height = 34.dp, + onClick = { onChange(levels.toMutableList().also { it[i] = allowed[(allowed.indexOf(level) + 1) % allowed.size] }) }) + } + } + if (levels.size < QUIZ_MAX_PLAYERS) ArcadeButton("Add a player", Modifier.fillMaxWidth(), icon = "+", height = 34.dp, onClick = { onChange(levels + allowed.last()) }) + if (levels.size > 1) ArcadeButton("Take a player off", Modifier.fillMaxWidth(), icon = "−", height = 34.dp, onClick = { onChange(levels.dropLast(1)) }) + Spacer(Modifier.height(4.dp)) + ArcadeButton("Start the quiz", Modifier.fillMaxWidth(), icon = "▶", primary = true, height = 38.dp, onClick = onStart) + } + Column(Modifier.weight(1f).fillMaxHeight(), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center) { + SpeechBubble(if (levels.size == 1) "Just you? Let's see\nwhat you know!" else "Everyone gets questions\nat their own level!") + Canvas(Modifier.size(150.dp)) { drawOrbMascot(center, size.minDimension * .3f) } + Text(levels.groupBy { it }.entries.joinToString(" · ") { (l, ps) -> "${ps.size} ${l.title}" }, color = ArcadeColours.Muted, fontSize = 14.sp) + } + } + KeyFooter(listOf(Control("▲▼", "Choose"), Control("OK", "Change or select"), Control("Back", "Title"))) + } + } +} + +// ---------- A question ---------- + +@Composable +private fun QuizAskScreen(g: QuizGame, backdrop: ArcadeBackdrop, paused: Boolean, onAnswer: (Int) -> Unit, onNext: () -> Unit, onPause: () -> Unit) { + val ask = g.ask + val answered = g.answered + val firstAnswer = remember { FocusRequester() } + val nextButton = remember { FocusRequester() } + LaunchedEffect(ask, answered, paused) { if (!paused) runCatching { if (answered == null) firstAnswer.requestFocus() else nextButton.requestFocus() } } + // Nothing is ever held mid-question, so Back pauses (Paul's Back rule). + BackHandler(!paused, onBack = onPause) + Box(Modifier.fillMaxSize().onBackKey(enabled = !paused, action = onPause)) { + ArcadeBackdropLayer(backdrop) + Column(Modifier.fillMaxSize().padding(start = 32.dp, end = 32.dp, top = 22.dp, bottom = 10.dp)) { + Row(Modifier.fillMaxWidth().weight(1f), horizontalArrangement = Arrangement.spacedBy(20.dp)) { + // The scoreboard: everyone's score, whose turn it is. + Column(Modifier.width(170.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) { + Text("ROUND ${g.round} OF ${g.rounds}", color = ArcadeColours.Muted, fontSize = 16.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 2.sp) + g.players.forEachIndexed { i, p -> + Row(Modifier.fillMaxWidth().background(if (i == g.turn) ArcadeColours.Panel else Color.Transparent, RoundedCornerShape(8.dp)) + .border(if (i == g.turn) 2.dp else 0.dp, if (i == g.turn) PlayerColours[i] else Color.Transparent, RoundedCornerShape(8.dp)).padding(horizontal = 8.dp, vertical = 4.dp), + verticalAlignment = Alignment.CenterVertically) { + Column(Modifier.weight(1f)) { + Text(p.name, color = ArcadeColours.Ink, fontSize = 15.sp, fontWeight = FontWeight.SemiBold) + Text(p.level.title, color = ArcadeColours.Muted, fontSize = 12.sp) + } + Text("${g.scores[i]}", color = PlayerColours[i], fontFamily = Anton, fontSize = 22.sp) + } + } + } + Column(Modifier.weight(1f).fillMaxHeight(), verticalArrangement = Arrangement.spacedBy(10.dp)) { + val p = g.players[g.turn] + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { + Text("${p.name.uppercase()}'S QUESTION", color = PlayerColours[g.turn], fontSize = 15.sp, fontWeight = FontWeight.Bold, letterSpacing = 2.sp) + Text("${ask.question.category.title} · ${p.level.title}", Modifier.background(ArcadeColours.Panel, RoundedCornerShape(10.dp)).padding(horizontal = 8.dp, vertical = 2.dp), + color = ArcadeColours.Muted, fontSize = 12.sp) + } + Text(ask.question.text, Modifier.fillMaxWidth().background(ArcadeColours.PanelDeep.copy(alpha = .92f), RoundedCornerShape(12.dp)) + .border(1.dp, ArcadeColours.Line, RoundedCornerShape(12.dp)).padding(18.dp), color = ArcadeColours.Ink, fontSize = 24.sp, fontWeight = FontWeight.SemiBold, lineHeight = 30.sp) + // The four answers, two by two: ◀▶▲▼ to choose, OK to answer. + val shown = ask.shown + for (row in 0..1) Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) { + for (col in 0..1) { + val at = row * 2 + col + AnswerButton("ABCD"[at], shown[at], Modifier.weight(1f).then(if (at == 0) Modifier.focusRequester(firstAnswer) else Modifier), + state = when { answered == null -> AnswerState.Open; at == ask.rightAt -> AnswerState.Right; at == answered -> AnswerState.Wrong; else -> AnswerState.Spent }, + onClick = { if (answered == null) onAnswer(at) }) + } + } + if (answered != null) Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp)) { + val last = g.turn == g.players.size - 1 && g.round == g.rounds + ArcadeButton(if (last) "See the scores" else "Next: ${g.players[(g.turn + 1) % g.players.size].name}", Modifier.width(240.dp).focusRequester(nextButton), + icon = "▶", primary = true, height = 36.dp, onClick = onNext) + if (g.players.size > 1 && !last) Text("Pass the remote!", color = ArcadeColours.Muted, fontSize = 14.sp) + } + } + // Ollie hosts (the only one of the cast with a mouth); a friend from the cast cheers a right answer. + Column(Modifier.width(150.dp).fillMaxHeight(), horizontalAlignment = Alignment.CenterHorizontally) { + Spacer(Modifier.weight(1f)) + val right = answered != null && answered == ask.rightAt + SpeechBubble(when { + answered == null -> if (g.players.size > 1) "Over to you,\n${g.players[g.turn].name}!" else "Take your time!" + right -> "Spot on!" + else -> "Not quite:\nit's ${ask.question.right}." + }) + Canvas(Modifier.size(100.dp)) { drawOrbMascot(center, size.minDimension * .32f) } + if (right) Canvas(Modifier.size(60.dp)) { drawOrbChaser(center, size.minDimension * .36f, OrbCharacter.Zip, OrbDir.Down, false, false, false, 0f) } + } + } + KeyFooter(if (answered == null) listOf(Control("◀▶▲▼", "Choose an answer"), Control("OK", "Answer"), Control("Back", "Pause")) + else listOf(Control("OK", "Next"), Control("Back", "Pause"))) + } + } +} + +private enum class AnswerState { Open, Right, Wrong, Spent } + +/** An answer: A to D and its words; after OK, the right one turns green and a wrong pick red. */ +@Composable +private fun AnswerButton(letter: Char, text: String, modifier: Modifier, state: AnswerState, onClick: () -> Unit) { + var focused by remember { mutableStateOf(false) } + val corner = RoundedCornerShape(10.dp) + val fill = when (state) { AnswerState.Right -> Color(0xFF1E5E46); AnswerState.Wrong -> ArcadeColours.DangerFill; else -> if (focused) ArcadeColours.FocusFill else ArcadeColours.Panel } + val edge = when { state == AnswerState.Right -> ArcadeColours.Green; state == AnswerState.Wrong -> ArcadeColours.Red; focused -> ArcadeColours.Yellow; else -> ArcadeColours.Line } + Row(modifier.heightIn(min = 54.dp).onFocusChanged { focused = it.isFocused }.background(fill, corner).border(if (focused || state == AnswerState.Right || state == AnswerState.Wrong) 3.dp else 1.dp, edge, corner) + .clickable(enabled = state == AnswerState.Open, onClick = onClick).padding(horizontal = 14.dp, vertical = 8.dp), verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(12.dp)) { + Text("$letter", color = ArcadeColours.Yellow, fontFamily = Anton, fontSize = 22.sp) + Text(text, Modifier.weight(1f), color = if (state == AnswerState.Spent) ArcadeColours.Muted else ArcadeColours.Ink, fontSize = 18.sp, fontWeight = FontWeight.SemiBold, textAlign = TextAlign.Start) + when (state) { AnswerState.Right -> Text("✓", color = ArcadeColours.Green, fontSize = 22.sp, fontWeight = FontWeight.Bold); AnswerState.Wrong -> Text("✗", color = ArcadeColours.Red, fontSize = 22.sp, fontWeight = FontWeight.Bold); else -> {} } + } +} diff --git a/android/app/src/main/java/tv/orbit/classic/arcade/quiz/QuizQuestions.kt b/android/app/src/main/java/tv/orbit/classic/arcade/quiz/QuizQuestions.kt new file mode 100644 index 00000000..fd37b79b --- /dev/null +++ b/android/app/src/main/java/tv/orbit/classic/arcade/quiz/QuizQuestions.kt @@ -0,0 +1,200 @@ +package tv.orbit.classic.arcade.quiz + +/** + * Quiz Night's questions (9 November 2026), written for Orbit and kept on the box: no network, nothing to fetch. Three + * levels, so a grown-up and a child can play together each at their own: Kid (about 5 to 8), Older kid (about 9 to 13) and + * Adult. A Kids profile only ever sees Kid and Older kid questions. Each question's first answer is the right one; the + * game shuffles them. + */ +internal enum class QuizLevel(val title: String) { Kid("Kid"), OlderKid("Older kid"), Adult("Adult") } + +internal enum class QuizCategory(val title: String) { General("General knowledge"), Movies("Movies"), Tv("TV") } + +internal class QuizQuestion(val id: Int, val level: QuizLevel, val category: QuizCategory, val text: String, val answers: List) { + val right get() = answers[0] +} + +private class QuizBank { + val all = ArrayList() + private fun add(level: QuizLevel, cat: QuizCategory, text: String, vararg answers: String) { all += QuizQuestion(all.size, level, cat, text, answers.toList()) } + + init { + val k = QuizLevel.Kid; val o = QuizLevel.OlderKid; val a = QuizLevel.Adult + val g = QuizCategory.General; val m = QuizCategory.Movies; val t = QuizCategory.Tv + + // ---------- Kid: general knowledge ---------- + add(k, g, "How many legs does a spider have?", "8", "6", "10", "4") + add(k, g, "What colour do you get by mixing blue and yellow?", "Green", "Purple", "Orange", "Brown") + add(k, g, "Which planet do we live on?", "Earth", "Mars", "Venus", "Jupiter") + add(k, g, "How many days are there in a week?", "7", "5", "6", "10") + add(k, g, "What do bees make?", "Honey", "Milk", "Jam", "Bread") + add(k, g, "Which animal is called the king of the jungle?", "Lion", "Elephant", "Tiger", "Giraffe") + add(k, g, "What is frozen water called?", "Ice", "Steam", "Rain", "Fog") + add(k, g, "How many sides does a triangle have?", "3", "4", "5", "6") + add(k, g, "Which is the biggest planet in our solar system?", "Jupiter", "Earth", "Mars", "Mercury") + add(k, g, "What do caterpillars turn into?", "Butterflies", "Bees", "Birds", "Frogs") + add(k, g, "What is the opposite of hot?", "Cold", "Warm", "Wet", "Big") + add(k, g, "Which season comes after winter?", "Spring", "Summer", "Autumn", "Bedtime") + add(k, g, "How many minutes are there in an hour?", "60", "100", "30", "24") + add(k, g, "Which animal says moo?", "A cow", "A sheep", "A duck", "A pig") + add(k, g, "How many wheels does a bicycle have?", "2", "3", "4", "1") + add(k, g, "What do you call a baby cat?", "A kitten", "A puppy", "A calf", "A cub") + add(k, g, "Which is the largest ocean on Earth?", "The Pacific", "The Atlantic", "The Indian", "The Arctic") + add(k, g, "Which fruit is long, yellow and curved?", "A banana", "An apple", "A grape", "A strawberry") + add(k, g, "What colour is the sky on a clear sunny day?", "Blue", "Green", "Red", "Purple") + add(k, g, "How many months are there in a year?", "12", "10", "7", "52") + + // ---------- Kid: movies ---------- + add(k, m, "In Frozen, what is the snowman called?", "Olaf", "Sven", "Kristoff", "Hans") + add(k, m, "What kind of fish is Nemo?", "A clownfish", "A shark", "A goldfish", "A pufferfish") + add(k, m, "In Toy Story, what is the cowboy's name?", "Woody", "Buzz", "Rex", "Hamm") + add(k, m, "In The Lion King, who is Simba's dad?", "Mufasa", "Scar", "Rafiki", "Timon") + add(k, m, "What colour is Shrek?", "Green", "Blue", "Red", "Yellow") + add(k, m, "Who says \"To infinity and beyond!\"?", "Buzz Lightyear", "Woody", "Olaf", "Dory") + add(k, m, "Which films have little yellow Minions in them?", "Despicable Me", "Frozen", "Cars", "Up") + add(k, m, "In Cars, what is the red racing car called?", "Lightning McQueen", "Mater", "Doc Hudson", "Sally") + add(k, m, "In Up, what lifts the house into the sky?", "Balloons", "A rocket", "A helicopter", "Kites") + add(k, m, "In Frozen, what is Kristoff's reindeer called?", "Sven", "Olaf", "Rudolph", "Dasher") + add(k, m, "In Moana, what is the name of the demigod?", "Maui", "Hei Hei", "Pua", "Tala") + add(k, m, "In Finding Nemo, which forgetful fish helps Marlin?", "Dory", "Bruce", "Gill", "Crush") + add(k, m, "What kind of animal is Paddington?", "A bear", "A dog", "A rabbit", "A fox") + add(k, m, "What does Paddington love to eat?", "Marmalade sandwiches", "Pizza", "Fish fingers", "Cheese") + add(k, m, "In Zootropolis, what kind of animal is Judy Hopps?", "A rabbit", "A fox", "A sloth", "A lion") + + // ---------- Kid: TV ---------- + add(k, t, "Which dog has a little sister called Bingo?", "Bluey", "Bandit", "Chilli", "Muffin") + add(k, t, "What is Peppa Pig's little brother called?", "George", "Richard", "Pedro", "Danny") + add(k, t, "SpongeBob lives in what, under the sea?", "A pineapple", "A rock", "A shell", "A castle") + add(k, t, "Which Teletubby is purple?", "Tinky Winky", "Dipsy", "Laa-Laa", "Po") + add(k, t, "In PAW Patrol, who is the boy who leads the pups?", "Ryder", "Chase", "Marshall", "Rubble") + add(k, t, "Which bear is friends with Piglet and Eeyore?", "Winnie the Pooh", "Paddington", "Baloo", "Yogi") + add(k, t, "What colour is Pikachu?", "Yellow", "Blue", "Red", "Green") + add(k, t, "What colour are the Smurfs?", "Blue", "Green", "Purple", "Red") + add(k, t, "What is Thomas in Thomas & Friends?", "A tank engine", "A bus", "A tractor", "A boat") + add(k, t, "Bitzer the sheepdog is in which show?", "Shaun the Sheep", "Bluey", "Peppa Pig", "Hey Duggee") + add(k, t, "In Hey Duggee, what kind of animal is Duggee?", "A dog", "A cat", "A bear", "A rabbit") + add(k, t, "What kind of animal is Scooby-Doo?", "A dog", "A cat", "A horse", "A mouse") + add(k, t, "Who works at the Krusty Krab?", "SpongeBob", "Peppa Pig", "Bluey", "Paddington") + add(k, t, "In Tom and Jerry, which one is the mouse?", "Jerry", "Tom", "Spike", "Butch") + add(k, t, "What colour is Postman Pat's cat, Jess?", "Black and white", "Ginger", "Grey", "All white") + + // ---------- Older kid: general knowledge ---------- + add(o, g, "What is the capital of France?", "Paris", "Lyon", "Marseille", "Nice") + add(o, g, "How many continents are there?", "7", "5", "6", "8") + add(o, g, "What is H2O better known as?", "Water", "Salt", "Sugar", "Air") + add(o, g, "Which planet is known as the Red Planet?", "Mars", "Venus", "Jupiter", "Mercury") + add(o, g, "What is the largest animal that has ever lived?", "The blue whale", "The elephant", "The T. rex", "The giraffe") + add(o, g, "How many players does a football team have on the pitch?", "11", "10", "9", "12") + add(o, g, "What is 9 times 9?", "81", "72", "99", "18") + add(o, g, "Who painted the Mona Lisa?", "Leonardo da Vinci", "Michelangelo", "Vincent van Gogh", "Pablo Picasso") + add(o, g, "At what temperature does water boil, at sea level?", "100°C", "90°C", "50°C", "212°C") + add(o, g, "What is the longest river in the UK?", "The Severn", "The Thames", "The Trent", "The Tyne") + add(o, g, "What is the capital of Scotland?", "Edinburgh", "Glasgow", "Aberdeen", "Dundee") + add(o, g, "How many bones does an adult human have?", "206", "106", "306", "186") + add(o, g, "Which gas do plants take in to make their food?", "Carbon dioxide", "Oxygen", "Nitrogen", "Helium") + add(o, g, "Which instrument usually has 88 keys?", "The piano", "The guitar", "The violin", "The trumpet") + add(o, g, "What is the fastest land animal?", "The cheetah", "The lion", "The horse", "The greyhound") + + // ---------- Older kid: movies ---------- + add(o, m, "Who is Harry Potter's red-haired best friend?", "Ron Weasley", "Neville Longbottom", "Draco Malfoy", "Cedric Diggory") + add(o, m, "In Star Wars, who is Luke Skywalker's father?", "Darth Vader", "Obi-Wan Kenobi", "Han Solo", "Yoda") + add(o, m, "Which superhero is Peter Parker?", "Spider-Man", "Batman", "Iron Man", "Superman") + add(o, m, "Tony Stark is which superhero?", "Iron Man", "Captain America", "Thor", "The Hulk") + add(o, m, "What is the school in Harry Potter called?", "Hogwarts", "Durmstrang", "Beauxbatons", "Brakebills") + add(o, m, "In The Wizard of Oz, what colour is the road Dorothy follows?", "Yellow", "Red", "Green", "Blue") + add(o, m, "Which film is about a giant shark at Amity Island?", "Jaws", "The Meg", "Deep Blue Sea", "Orca") + add(o, m, "In Back to the Future, which car is the time machine?", "A DeLorean", "A Mustang", "A Beetle", "A Mini") + add(o, m, "In Frozen, which sister has ice powers?", "Elsa", "Anna", "Rapunzel", "Moana") + add(o, m, "What is Batman's real name?", "Bruce Wayne", "Clark Kent", "Tony Stark", "Peter Parker") + add(o, m, "In Jurassic Park, the dinosaurs are brought back from what?", "DNA", "Fossilised eggs", "A time machine", "A volcano") + add(o, m, "Which wizard has a scar shaped like a lightning bolt?", "Harry Potter", "Gandalf", "Merlin", "Dumbledore") + + // ---------- Older kid: TV ---------- + add(o, t, "In Doctor Who, what does the TARDIS look like on the outside?", "A police box", "A phone box", "A post box", "A caravan") + add(o, t, "Which cartoon family lives in Springfield and has a son called Bart?", "The Simpsons", "The Griffins", "The Flintstones", "The Belchers") + add(o, t, "What was Ash's first Pokémon?", "Pikachu", "Charmander", "Bulbasaur", "Squirtle") + add(o, t, "In Doctor Who, what are the Doctor's people called?", "Time Lords", "Daleks", "Cybermen", "Sontarans") + add(o, t, "In Dragon Ball Z, Goku belongs to which race?", "Saiyan", "Namekian", "Human", "Android") + add(o, t, "In Avatar: The Last Airbender, Aang is the last of which people?", "The Air Nomads", "The Water Tribe", "The Fire Nation", "The Earth Kingdom") + add(o, t, "In SpongeBob SquarePants, what is Patrick?", "A starfish", "A crab", "A squid", "A sponge") + add(o, t, "Which Pokémon evolves into Raichu?", "Pikachu", "Charmander", "Eevee", "Jigglypuff") + add(o, t, "Who lives at 742 Evergreen Terrace?", "The Simpsons", "The Griffins", "The Flintstones", "The Belchers") + add(o, t, "In Scooby-Doo, what is the gang's van called?", "The Mystery Machine", "The Ghost Bus", "The Clue Cruiser", "The Scooby Van") + add(o, t, "In Doctor Who, which robots shout \"Exterminate!\"?", "The Daleks", "The Cybermen", "The Ood", "The Silence") + add(o, t, "Which pup in PAW Patrol is a fire dog?", "Marshall", "Chase", "Skye", "Rocky") + + // ---------- Adult: general knowledge ---------- + add(a, g, "What is the capital of Australia?", "Canberra", "Sydney", "Melbourne", "Perth") + add(a, g, "In which year did the Titanic sink?", "1912", "1905", "1921", "1898") + add(a, g, "What is the chemical symbol for gold?", "Au", "Ag", "Gd", "Go") + add(a, g, "Who wrote Pride and Prejudice?", "Jane Austen", "Charlotte Brontë", "Charles Dickens", "George Eliot") + add(a, g, "How many hearts does an octopus have?", "3", "1", "2", "8") + add(a, g, "Which element has the atomic number 1?", "Hydrogen", "Helium", "Oxygen", "Carbon") + add(a, g, "What is the smallest country in the world?", "Vatican City", "Monaco", "San Marino", "Liechtenstein") + add(a, g, "In which city is the Brandenburg Gate?", "Berlin", "Munich", "Vienna", "Hamburg") + add(a, g, "In which year did the Berlin Wall fall?", "1989", "1991", "1985", "1979") + add(a, g, "Who was the first person to walk on the Moon?", "Neil Armstrong", "Buzz Aldrin", "Yuri Gagarin", "John Glenn") + add(a, g, "Which South American country has the most people?", "Brazil", "Argentina", "Colombia", "Peru") + add(a, g, "How many pints are there in a UK gallon?", "8", "4", "6", "10") + add(a, g, "Who painted The Starry Night?", "Vincent van Gogh", "Claude Monet", "Salvador Dalí", "Rembrandt") + add(a, g, "What is the currency of Japan?", "The yen", "The won", "The yuan", "The ringgit") + add(a, g, "Which organ makes insulin?", "The pancreas", "The liver", "The kidneys", "The spleen") + add(a, g, "In which country is Machu Picchu?", "Peru", "Mexico", "Chile", "Bolivia") + add(a, g, "Which Shakespeare play has the line \"To be, or not to be\"?", "Hamlet", "Macbeth", "Othello", "King Lear") + add(a, g, "How many players are in a rugby union team on the pitch?", "15", "13", "11", "12") + add(a, g, "Who composed the Moonlight Sonata?", "Beethoven", "Mozart", "Bach", "Chopin") + add(a, g, "What is the highest mountain in the UK?", "Ben Nevis", "Snowdon", "Scafell Pike", "Slieve Donard") + add(a, g, "What is the capital of Canada?", "Ottawa", "Toronto", "Vancouver", "Montreal") + add(a, g, "In which year did Yuri Gagarin become the first person in space?", "1961", "1957", "1969", "1965") + add(a, g, "What does the D in DNA stand for?", "Deoxyribo-", "Di-", "Dynamic", "Dual") + add(a, g, "Roughly how fast does light travel?", "300,000 km a second", "30,000 km a second", "3,000 km a second", "3 million km a second") + add(a, g, "Which planet is closest to the Sun?", "Mercury", "Venus", "Mars", "Earth") + + // ---------- Adult: movies ---------- + add(a, m, "Who directed Jaws?", "Steven Spielberg", "George Lucas", "Martin Scorsese", "Ridley Scott") + add(a, m, "Which 1997 film starred Leonardo DiCaprio and Kate Winslet?", "Titanic", "The Beach", "Inception", "The Aviator") + add(a, m, "In The Matrix, which pill does Neo take?", "The red one", "The blue one", "The green one", "The white one") + add(a, m, "Who played the Joker in The Dark Knight?", "Heath Ledger", "Jack Nicholson", "Joaquin Phoenix", "Jared Leto") + add(a, m, "Which hobbit did Elijah Wood play?", "Frodo Baggins", "Samwise Gamgee", "Bilbo Baggins", "Pippin") + add(a, m, "Which film has the line \"Here's looking at you, kid\"?", "Casablanca", "Gone with the Wind", "Citizen Kane", "The Maltese Falcon") + add(a, m, "In which film does Tom Hanks talk to a volleyball called Wilson?", "Cast Away", "Big", "Forrest Gump", "The Terminal") + add(a, m, "Who played James Bond in Casino Royale (2006)?", "Daniel Craig", "Pierce Brosnan", "Sean Connery", "Roger Moore") + add(a, m, "What is the ship called in Alien (1979)?", "The Nostromo", "The Sulaco", "The Prometheus", "The Covenant") + add(a, m, "In Back to the Future, what speed must the DeLorean hit?", "88 mph", "100 mph", "77 mph", "66 mph") + add(a, m, "Who played Ellen Ripley in Alien?", "Sigourney Weaver", "Jamie Lee Curtis", "Linda Hamilton", "Carrie Fisher") + add(a, m, "Which Pixar film takes place mostly inside a girl's mind?", "Inside Out", "Soul", "Coco", "Up") + add(a, m, "Which film is set at the Overlook Hotel?", "The Shining", "Psycho", "Misery", "Carrie") + add(a, m, "Who directed Inception?", "Christopher Nolan", "Denis Villeneuve", "Ridley Scott", "James Cameron") + add(a, m, "Who played Dr Alan Grant in Jurassic Park?", "Sam Neill", "Jeff Goldblum", "Richard Attenborough", "Bob Peck") + add(a, m, "In which film is the computer HAL 9000?", "2001: A Space Odyssey", "Blade Runner", "Alien", "The Terminator") + add(a, m, "In The Godfather, what is the family's surname?", "Corleone", "Soprano", "Gambino", "Tattaglia") + add(a, m, "In which year was the first Star Wars film released?", "1977", "1980", "1975", "1983") + add(a, m, "Which Studio Ghibli film has a Catbus in it?", "My Neighbour Totoro", "Spirited Away", "Ponyo", "Howl's Moving Castle") + add(a, m, "Which Disney film was the first full-length animated feature?", "Snow White and the Seven Dwarfs", "Pinocchio", "Bambi", "Fantasia") + + // ---------- Adult: TV ---------- + add(a, t, "In Breaking Bad, what is Walter White's alias?", "Heisenberg", "Pinkman", "Goodman", "Fring") + add(a, t, "Which sitcom is set around a coffee shop called Central Perk?", "Friends", "Seinfeld", "Frasier", "Cheers") + add(a, t, "What is the pub in EastEnders called?", "The Queen Vic", "The Rovers Return", "The Woolpack", "The Bull") + add(a, t, "The Rovers Return is the pub in which soap?", "Coronation Street", "EastEnders", "Emmerdale", "Hollyoaks") + add(a, t, "In Only Fools and Horses, what is Del Boy's surname?", "Trotter", "Boyce", "Partridge", "Steptoe") + add(a, t, "Which series follows the Shelby family in Birmingham?", "Peaky Blinders", "The Crown", "Line of Duty", "Gangs of London") + add(a, t, "In Game of Thrones, what is Jon Snow's direwolf called?", "Ghost", "Nymeria", "Summer", "Grey Wind") + add(a, t, "Which show has a place called the Upside Down?", "Stranger Things", "Dark", "Lost", "The OA") + add(a, t, "Who played the Tenth Doctor in Doctor Who?", "David Tennant", "Matt Smith", "Peter Capaldi", "Christopher Eccleston") + add(a, t, "Which TV detective lives at 221B Baker Street?", "Sherlock Holmes", "Hercule Poirot", "Inspector Morse", "Columbo") + add(a, t, "In The X-Files, what are the two agents' surnames?", "Mulder and Scully", "Starsky and Hutch", "Cagney and Lacey", "Crockett and Tubbs") + add(a, t, "In Fawlty Towers, what is the Spanish waiter called?", "Manuel", "Pedro", "Juan", "Carlos") + add(a, t, "Which show is set at Dunder Mifflin's Scranton branch?", "The Office (US)", "Parks and Recreation", "Brooklyn Nine-Nine", "30 Rock") + add(a, t, "In Red Dwarf, what is the ship's computer called?", "Holly", "HAL", "Kryten", "Rimmer") + add(a, t, "In Blackadder, what is Baldrick known for?", "His cunning plans", "His singing", "His cooking", "His sword fighting") + add(a, t, "In The Simpsons, what is the bar called?", "Moe's", "Barney's", "Duff's", "Lenny's") + add(a, t, "Who presented Top Gear alongside Richard Hammond and James May?", "Jeremy Clarkson", "Chris Evans", "Matt LeBlanc", "Paddy McGuinness") + add(a, t, "In Line of Duty, what is the anti-corruption unit called?", "AC-12", "CID", "MI5", "The Flying Squad") + add(a, t, "In Dragon Ball Z, what is Goku's Saiyan name?", "Kakarot", "Vegeta", "Raditz", "Bardock") + add(a, t, "What is the name of the family in Downton Abbey?", "The Crawleys", "The Bellamys", "The Bridgertons", "The Marchmains") + } +} + +/** Every question on the box, made once. */ +internal val QuizQuestions: List by lazy { QuizBank().all } diff --git a/android/app/src/test/java/tv/orbit/classic/arcade/KidsArcadeTest.kt b/android/app/src/test/java/tv/orbit/classic/arcade/KidsArcadeTest.kt index 6329670c..fc639672 100644 --- a/android/app/src/test/java/tv/orbit/classic/arcade/KidsArcadeTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/arcade/KidsArcadeTest.kt @@ -16,7 +16,7 @@ class KidsArcadeTest { @Test fun grownUpsSeeEveryGame() { assertEquals(ArcadeGames.all.map { it.id }, ids(grown)) - assertEquals(13, ids(grown).size) + assertEquals(14, 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: 11 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.KidsSuitable))) + assertEquals("Kids-suitable games: 12 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(5, ArcadeGames.originals.size); assertEquals(8, ArcadeGames.classics.size) + assertEquals(6, 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"), ArcadeGames.originals.filter { it.launchable }.map { it.id }) + assertEquals(listOf("OrbiRaiders", "ChannelChaos", "Hive", "NightShift", "Orbiteroids", "QuizNight"), 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()) diff --git a/android/app/src/test/java/tv/orbit/classic/arcade/TitleTextFitsTest.kt b/android/app/src/test/java/tv/orbit/classic/arcade/TitleTextFitsTest.kt index a2857079..f5a699d2 100644 --- a/android/app/src/test/java/tv/orbit/classic/arcade/TitleTextFitsTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/arcade/TitleTextFitsTest.kt @@ -164,4 +164,19 @@ class TitleTextFitsTest { val column = 960.0 - 2 * 52 - 2 * 24 - 76 - 2 * 28 - 110 for (g in ArcadeGames.all) assertTrue(g.title, width(anton, "HOW TO PLAY ${g.title.uppercase()}") <= column) } + + @Test fun quizNightsWordsFit() { + // Each answer button is half the answers' column (960 less the side padding, the 170 dp scoreboard, Ollie's 150 and + // the gaps), less its padding and letter: every answer fits in two lines at the largest font scale. + val answer = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(18f * 1.3f) + val room = ((960.0 - 64 - 170 - 150 - 40) - 10) / 2 - 28 - 24 - 12 + for (q in tv.orbit.classic.arcade.quiz.QuizQuestions) for (a in q.answers) assertTrue("$a", width(answer, a) <= room * 2) + // Every question fits its panel in at most three lines. + val question = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(24f * 1.3f) + val panel = (960.0 - 64 - 170 - 150 - 40) - 36 + for (q in tv.orbit.classic.arcade.quiz.QuizQuestions) assertTrue(q.text, width(question, q.text) <= panel * 3) + val sans = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f) + for (mode in tv.orbit.classic.arcade.quiz.QuizMix.entries) assertTrue(mode.title, width(sans, "◆ ${mode.title}") <= 230 - 2 * 12 - 4) + assertTrue(width(sans, "▶ Who's playing?") <= 230 - 2 * 12 - 4) + } } diff --git a/android/app/src/test/java/tv/orbit/classic/arcade/quiz/QuizNightTest.kt b/android/app/src/test/java/tv/orbit/classic/arcade/quiz/QuizNightTest.kt new file mode 100644 index 00000000..1da8170a --- /dev/null +++ b/android/app/src/test/java/tv/orbit/classic/arcade/quiz/QuizNightTest.kt @@ -0,0 +1,61 @@ +package tv.orbit.classic.arcade.quiz + +import org.junit.Assert.* +import org.junit.Test + +class QuizNightTest { + @Test fun theQuestionsAreWellFormedAndEveryLevelHasEnough() { + val qs = QuizQuestions + assertEquals(qs.size, qs.map { it.text }.toSet().size) // no question twice + for (q in qs) { + assertEquals(q.text, 4, q.answers.size) + assertEquals(q.text, 4, q.answers.toSet().size) // four different answers + assertTrue(q.text, q.text.endsWith("?")) + } + // Enough of every level in every category for a full game of four (five rounds, one at each level), mixed. + for (level in QuizLevel.entries) { + for (cat in QuizCategory.entries) assertTrue("$level $cat", qs.count { it.level == level && it.category == cat } >= 12) + assertTrue("$level mixed", quizPool(level, QuizMix.Mixed).size >= QUIZ_ROUNDS * QUIZ_MAX_PLAYERS) + } + } + + @Test fun aKidsProfileNeverSeesAdultQuestions() { + assertEquals(listOf(QuizLevel.Kid, QuizLevel.OlderKid), quizLevels(kids = true)) + assertEquals(QuizLevel.entries, quizLevels(kids = false)) + // A saved Adult player on a Kids profile becomes an Older kid. + assertEquals(listOf(QuizLevel.OlderKid, QuizLevel.Kid), quizPlayersFrom("Adult,Kid", kids = true)) + assertEquals(listOf(QuizLevel.Adult), quizPlayersFrom(null, kids = false)) + } + + @Test fun playersTakeTurnsEachAtTheirOwnLevelWithNoRepeats() { + val g = QuizGame(listOf(QuizPlayer("Player 1", QuizLevel.Adult), QuizPlayer("Player 2", QuizLevel.Kid)), QuizMix.Mixed, seed = 3) + assertEquals(QUIZ_ROUNDS, g.rounds) + val asked = ArrayList() + var answers = 0 + while (!g.over) { + val who = g.players[g.turn] + assertEquals(who.level, g.ask.question.level) + asked += g.ask.question + // Player 1 always right, player 2 always wrong. + g.answer(if (g.turn == 0) g.ask.rightAt else (g.ask.rightAt + 1) % 4) + assertFalse(g.answer(g.ask.rightAt)) // a second OK does nothing + g.next(); answers++ + } + assertEquals(10, answers); assertEquals(asked.size, asked.toSet().size) + assertEquals(QUIZ_ROUNDS * QUIZ_POINTS, g.scores[0]); assertEquals(0, g.scores[1]); assertEquals(listOf(0), g.winners()) + } + + @Test fun theAnswersAreShuffledButTheRightOneIsKnown() { + val g = QuizGame(listOf(QuizPlayer("Player 1", QuizLevel.OlderKid)), QuizMix.Movies, seed = 9) + assertEquals(g.ask.question.right, g.ask.shown[g.ask.rightAt]) + assertEquals(g.ask.question.answers.toSet(), g.ask.shown.toSet()) + assertTrue(g.answer(g.ask.rightAt)); assertEquals(QUIZ_POINTS, g.scores[0]) + } + + @Test fun aSmallCategoryShortensTheGameRatherThanRepeating() { + val four = List(4) { QuizPlayer("Player ${it + 1}", QuizLevel.Kid) } + val g = QuizGame(four, QuizMix.Tv, seed = 1) + assertTrue(g.rounds * 4 <= quizPool(QuizLevel.Kid, QuizMix.Tv).size) + assertEquals("FULL MARKS!", quizHeading(5, 5)); assertEquals("GOOD TRY!", quizHeading(1, 5)) + } +} diff --git a/docs/quiz-night.md b/docs/quiz-night.md new file mode 100644 index 00000000..4280b9f8 --- /dev/null +++ b/docs/quiz-night.md @@ -0,0 +1,60 @@ +# Quiz Night (0.117.0, versionCode 308, 9 November 2026) + +Branch `classics-modes`, on top of 0.116.1. The first of the four new Originals Paul approved: "general knowledge, +movies, tv shows, things like that and user can set like play 1 adult, player 2 kid or varying levels of difficulty". +Not installed; nothing seen running. + +## The game + +- **1 to 4 players** share the remote. **Each player picks their own level:** Kid (about 5 to 8), Older kid (about 9 to + 13) or Adult. A Kids profile only offers Kid and Older kid; a saved Adult player becomes an Older kid there. +- **Five rounds**: each round, every player answers one question at their level, in turn. If a category is too small for + everyone, the game is shortened rather than repeating a question. +- **The Mode button** picks the questions: Mixed, General knowledge, Movies or TV. +- **Answers:** four, two by two. ◀▶▲▼ choose and OK answers. The right one turns green with a tick, a wrong pick red + with a cross. Ollie (the only one of the cast with a mouth) says "Spot on!" or "Not quite: it's …", and Zip cheers a + right answer. +- **Pace:** nothing moves on until OK on "Next: Player 2" ("Pass the remote!"). No timer. +- **Back:** nothing is ever held, so Back pauses (shared pause menu). On "Who's playing?" Back goes to the title. +- **Scores:** 100 a right answer. + - On your own, the score goes in your High Scores, with how many were right and the level. + - With several players it's everyone's game, so it keeps none, as with Pairs Family Play. The result shows every + player's score and the winner, or a draw. +- **Who's playing** is remembered per profile, with each player's level. + +## The questions + +`arcade/quiz/QuizQuestions.kt`: 152, written for Orbit and kept on the box (no network). + +| | Kid | Older kid | Adult | +|---|---|---|---| +| General knowledge | 20 | 15 | 25 | +| Movies | 15 | 12 | 20 | +| TV | 15 | 12 | 20 | + +- Family-friendly at Kid and Older kid. Adult has grown-up shows (Breaking Bad, Line of Duty) but no grown-up content. +- UK names where they differ (Zootropolis, My Neighbour Totoro). +- A few nods to Orbit's own channels (Dragon Ball Z, Doctor Who, The X-Files). +- **Adding questions** is one line each; the tests check every addition. + +## The Arcade home + +Quiz Night is the sixth Original, so the Originals row now scrolls sideways when there are more than five: the cards keep +their size, and the remote's focus brings the next into view. + +## Checks + +- **`QuizNightTest`:** + - No question twice, four different answers each. + - At least 12 per level and category, and enough for four players at one level. + - Kids profiles never get Adult questions. + - Turns go round each at their own level with no repeats; scoring, winners and the shuffled answers. + - A small category shortens the game. +- **Fit checks:** every answer fits its button in two lines, every question its panel in three, at the largest font scale + (720p and 1080p alike). +- **Kids test:** 12 Kids-suitable games, 6 Originals. +- **Unit tests:** 1,062 run, 24 skipped, 0 failed. +- **Lint:** 0 errors, 87 warnings (none new). +- **Release APK:** 48,203,359 bytes (+32,772 on 0.116.1). +- **Light on the 2 GB box:** the questions are a few kilobytes of text made once, there are no pictures, and nothing runs + frame by frame.