From d375aae62155d2baa648957cae475347a5e4d32c Mon Sep 17 00:00:00 2001 From: Pauljd Date: Mon, 9 Nov 2026 10:22:07 +0000 Subject: [PATCH] Night Shift power-ups as the power-up sheet has them: Moonbeam shows the route, Sleepy Time naps the clouds for 6 hops, Star Magnet pulls the light on, Night Vision shows wrong pieces Co-Authored-By: Claude Opus 5.5 --- .../classic/arcade/nightshift/NightShift.kt | 21 +++++++++---------- .../arcade/nightshift/NightShiftScreen.kt | 20 +++++++++++------- .../arcade/nightshift/NightShiftLevelsTest.kt | 8 +++---- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/android/app/src/main/java/tv/orbit/classic/arcade/nightshift/NightShift.kt b/android/app/src/main/java/tv/orbit/classic/arcade/nightshift/NightShift.kt index 85fb163d..3f3979dc 100644 --- a/android/app/src/main/java/tv/orbit/classic/arcade/nightshift/NightShift.kt +++ b/android/app/src/main/java/tv/orbit/classic/arcade/nightshift/NightShift.kt @@ -36,14 +36,14 @@ internal fun sides(piece: Char, turns: Int): Int { internal fun turnable(piece: Char) = piece == 'I' || piece == 'L' || piece == 'T' /** Sleepy Time's doze, in hops. */ -internal const val SLEEPY_HOPS = 10 +internal const val SLEEPY_HOPS = 6 -/** Night Shift's power-ups: how many each level gives (Sleepy Time only where there are clouds). */ +/** Night Shift's power-ups, as the Stage B power-up sheet has them; how many each level gives (Sleepy Time only where there are clouds). */ internal enum class NightPower(val title: String, val line: String) { - Moonbeam("Moonbeam", "Turns the nearest piece the light needs"), - SleepyTime("Sleepy Time", "The clouds doze for ten hops"), - StarMagnet("Star Magnet", "Nite Owl flies to the next piece to turn"), - NightVision("Night Vision", "Shows the way the light should go"); + Moonbeam("Moonbeam", "Shows the route, softly"), + SleepyTime("Sleepy Time", "Clouds nap for 6 hops"), + StarMagnet("Star Magnet", "Pulls the light on: the nearest piece it needs turns"), + NightVision("Night Vision", "Shows the pieces still turned the wrong way"); fun forLevel(level: NightLevel) = if (this == SleepyTime && level.clouds.isEmpty()) 0 else 1 } @@ -101,16 +101,15 @@ internal class NightGame(val level: NightLevel, val turns: IntArray = IntArray(N // ---------- the power-ups (frame 41), each optional and limited per level; none counts as a move ---------- - /** Moonbeam: the nearest piece the light needs turns the right way, free. */ - fun moonbeam(): NightGame { + /** Star Magnet: the nearest piece the light needs turns the right way, free. */ + fun starMagnet(): NightGame { val i = wrongPieces().firstOrNull() ?: return this val t = turns.copyOf(); t[i] = solutionTurns(i) return NightGame(level, t, owl, moves, hops, cloudClock, dozeFor) } - /** Sleepy Time: the clouds doze where they are for the next ten hops. */ + /** Sleepy Time: the clouds nap where they are for the next six hops. */ fun sleepyTime() = NightGame(level, turns, owl, moves, hops, cloudClock, SLEEPY_HOPS) - /** Star Magnet: Nite Owl is drawn straight to the next piece the light needs. */ - fun starMagnet(): NightGame = wrongPieces().firstOrNull()?.let { NightGame(level, turns, it, moves, hops, cloudClock, dozeFor) } ?: this + /** The tiles a cloud sits on now ([at] hops), each blocking the light. */ fun cloudTiles(at: Int = cloudClock): IntArray = IntArray(level.clouds.size) { cloudAt(level.clouds[it], at) } diff --git a/android/app/src/main/java/tv/orbit/classic/arcade/nightshift/NightShiftScreen.kt b/android/app/src/main/java/tv/orbit/classic/arcade/nightshift/NightShiftScreen.kt index 7fd5e252..d2f96588 100644 --- a/android/app/src/main/java/tv/orbit/classic/arcade/nightshift/NightShiftScreen.kt +++ b/android/app/src/main/java/tv/orbit/classic/arcade/nightshift/NightShiftScreen.kt @@ -105,18 +105,19 @@ internal fun NightShiftScreen(play: ArcadePlay) { // The level's power-ups (from the pause menu), and whether Night Vision is showing the way. var powers by remember { mutableStateOf(NightPower.entries.associateWith { it.forLevel(game.level) }) } var nightVision by remember { mutableStateOf(false) } + var moonbeam by remember { mutableStateOf(false) } var powerMenu by remember { mutableStateOf(false) } val par = nightPar(game.level, play.difficulty) val focus = remember { FocusRequester() } fun startLevel(c: Int, l: Int) { chapter = c; levelIx = l; game = NightGame(NightChapters[c].levels[l]); paused = false; finished = null; stage = NightStage.Play - powers = NightPower.entries.associateWith { it.forLevel(game.level) }; nightVision = false; powerMenu = false + powers = NightPower.entries.associateWith { it.forLevel(game.level) }; nightVision = false; moonbeam = false; powerMenu = false } fun use(p: NightPower) { if ((powers[p] ?: 0) <= 0) return powers = powers + (p to (powers[p] ?: 0) - 1) - when (p) { NightPower.Moonbeam -> game = game.moonbeam(); NightPower.SleepyTime -> game = game.sleepyTime(); NightPower.StarMagnet -> game = game.starMagnet(); NightPower.NightVision -> nightVision = true } + when (p) { NightPower.Moonbeam -> moonbeam = true; NightPower.SleepyTime -> game = game.sleepyTime(); NightPower.StarMagnet -> game = game.starMagnet(); NightPower.NightVision -> nightVision = true } powerMenu = false; paused = false } // A finished level: its best saved (more stars, or fewer moves), and the profile's total stars in the High Scores. @@ -158,7 +159,7 @@ internal fun NightShiftScreen(play: ArcadePlay) { if (next != null) game = next next != null } - NightPlay(game, chapter, levelIx, par, keys, still = Motion.reduce || play.reduceFlashing, powers = powers, nightVision = nightVision) + NightPlay(game, chapter, levelIx, par, keys, still = Motion.reduce || play.reduceFlashing, powers = powers, moonbeam = moonbeam, nightVision = nightVision) if (stage == NightStage.Complete) finished?.let { (stars, moves, p) -> NightComplete(chapter, levelIx, stars, moves, p, last = chapter == NightChapters.lastIndex && levelIx == NightChapters[chapter].levels.lastIndex, onNext = { @@ -334,12 +335,14 @@ private fun NightChaptersPage(saved: Map, current: Int, onPlay: @Suppress("ModifierParameter") // [keys] is the screen's key handling, not a layout modifier @Composable -private fun NightPlay(game: NightGame, chapter: Int, level: Int, par: Int, keys: Modifier, still: Boolean, powers: Map, nightVision: Boolean) { +private fun NightPlay(game: NightGame, chapter: Int, level: Int, par: Int, keys: Modifier, still: Boolean, powers: Map, moonbeam: Boolean, nightVision: Boolean) { val on = remember(game) { game.lit() } val clouds = remember(game) { game.cloudTiles() } // Where the clouds go on the next hop (nowhere while they doze). val nextClouds = remember(game) { game.cloudTiles(if (game.dozeFor > 0) game.cloudClock else game.cloudClock + 1) } - val way = remember(game.level, nightVision) { if (nightVision) game.solutionLit() else null } + // Moonbeam: the route softly outlined. Night Vision: the pieces still turned the wrong way. + val way = remember(game.level, moonbeam) { if (moonbeam) game.solutionLit() else null } + val wrong = remember(game, nightVision) { if (nightVision) game.wrongPieces().toSet() else emptySet() } Column(Modifier.fillMaxSize().then(keys).padding(start = 32.dp, end = 32.dp, top = 22.dp, bottom = 10.dp)) { Row(Modifier.fillMaxWidth().weight(1f), horizontalArrangement = Arrangement.spacedBy(18.dp)) { Column(Modifier.width(176.dp).fillMaxHeight(), verticalArrangement = Arrangement.spacedBy(2.dp)) { @@ -363,7 +366,7 @@ private fun NightPlay(game: NightGame, chapter: Int, level: Int, par: Int, keys: } Box(Modifier.weight(1f).fillMaxHeight(), contentAlignment = Alignment.Center) { Canvas(Modifier.fillMaxHeight().aspectRatio(NW / NH.toFloat()).background(NightColours.Panel.copy(alpha = .6f), RoundedCornerShape(14.dp)) - .border(1.dp, NightColours.TileEdge, RoundedCornerShape(14.dp)).padding(8.dp)) { drawBoard(game, on, clouds, nextClouds, still, way) } + .border(1.dp, NightColours.TileEdge, RoundedCornerShape(14.dp)).padding(8.dp)) { drawBoard(game, on, clouds, nextClouds, still, way, wrong) } } Column(Modifier.width(150.dp).fillMaxHeight(), horizontalAlignment = Alignment.End, verticalArrangement = Arrangement.spacedBy(4.dp)) { // The level's power-ups (frame 41): used from the pause menu, so no Menu key is needed. @@ -388,7 +391,7 @@ private fun NightPlay(game: NightGame, chapter: Int, level: Int, par: Int, keys: } /** The board: tiles, beam pieces (lit where the light reaches), the star and mast, the clouds and where they go next, and Nite Owl. */ -private fun DrawScope.drawBoard(game: NightGame, on: BooleanArray, clouds: IntArray, nextClouds: IntArray, still: Boolean, way: BooleanArray? = null) { +private fun DrawScope.drawBoard(game: NightGame, on: BooleanArray, clouds: IntArray, nextClouds: IntArray, still: Boolean, way: BooleanArray? = null, wrong: Set = emptySet()) { val cell = minOf(size.width / NW, size.height / NH) val ox = (size.width - cell * NW) / 2; val oy = (size.height - cell * NH) / 2 val pad = cell * .05f @@ -399,7 +402,8 @@ private fun DrawScope.drawBoard(game: NightGame, on: BooleanArray, clouds: IntAr if (nextClouds.contains(i) && !clouds.contains(i)) drawRoundRect(NightColours.Muted.copy(alpha = .55f), Offset(x + pad * 2.5f, y + pad * 2.5f), Size(cell - 5 * pad, cell - 5 * pad), CornerRadius(cell * .1f), style = Stroke(1.5f, pathEffect = androidx.compose.ui.graphics.PathEffect.dashPathEffect(floatArrayOf(6f, 5f)))) - // Night Vision: the way the light should go, softly outlined. + if (i in wrong) drawRoundRect(Color(0xFF9FCFC0).copy(alpha = .8f), Offset(x + pad * 1.5f, y + pad * 1.5f), Size(cell - 3 * pad, cell - 3 * pad), CornerRadius(cell * .12f), style = Stroke(3f)) + // Moonbeam: the way the light should go, softly outlined. if (way != null && way[i]) drawRoundRect(NightColours.Star.copy(alpha = .35f), Offset(x + pad * 1.5f, y + pad * 1.5f), Size(cell - 3 * pad, cell - 3 * pad), CornerRadius(cell * .12f), style = Stroke(2f)) val c = Offset(x + cell / 2, y + cell / 2) val p = game.piece(i) diff --git a/android/app/src/test/java/tv/orbit/classic/arcade/nightshift/NightShiftLevelsTest.kt b/android/app/src/test/java/tv/orbit/classic/arcade/nightshift/NightShiftLevelsTest.kt index 160efb4a..bad1ba55 100644 --- a/android/app/src/test/java/tv/orbit/classic/arcade/nightshift/NightShiftLevelsTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/arcade/nightshift/NightShiftLevelsTest.kt @@ -95,12 +95,10 @@ class NightShiftLevelsTest { val g = NightGame(lv) val wrong = g.wrongPieces() assertTrue(wrong.isNotEmpty()) - // Moonbeam turns the nearest needed piece right, free. - val m = g.moonbeam() + // Star Magnet pulls the light on: the nearest needed piece turns right, free. + val m = g.starMagnet() assertEquals(wrong.size - 1, m.wrongPieces().size); assertEquals(0, m.moves) - // Star Magnet takes Owl to the next piece to turn. - assertEquals(wrong.first(), g.starMagnet().owl) - // Sleepy Time: the clouds stay put for ten hops, then drift again. + // Sleepy Time: the clouds nap for six hops, then drift again. var s = g.sleepyTime(); val before = s.cloudTiles().toList() repeat(SLEEPY_HOPS) { s = s.hop(if (s.owl % NW == 0) 1 else -1, 0) } assertEquals(before, s.cloudTiles().toList())