Nite Owl's Night Shift (0.115.0, versionCode 305): five chapters of twelve hand-made levels, all bot-checked within par
- 7x5 night sky: Owl hops, OK turns the beam piece; light the mast; clouds drift a tile a hop; moves against Owl's par, no timer, no fail - Title, chapter select, play and level complete from Stage B frames 40-43; shared pause; Back by context - Per-profile progress (best stars and moves per level); High Scores keep total stars; Kids-suitable - Levels from design/night-shift/make_levels.py, checked again by a bot in NightShiftLevelsTest - Power-ups left out for Paul's call (they need the Menu key the remote lacks) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,8 +9,8 @@ android {
|
||||
applicationId = "tv.orbit.classic"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = 304
|
||||
versionName = "0.114.0-classic-modes"
|
||||
versionCode = 305
|
||||
versionName = "0.115.0-night-shift"
|
||||
}
|
||||
buildFeatures { compose = true }
|
||||
// The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so
|
||||
|
||||
@@ -85,9 +85,12 @@ internal object ArcadeGames {
|
||||
listOf(GameSetting("sound", "Sound"), GameSetting("guide", "Guide line"), GameSetting("classicSkin", "Classic skin", default = false))) {
|
||||
tv.orbit.classic.arcade.hive.BumbleHiveScreen(it)
|
||||
}
|
||||
// Playable from 9 November 2026: tv.orbit.classic.arcade.nightshift. Its High Scores keep the stars won across the chapters.
|
||||
val NightShift: ArcadeGame = GameDef("NightShift", "Nite Owl's Night Shift", "Route the starlight", "Turn the beams and guide each lost star home.", Mascot.NiteOwl,
|
||||
kidsSuitable = true, original = true, launchable = false, ScoreKind.FewestMoves, keepsLevels = true, legacyRecordKey = null,
|
||||
listOf(Control("◀▶▲▼", "Hop"), Control("OK", "Turn a beam"), BackPause), "No timer and no fail: just Nite Owl's par.")
|
||||
kidsSuitable = true, original = true, launchable = true, ScoreKind.Points, keepsLevels = true, legacyRecordKey = null,
|
||||
listOf(Control("◀▶▲▼", "Hop"), Control("OK", "Turn the beam"), BackPause), "Light the mast. No timer and no fail: just Nite Owl's par.") {
|
||||
tv.orbit.classic.arcade.nightshift.NightShiftScreen(it)
|
||||
}
|
||||
val Orbiteroids: ArcadeGame = GameDef("Orbiteroids", "Orbiteroids", "Zip clears the sky", "Fly Zip through the debris and keep the sky clear.", Mascot.Zip,
|
||||
kidsSuitable = true, original = true, launchable = false, ScoreKind.Points, keepsLevels = false, legacyRecordKey = null,
|
||||
listOf(Control("◀▶", "Turn"), Control("▲", "Thrust"), Control("OK", "Fire"), BackPause), "Clear each sector, and watch your hull.")
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
package tv.orbit.classic.arcade.nightshift
|
||||
|
||||
// Generated by design/night-shift/make_levels.py (9 November 2026): five chapters of twelve, each checked solvable there
|
||||
// and again by NightShiftLevelsTest. Each row is 7 tiles of two characters: the piece (. empty, S star, M mast, I straight,
|
||||
// L corner, T tee) and its quarter turns. Clouds: each lane's tiles, a cloud moving one along it (and back) a hop.
|
||||
|
||||
internal val NightChapters: List<NightChapter> = listOf(
|
||||
NightChapter("First Light", listOf(
|
||||
NightLevel(listOf("S1L1.0.0.0.0.0", ".0L0L0.0.0I0.0", ".0.0L1L3.0.0.0", ".0I3.0L0I3I1M0", ".0.0.0.0.0.0.0"),
|
||||
solution = listOf("S1L2.0.0.0.0.0", ".0L0L2.0.0I3.0", ".0.0L0L2.0.0.0", ".0I1.0L0I1I1M0", ".0.0.0.0.0.0.0"),
|
||||
par = 11, clouds = listOf()),
|
||||
NightLevel(listOf(".0.0.0.0.0.0.0", ".0.0.0.0.0L1.0", ".0.0.0.0.0.0.0", "S1L0.0.0L3.0.0", ".0L2I1I1I1I2M0"),
|
||||
solution = listOf(".0.0.0.0.0.0.0", ".0.0.0.0.0L2.0", ".0.0.0.0.0.0.0", "S1L2.0.0L2.0.0", ".0L0I1I1I1I1M0"),
|
||||
par = 7, clouds = listOf()),
|
||||
NightLevel(listOf(".0.0.0.0.0.0.0", "S1L3.0.0.0.0.0", ".0L0I1L1L0.0.0", ".0.0.0I1.0.0.0", ".0L2.0L1I1I2M0"),
|
||||
solution = listOf(".0.0.0.0.0.0.0", "S1L2.0.0.0.0.0", ".0L0I1L2L2.0.0", ".0.0.0I0.0.0.0", ".0L3.0L0I1I1M0"),
|
||||
par = 11, clouds = listOf()),
|
||||
NightLevel(listOf(".0.0.0L2.0.0.0", "S1I1L1.0.0.0.0", ".0.0L0I0L0.0.0", ".0.0.0.0I0I3.0", "L1.0.0.0L0I1M0"),
|
||||
solution = listOf(".0.0.0L3.0.0.0", "S1I1L2.0.0.0.0", ".0.0L0I1L2.0.0", ".0.0.0.0I0I0.0", "L2.0.0.0L0I1M0"),
|
||||
par = 6, clouds = listOf()),
|
||||
NightLevel(listOf(".0.0.0.0.0.0.0", ".0.0.0.0.0.0.0", ".0I1.0.0L3.0.0", ".0L3I2I2I3I0M0", "S1L2.0.0.0L3.0"),
|
||||
solution = listOf(".0.0.0.0.0.0.0", ".0.0.0.0.0.0.0", ".0I2.0.0L0.0.0", ".0L1I1I1I1I1M0", "S1L3.0.0.0L1.0"),
|
||||
par = 8, clouds = listOf()),
|
||||
NightLevel(listOf("L3.0.0.0.0.0.0", ".0.0.0.0.0L1.0", ".0.0.0.0.0.0.0", "S1I2L0.0L2I3M0", ".0.0L3I3L2.0I0"),
|
||||
solution = listOf("L1.0.0.0.0.0.0", ".0.0.0.0.0L0.0", ".0.0.0.0.0.0.0", "S1I1L2.0L1I1M0", ".0.0L0I1L3.0I3"),
|
||||
par = 10, clouds = listOf()),
|
||||
NightLevel(listOf(".0.0.0.0.0.0.0", ".0L2.0.0L1.0.0", ".0.0I0.0.0.0.0", "S2.0L2.0L0L3.0", "L2I0I3I0L2L2M0"),
|
||||
solution = listOf(".0.0.0.0.0.0.0", ".0L3.0.0L2.0.0", ".0.0I3.0.0.0.0", "S2.0L0.0L1L2.0", "L0I1I1I1L3L0M0"),
|
||||
par = 13, clouds = listOf()),
|
||||
NightLevel(listOf("S1I2I0I2L3I2.0", ".0.0.0.0I2.0.0", ".0L3.0.0L2I0M0", ".0L2.0.0.0.0.0", "L1.0.0.0.0.0.0"),
|
||||
solution = listOf("S1I1I1I1L2I3.0", ".0.0.0.0I0.0.0", ".0L0.0.0L0I1M0", ".0L1.0.0.0.0.0", "L3.0.0.0.0.0.0"),
|
||||
par = 11, clouds = listOf()),
|
||||
NightLevel(listOf(".0I0I2.0.0.0.0", ".0.0I3.0.0.0.0", ".0.0.0.0L0I2L0", "I2.0.0L2L2.0M0", "S1I2I2L1.0.0.0"),
|
||||
solution = listOf(".0I3I1.0.0.0.0", ".0.0I2.0.0.0.0", ".0.0.0.0L1I1L2", "I3.0.0L1L3.0M0", "S1I1I1L3.0.0.0"),
|
||||
par = 14, clouds = listOf()),
|
||||
NightLevel(listOf("S1L3.0.0I2I0.0", "L3I1.0.0.0.0.0", "I0L2L0.0.0.0.0", ".0.0I1.0.0L3M0", "I0.0L3I3I0L1.0"),
|
||||
solution = listOf("S1L2.0.0I3I3.0", "L1I0.0.0.0.0.0", "I3L0L2.0.0.0.0", ".0.0I0.0.0L1M0", "I2.0L0I1I1L3.0"),
|
||||
par = 17, clouds = listOf()),
|
||||
NightLevel(listOf("S2I0.0L2L2I3L0", "L2I0I2I3L1L1M0", ".0I2.0.0.0.0.0", ".0.0.0.0.0.0.0", ".0.0.0.0L0.0.0"),
|
||||
solution = listOf("S2I1.0L0L1I1L2", "L0I1I1I1L3L3M0", ".0I1.0.0.0.0.0", ".0.0.0.0.0.0.0", ".0.0.0.0L2.0.0"),
|
||||
par = 13, clouds = listOf()),
|
||||
NightLevel(listOf("L2L0L1.0L2.0.0", "I2L2I3L1.0L1.0", "I2.0I0L3I2I2M0", "S0I2.0.0.0.0.0", ".0.0.0.0.0.0.0"),
|
||||
solution = listOf("L1L2L0.0L0.0.0", "I0L0I1L2.0L3.0", "I0.0I2L0I1I1M0", "S0I0.0.0.0.0.0", ".0.0.0.0.0.0.0"),
|
||||
par = 13, clouds = listOf()),
|
||||
)),
|
||||
NightChapter("The Quiet Mast", listOf(
|
||||
NightLevel(listOf(".0L2I2I2L1T3.0", ".0I1.0.0L1L1.0", "S1L2.0.0.0L1M0", ".0L3.0.0.0I2.0", ".0I1I3.0.0.0.0"),
|
||||
solution = listOf(".0L1I1I1L2T2.0", ".0I0.0.0L0L2.0", "S1L3.0.0.0L0M0", ".0L2.0.0.0I1.0", ".0I0I1.0.0.0.0"),
|
||||
par = 17, clouds = listOf()),
|
||||
NightLevel(listOf("S2.0.0.0L2.0I0", "I3.0.0.0.0.0.0", "L2I0I3I2I2I0M0", ".0.0.0.0L2T3.0", ".0.0.0.0.0.0L0"),
|
||||
solution = listOf("S2.0.0.0L1.0I2", "I0.0.0.0.0.0.0", "L0I1I1I1I1I1M0", ".0.0.0.0L1T0.0", ".0.0.0.0.0.0L3"),
|
||||
par = 9, clouds = listOf()),
|
||||
NightLevel(listOf("S2.0L3.0.0.0.0", "L3L3.0.0.0.0.0", "L0I3.0.0.0.0L3", ".0L3I0I2I2I2M0", "I1.0.0.0.0.0T0"),
|
||||
solution = listOf("S2.0L0.0.0.0.0", "L0L2.0.0.0.0.0", "L2I0.0.0.0.0L0", ".0L0I1I1I1I1M0", "I0.0.0.0.0.0T3"),
|
||||
par = 15, clouds = listOf()),
|
||||
NightLevel(listOf("S1I2I2L1.0T2.0", ".0.0.0L2I2I0M0", ".0.0.0.0.0.0T0", "L1I1.0.0.0.0.0", ".0I0.0.0.0T0.0"),
|
||||
solution = listOf("S1I1I1L2.0T0.0", ".0.0.0L0I1I1M0", ".0.0.0.0.0.0T1", "L2I0.0.0.0.0.0", ".0I3.0.0.0T1.0"),
|
||||
par = 9, clouds = listOf()),
|
||||
NightLevel(listOf("T2.0.0.0.0L1.0", ".0I1.0.0.0.0.0", ".0.0.0L0.0I1M0", "S1I3L1L2I2I2L0", ".0.0L1L2.0.0L3"),
|
||||
solution = listOf("T1.0.0.0.0L2.0", ".0I2.0.0.0.0.0", ".0.0.0L2.0I3M0", "S1I1L2L1I1I1L3", ".0.0L0L3.0.0L1"),
|
||||
par = 15, clouds = listOf()),
|
||||
NightLevel(listOf(".0.0.0.0T0.0.0", ".0.0L2.0L0.0M0", ".0.0.0L0I3I3L2", ".0.0L3L2.0.0T1", "S1I0L0.0I3.0T0"),
|
||||
solution = listOf(".0.0.0.0T3.0.0", ".0.0L0.0L1.0M0", ".0.0.0L1I1I1L3", ".0.0L1L3.0.0T2", "S1I1L3.0I0.0T3"),
|
||||
par = 11, clouds = listOf()),
|
||||
NightLevel(listOf("I3.0I1.0.0.0.0", "L2L0.0L2I3I2M0", "I3L2I0L0I2.0.0", "I2.0L0I3.0.0.0", "S0L1.0.0.0.0L2"),
|
||||
solution = listOf("I0.0I2.0.0.0.0", "L1L2.0L1I1I1M0", "I0L0I1L3I1.0.0", "I0.0L2I2.0.0.0", "S0L0.0.0.0.0L0"),
|
||||
par = 18, clouds = listOf()),
|
||||
NightLevel(listOf("L2L0.0.0.0.0.0", "S1I3L1L2I2I2M0", ".0.0L3L1I2.0.0", "I3L3.0.0T1.0I2", ".0.0.0.0.0.0.0"),
|
||||
solution = listOf("L3L1.0.0.0.0.0", "S1I1L2L1I1I1M0", ".0.0L0L3I0.0.0", "I0L0.0.0T3.0I1", ".0.0.0.0.0.0.0"),
|
||||
par = 11, clouds = listOf()),
|
||||
NightLevel(listOf(".0.0I0I1.0I3L0", ".0.0.0.0.0.0.0", "S1L0L0I0I0L0M0", ".0L1L0.0T2L1L0", "I0.0.0L3.0.0.0"),
|
||||
solution = listOf(".0.0I3I3.0I0L1", ".0.0.0.0.0.0.0", "S1L2L1I1I1L2M0", ".0L0L3.0T1L0L3", "I1.0.0L0.0.0.0"),
|
||||
par = 21, clouds = listOf()),
|
||||
NightLevel(listOf("L0L3.0.0L3I0.0", "I1L3I3I2I2I0M0", "S0L2.0T2I3.0.0", ".0.0I0.0.0.0L2", ".0.0.0.0I1.0.0"),
|
||||
solution = listOf("L1L2.0.0L0I2.0", "I0L0I1I1I1I1M0", "S0L0.0T1I0.0.0", ".0.0I1.0.0.0L1", ".0.0.0.0I3.0.0"),
|
||||
par = 11, clouds = listOf()),
|
||||
NightLevel(listOf(".0L0I0I0I0I3M0", "L0L0T1L3.0.0.0", "I2.0.0.0.0L0T3", "L3L3L2I1.0T2I2", "S1L2.0.0.0.0.0"),
|
||||
solution = listOf(".0L1I1I1I1I1M0", "L1L3T0L2.0.0.0", "I0.0.0.0.0L2T1", "L0L2L3I3.0T0I1", "S1L3.0.0.0.0.0"),
|
||||
par = 15, clouds = listOf()),
|
||||
NightLevel(listOf("S2.0L2I0L3.0L1", "I3.0I1T0L2L0.0", "L1I0L0T0L0L3L3", ".0.0T2.0.0I2M0", ".0.0I1.0.0.0I2"),
|
||||
solution = listOf("S2.0L1I1L2.0L3", "I0.0I0T3L0L2.0", "L0I1L3T2L2L0L2", ".0.0T3.0.0I0M0", ".0.0I0.0.0.0I0"),
|
||||
par = 26, clouds = listOf()),
|
||||
)),
|
||||
NightChapter("Cloudbank", listOf(
|
||||
NightLevel(listOf(".0.0.0.0I3.0.0", ".0L0I3.0.0.0I2", "I0.0.0.0.0.0.0", "L2I0I0I2L0.0M0", "S0.0L1.0L3I0L2"),
|
||||
solution = listOf(".0.0.0.0I1.0.0", ".0L3I2.0.0.0I0", "I2.0.0.0.0.0.0", "L1I1I1I1L2.0M0", "S0.0L0.0L0I1L3"),
|
||||
par = 14, clouds = listOf(listOf(3 to 1, 3 to 2, 3 to 3))),
|
||||
NightLevel(listOf(".0.0.0.0.0.0.0", "T3T3.0.0.0.0.0", "S2.0L2L2I3I3M0", "L3I0I0L0I1L0.0", ".0.0.0.0.0T1.0"),
|
||||
solution = listOf(".0.0.0.0.0.0.0", "T1T2.0.0.0.0.0", "S2.0L1L1I1I1M0", "L0I1I1L3I3L2.0", ".0.0.0.0.0T3.0"),
|
||||
par = 12, clouds = listOf(listOf(1 to 1, 1 to 2, 1 to 3))),
|
||||
NightLevel(listOf(".0.0L3I2L0.0.0", ".0L0L2.0I1I2M0", "S1L1.0.0L1I3L2", "L0.0.0.0.0T2T0", ".0.0I3.0.0T0.0"),
|
||||
solution = listOf(".0.0L1I1L2.0.0", ".0L1L3.0I0I1M0", "S1L3.0.0L0I1L3", "L3.0.0.0.0T0T2", ".0.0I2.0.0T1.0"),
|
||||
par = 18, clouds = listOf(listOf(2 to 2, 3 to 2, 4 to 2, 5 to 2))),
|
||||
NightLevel(listOf(".0.0.0.0.0I2.0", ".0L3.0.0L3.0M0", "S1L1.0I3.0.0I2", ".0L3I3I0L1L3L0", "I2I2.0.0L1L1L0"),
|
||||
solution = listOf(".0.0.0.0.0I0.0", ".0L2.0.0L2.0M0", "S1L2.0I2.0.0I0", ".0L0I1I1L2L1L3", "I3I3.0.0L0L3L1"),
|
||||
par = 17, clouds = listOf(listOf(3 to 4, 4 to 4, 5 to 4))),
|
||||
NightLevel(listOf(".0.0.0.0.0L3.0", "L0L0.0.0I0.0.0", "L3L0.0.0I3I1M0", "I2L3I0I2I0I2L2", "S0T3.0.0.0.0.0"),
|
||||
solution = listOf(".0.0.0.0.0L1.0", "L1L3.0.0I3.0.0", "L1L2.0.0I0I0M0", "I0L0I1I1I1I1L3", "S0T2.0.0.0.0.0"),
|
||||
par = 13, clouds = listOf(listOf(1 to 1, 1 to 2, 1 to 3))),
|
||||
NightLevel(listOf("S1I3I2L0L2L3M0", "I0.0.0L1L2L3L0", ".0.0.0.0.0.0.0", "L0L3.0.0.0.0.0", ".0.0.0I3T3L0I2"),
|
||||
solution = listOf("S1I1I1L2L1L2M0", "I1.0.0L0L3L0L3", ".0.0.0.0.0.0.0", "L2L2.0.0.0.0.0", ".0.0.0I1T0L1I1"),
|
||||
par = 20, clouds = listOf(listOf(3 to 0, 3 to 1, 3 to 2))),
|
||||
NightLevel(listOf(".0.0.0.0T0.0I3", ".0L3I3I0L1L2M0", "S1L2I1.0L2L2.0", "I1L3.0.0.0.0.0", "I2.0T0I1.0.0.0"),
|
||||
solution = listOf(".0.0.0.0T2.0I0", ".0L1I1I1L2L1M0", "S1L3I3.0L0L3.0", "I2L0.0.0.0.0.0", "I3.0T3I2.0.0.0"),
|
||||
par = 15, clouds = listOf(listOf(0 to 1, 1 to 1, 2 to 1, 3 to 1), listOf(5 to 0, 5 to 1, 5 to 2))),
|
||||
NightLevel(listOf(".0.0.0.0.0L1L3", ".0.0.0.0I2L0L3", ".0I3.0T3.0.0.0", ".0L0I2I2I3L0M0", "S1L0T3.0.0L1L1"),
|
||||
solution = listOf(".0.0.0.0.0L0L1", ".0.0.0.0I1L2L2", ".0I1.0T0.0.0.0", ".0L1I1I1I1L2M0", "S1L3T0.0.0L0L3"),
|
||||
par = 16, clouds = listOf(listOf(0 to 3, 1 to 3, 2 to 3, 3 to 3), listOf(4 to 1, 4 to 2, 4 to 3))),
|
||||
NightLevel(listOf("I0I0I3.0.0.0I1", "L3L3L0I0.0.0M0", "S0L3I2L3.0.0I1", ".0L0.0L2I2I2L0", ".0.0.0.0I1.0.0"),
|
||||
solution = listOf("I1I3I1.0.0.0I2", "L1L2L2I1.0.0M0", "S0L0I1L2.0.0I0", ".0L2.0L0I1I1L3", ".0.0.0.0I2.0.0"),
|
||||
par = 22, clouds = listOf(listOf(0 to 1, 1 to 1, 2 to 1, 3 to 1), listOf(2 to 2, 3 to 2, 4 to 2, 5 to 2))),
|
||||
NightLevel(listOf(".0L2L1I0.0L2L3", "L0L0L1I3I3I0M0", "I2T2L3.0.0L1T1", "I3.0.0.0.0.0.0", "S0.0.0.0.0I1T2"),
|
||||
solution = listOf(".0L1L2I2.0L0L2", "L1L3L0I1I1I1M0", "I0T0L0.0.0L3T3", "I0.0.0.0.0.0.0", "S0.0.0.0.0I0T0"),
|
||||
par = 23, clouds = listOf(listOf(1 to 0, 1 to 1, 1 to 2), listOf(5 to 0, 5 to 1, 5 to 2))),
|
||||
NightLevel(listOf("T1.0.0I2L1.0.0", "L2I0L1I3T1.0I1", "S0L2L0.0I1.0M0", ".0L3I3I2I3I3L1", ".0.0L0.0L1.0.0"),
|
||||
solution = listOf("T0.0.0I1L3.0.0", "L1I1L2I2T2.0I0", "S0L1L3.0I0.0M0", ".0L0I1I1I1I1L3", ".0.0L1.0L0.0.0"),
|
||||
par = 19, clouds = listOf(listOf(1 to 0, 1 to 1, 1 to 2), listOf(3 to 1, 3 to 2, 3 to 3))),
|
||||
NightLevel(listOf(".0.0I1.0.0.0L0", "L2L3I0L1L1.0.0", "S0I1.0L1.0.0.0", ".0L2L3.0L0I2M0", "I1I1L1I0L2.0L3"),
|
||||
solution = listOf(".0.0I3.0.0.0L1", "L1L2I2L3L3.0.0", "S0I0.0L0.0.0.0", ".0L0L2.0L1I1M0", "I0I2L0I1L3.0L1"),
|
||||
par = 22, clouds = listOf(listOf(5 to 1, 5 to 2, 5 to 3), listOf(2 to 1, 2 to 2, 2 to 3))),
|
||||
)),
|
||||
NightChapter("Northern Relay", listOf(
|
||||
NightLevel(listOf("S1I2I2T2L0.0T1", ".0L2.0M0L2L1.0", ".0.0T0.0.0L1M0", ".0.0I1.0.0.0.0", "I2.0T0.0.0I2.0"),
|
||||
solution = listOf("S1I1I1T1L2.0T3", ".0L1.0M0L0L2.0", ".0.0T2.0.0L0M0", ".0.0I2.0.0.0.0", "I1.0T1.0.0I1.0"),
|
||||
par = 16, clouds = listOf(listOf(2 to 0, 2 to 1, 2 to 2), listOf(4 to 0, 4 to 1, 4 to 2))),
|
||||
NightLevel(listOf(".0I3.0.0M0I2.0", "L3.0.0.0I3L1L0", ".0.0L0I2T0I2L0", "S1L1I3I0.0.0I1", ".0L1L1.0.0L3M0"),
|
||||
solution = listOf(".0I1.0.0M0I3.0", "L0.0.0.0I0L0L3", ".0.0L1I1T3I1L2", "S1L2I0I3.0.0I0", ".0L0L3.0.0L0M0"),
|
||||
par = 22, clouds = listOf(listOf(1 to 4, 2 to 4, 3 to 4, 4 to 4), listOf(3 to 0, 3 to 1, 3 to 2))),
|
||||
NightLevel(listOf("T1.0.0M0.0.0L1", "I1L0L0T2I0I2M0", "T1L3L2.0.0.0.0", "L0L1.0.0I2.0.0", "S0.0I3.0.0.0.0"),
|
||||
solution = listOf("T3.0.0M0.0.0L0", "I0L2L1T3I1I1M0", "T0L1L3.0.0.0.0", "L1L3.0.0I0.0.0", "S0.0I2.0.0.0.0"),
|
||||
par = 13, clouds = listOf(listOf(0 to 3, 1 to 3, 2 to 3), listOf(0 to 1, 1 to 1, 2 to 1, 3 to 1))),
|
||||
NightLevel(listOf("S2.0L3.0T3.0.0", "L3I0L0L3.0I1I3", ".0.0I2.0.0.0I2", ".0.0L1I2L0L3M0", ".0I0I1M0T2L2.0"),
|
||||
solution = listOf("S2.0L0.0T2.0.0", "L0I1L2L1.0I2I2", ".0.0I0.0.0.0I3", ".0.0L0I1L2L1M0", ".0I1I0M0T3L3.0"),
|
||||
par = 17, clouds = listOf(listOf(2 to 0, 2 to 1, 2 to 2), listOf(5 to 2, 5 to 3, 5 to 4))),
|
||||
NightLevel(listOf(".0L3.0.0.0M0I3", "L3I3I0L3.0T1L1", "S0T1L3L1I3L1M0", ".0.0I1L3.0.0.0", ".0.0.0L0.0T0.0"),
|
||||
solution = listOf(".0L0.0.0.0M0I0", "L1I1I1L2.0T0L2", "S0T3L0L0I1L3M0", ".0.0I2L0.0.0.0", ".0.0.0L1.0T3.0"),
|
||||
par = 18, clouds = listOf(listOf(4 to 1, 5 to 1, 6 to 1), listOf(2 to 0, 2 to 1, 2 to 2))),
|
||||
NightLevel(listOf("I2.0L3.0M0.0.0", ".0L2I2I2T1L0M0", "S1L2L2.0L1I3L1", "I3.0.0.0L2.0.0", ".0.0.0T1.0.0T1"),
|
||||
solution = listOf("I3.0L0.0M0.0.0", ".0L1I1I1T2L2M0", "S1L3L3.0L0I1L3", "I0.0.0.0L1.0.0", ".0.0.0T2.0.0T0"),
|
||||
par = 15, clouds = listOf(listOf(2 to 2, 3 to 2, 4 to 2, 5 to 2), listOf(1 to 1, 1 to 2, 1 to 3))),
|
||||
NightLevel(listOf("L1L0I3T3I3M0M0", "L2L2L0L2I0I0L1", "S0L0.0.0.0.0.0", "L1.0.0.0T0I0L3", ".0.0.0.0I0.0L1"),
|
||||
solution = listOf("L2L1I1T1I1M0M0", "L1L3L2L0I1I1L3", "S0L3.0.0.0.0.0", "L3.0.0.0T3I1L0", ".0.0.0.0I3.0L2"),
|
||||
par = 16, clouds = listOf(listOf(0 to 1, 1 to 1, 2 to 1), listOf(3 to 0, 3 to 1, 3 to 2))),
|
||||
NightLevel(listOf("M0T0I2L0.0.0M0", "L2L2.0L3I3I2L1", "S0I3I2.0.0T2I1", ".0T0.0.0L3.0.0", "I1.0.0L2L3.0.0"),
|
||||
solution = listOf("M0T1I1L2.0.0M0", "L1L3.0L0I1I1L3", "S0I2I0.0.0T0I2", ".0T2.0.0L0.0.0", "I3.0.0L0L1.0.0"),
|
||||
par = 15, clouds = listOf(listOf(5 to 0, 5 to 1, 5 to 2), listOf(3 to 0, 3 to 1, 3 to 2))),
|
||||
NightLevel(listOf(".0L1I1I3I3.0L2", ".0.0.0L3I0I0.0", "S2.0.0.0I0.0.0", "L2I3L3.0.0L0L3", ".0M0T1I3I2L0M0"),
|
||||
solution = listOf(".0L0I2I2I2.0L0", ".0.0.0L1I2I2.0", "S2.0.0.0I1.0.0", "L0I1L2.0.0L1L2", ".0M0T3I1I1L3M0"),
|
||||
par = 18, clouds = listOf(listOf(3 to 3, 4 to 3, 5 to 3), listOf(2 to 2, 2 to 3, 2 to 4))),
|
||||
NightLevel(listOf(".0.0I3.0.0.0.0", "L2I3M0I1T2.0.0", "L1.0I2L3.0I1.0", "S2L2T0I0L0.0M0", "L3L0L1L2L2I0L2"),
|
||||
solution = listOf(".0.0I2.0.0.0.0", "L0I1M0I0T1.0.0", "L0.0I0L2.0I3.0", "S2L1T3I1L2.0M0", "L0L3L3L3L0I1L3"),
|
||||
par = 23, clouds = listOf(listOf(4 to 1, 4 to 2, 4 to 3), listOf(3 to 2, 3 to 3, 3 to 4))),
|
||||
NightLevel(listOf("L2L1I1L1L3M0I0", "S0L3I0I2I0T3M0", ".0.0L2L1.0L3L1", "I1.0.0.0.0.0.0", "T3.0I2.0T1.0.0"),
|
||||
solution = listOf("L1L2I0L0L0M0I1", "S0L0I1I1I1T2M0", ".0.0L0L2.0L0L3", "I3.0.0.0.0.0.0", "T2.0I3.0T0.0.0"),
|
||||
par = 19, clouds = listOf(listOf(1 to 0, 1 to 1, 1 to 2), listOf(3 to 0, 3 to 1, 3 to 2))),
|
||||
NightLevel(listOf("S1L1.0L3L1L0L1", ".0T2L0L3I2L1M0", "I0I3L2L0.0L2L2", ".0M0.0.0T0T0.0", ".0.0I2.0.0L2L3"),
|
||||
solution = listOf("S1L2.0L2L2L2L3", ".0T0L2L1I1L2M0", "I3I0L0L3.0L0L3", ".0M0.0.0T2T3.0", ".0.0I1.0.0L0L1"),
|
||||
par = 21, clouds = listOf(listOf(5 to 0, 5 to 1, 5 to 2), listOf(2 to 0, 2 to 1, 2 to 2))),
|
||||
)),
|
||||
NightChapter("Last Light Before Dawn", listOf(
|
||||
NightLevel(listOf("I0I3.0.0I3.0.0", "L3.0.0.0L2.0.0", "L3.0M0.0.0L3.0", "S2L2T0I2I2L0.0", "L2L2.0L2L1L2M0"),
|
||||
solution = listOf("I3I2.0.0I2.0.0", "L2.0.0.0L1.0.0", "L2.0M0.0.0L2.0", "S2L1T3I1I1L2.0", "L0L3.0L3L2L0M0"),
|
||||
par = 19, clouds = listOf(listOf(3 to 1, 3 to 2, 3 to 3), listOf(1 to 2, 1 to 3, 1 to 4))),
|
||||
NightLevel(listOf("I1L3.0.0L0I3M0", ".0I0.0L3L1T2.0", "T3.0L2T3.0L0.0", "L0I2L2I3T2.0T3", "S0.0.0M0L2.0.0"),
|
||||
solution = listOf("I3L1.0.0L1I1M0", ".0I2.0L1L3T1.0", "T2.0L1T2.0L1.0", "L1I1L3I0T3.0T2", "S0.0.0M0L3.0.0"),
|
||||
par = 20, clouds = listOf(listOf(5 to 0, 5 to 1, 5 to 2), listOf(2 to 2, 2 to 3, 2 to 4))),
|
||||
NightLevel(listOf("S1I3T3I0M0.0L1", ".0.0I1.0.0T1L1", ".0L2I2T3.0L0.0", ".0.0L3L1.0.0L3", "T0.0I0L2I0I0M0"),
|
||||
solution = listOf("S1I1T1I1M0.0L3", ".0.0I0.0.0T2L3", ".0L1I0T1.0L1.0", ".0.0L0L2.0.0L2", "T2.0I2L0I1I1M0"),
|
||||
par = 17, clouds = listOf(listOf(5 to 2, 5 to 3, 5 to 4), listOf(3 to 2, 3 to 3, 3 to 4))),
|
||||
NightLevel(listOf("I1I3.0M0.0.0.0", "S2I1.0I3.0.0.0", "L1I2I0T2I0L0M0", "I1L3.0L1.0L2L2", ".0T1.0I3.0L3L1"),
|
||||
solution = listOf("I3I2.0M0.0.0.0", "S2I3.0I0.0.0.0", "L0I1I1T3I1L2M0", "I2L2.0L2.0L0L3", ".0T2.0I1.0L0L2"),
|
||||
par = 17, clouds = listOf(listOf(2 to 1, 2 to 2, 2 to 3), listOf(5 to 1, 5 to 2, 5 to 3))),
|
||||
NightLevel(listOf("S2.0I2T0L1.0.0", "I3I1L2I2M0.0.0", "L1I2L0.0I3L0M0", ".0.0L3I3T0I3L2", "I1L3.0.0.0L0.0"),
|
||||
solution = listOf("S2.0I3T2L0.0.0", "I0I2L0I1M0.0.0", "L0I1L2.0I0L1M0", ".0.0L0I1T3I1L3", "I0L0.0.0.0L1.0"),
|
||||
par = 21, clouds = listOf(listOf(3 to 1, 3 to 2, 3 to 3), listOf(5 to 1, 5 to 2, 5 to 3))),
|
||||
NightLevel(listOf(".0L3T3L0.0L3L3", "S1L1I3L1I0L1M0", "I2.0M0.0I0.0.0", "I0.0I3.0.0I2I1", ".0.0L1T2I0.0I1"),
|
||||
solution = listOf(".0L1T1L2.0L1L2", "S1L3I0L0I1L3M0", "I3.0M0.0I1.0.0", "I3.0I0.0.0I3I2", ".0.0L2T3I3.0I0"),
|
||||
par = 25, clouds = listOf(listOf(3 to 0, 3 to 1, 3 to 2), listOf(5 to 0, 5 to 1, 5 to 2))),
|
||||
NightLevel(listOf(".0M0I2T3I3L1M0", "L1L0I0L0L0L1L2", "S1L2.0.0.0L0L3", "I1.0.0.0.0L2.0", ".0I0L3I1L2I3.0"),
|
||||
solution = listOf(".0M0I1T1I1L2M0", "L2L1I1L3L1L0L3", "S1L3.0.0.0L2L0", "I0.0.0.0.0L0.0", ".0I3L2I3L0I2.0"),
|
||||
par = 18, clouds = listOf(listOf(2 to 0, 2 to 1, 2 to 2), listOf(5 to 0, 5 to 1, 5 to 2))),
|
||||
NightLevel(listOf(".0I2L1.0I1.0T1", ".0.0.0L2.0T1.0", "L2I3L0T1M0.0L2", "S0L3L1I2T0L3M0", ".0.0.0T1L3L1L1"),
|
||||
solution = listOf(".0I0L3.0I0.0T3", ".0.0.0L1.0T0.0", "L1I1L2T2M0.0L0", "S0L0L0I1T3L2M0", ".0.0.0T2L0L0L3"),
|
||||
par = 24, clouds = listOf(listOf(1 to 3, 2 to 3, 3 to 3, 4 to 3), listOf(5 to 2, 5 to 3, 5 to 4))),
|
||||
NightLevel(listOf("S2T1.0.0I3.0T1", "I3I3I0I2.0I3.0", "L3L1M0I3.0L0L3", ".0L2T1I0I0L0M0", "L3.0.0.0T0L1.0"),
|
||||
solution = listOf("S2T0.0.0I0.0T3", "I0I1I1I3.0I0.0", "L0L2M0I1.0L1L2", ".0L0T3I1I1L3M0", "L0.0.0.0T2L0.0"),
|
||||
par = 20, clouds = listOf(listOf(4 to 1, 4 to 2, 4 to 3), listOf(0 to 1, 1 to 1, 2 to 1))),
|
||||
NightLevel(listOf("L0L3L0T3I2M0L2", "I2L3L0L3I3I2M0", "I1.0L1L2T0I2L1", "S0T2.0.0.0L3.0", "L3L3I2.0.0T2.0"),
|
||||
solution = listOf("L1L2L1T1I1M0L3", "I0L0L3L0I1I1M0", "I0.0L3L3T2I0L0", "S0T1.0.0.0L1.0", "L0L1I1.0.0T1.0"),
|
||||
par = 23, clouds = listOf(listOf(2 to 0, 2 to 1, 2 to 2), listOf(1 to 0, 1 to 1, 1 to 2))),
|
||||
NightLevel(listOf("S2L2L0.0I3.0I0", "I1L0L0I2L0L0.0", "L3L2T1I2L2I3.0", "T2.0I1L2I1L3L0", "L2L3M0L2L3.0M0"),
|
||||
solution = listOf("S2L1L3.0I0.0I2", "I0L1L2I0L1L2.0", "L0L3T0I1L3I0.0", "T0.0I0L1I2L0L2", "L0L1M0L3L1.0M0"),
|
||||
par = 29, clouds = listOf(listOf(3 to 1, 4 to 1, 5 to 1, 6 to 1), listOf(3 to 3, 4 to 3, 5 to 3, 6 to 3))),
|
||||
NightLevel(listOf("S1L3.0L0L0L2M0", ".0I1L1.0.0.0I2", "I2T3I0I0I0L1I3", "I3I2I3T3I3L1L2", "L2M0.0.0I2.0L0"),
|
||||
solution = listOf("S1L2.0L1L3L0M0", ".0I0L0.0.0.0I0", "I0T0I1I1I1L2I0", "I2I0I2T0I2L0L3", "L1M0.0.0I3.0L2"),
|
||||
par = 23, clouds = listOf(listOf(3 to 3, 4 to 3, 5 to 3, 6 to 3), listOf(3 to 0, 3 to 1, 3 to 2))),
|
||||
)),
|
||||
)
|
||||
@@ -0,0 +1,138 @@
|
||||
package tv.orbit.classic.arcade.nightshift
|
||||
|
||||
import tv.orbit.classic.arcade.Difficulty
|
||||
|
||||
/**
|
||||
* Nite Owl's Night Shift (Stage B frames 40–43, 9 November 2026): a calm puzzle for the late shift. A 7 × 5 night sky; Nite
|
||||
* Owl hops tile to tile and OK turns the beam piece under him, routing the lost star's light to the relay mast. Clouds drift
|
||||
* a tile along their lanes each hop and block the light where they sit. Moves (turns) against Owl's par: no timer, no fail.
|
||||
* The game has no screen in it, so it can be tested.
|
||||
*/
|
||||
internal const val NW = 7
|
||||
internal const val NH = 5
|
||||
|
||||
/** A side of a tile, as a bit: north, east, south, west. */
|
||||
internal const val SIDE_N = 1
|
||||
internal const val SIDE_E = 2
|
||||
internal const val SIDE_S = 4
|
||||
internal const val SIDE_W = 8
|
||||
private val Sides = intArrayOf(SIDE_N, SIDE_E, SIDE_S, SIDE_W)
|
||||
private val Dx = intArrayOf(0, 1, 0, -1)
|
||||
private val Dy = intArrayOf(-1, 0, 1, 0)
|
||||
private fun opposite(side: Int) = when (side) { SIDE_N -> SIDE_S; SIDE_S -> SIDE_N; SIDE_E -> SIDE_W; else -> SIDE_E }
|
||||
|
||||
/** A piece's sides when unturned: a straight (north–south), a corner (north–east), a tee, the star (beam north), the mast (all). */
|
||||
internal fun baseSides(piece: Char) = when (piece) { 'I' -> SIDE_N or SIDE_S; 'L' -> SIDE_N or SIDE_E; 'T' -> SIDE_N or SIDE_E or SIDE_S; 'S' -> SIDE_N; 'M' -> 15; else -> 0 }
|
||||
|
||||
/** The sides of [piece] turned [turns] quarters clockwise. */
|
||||
internal fun sides(piece: Char, turns: Int): Int {
|
||||
if (piece == 'M') return 15
|
||||
var m = baseSides(piece)
|
||||
repeat(((turns % 4) + 4) % 4) { m = ((m shl 1) or (m shr 3)) and 15 }
|
||||
return m
|
||||
}
|
||||
|
||||
/** Only these turn under OK: the star and the mast stay put. */
|
||||
internal fun turnable(piece: Char) = piece == 'I' || piece == 'L' || piece == 'T'
|
||||
|
||||
internal class NightLevel(val rows: List<String>, val solution: List<String>, val par: Int, val clouds: List<List<Pair<Int, Int>>>) {
|
||||
fun piece(i: Int) = rows[i / NW][i % NW * 2]
|
||||
fun turns(i: Int) = rows[i / NW][i % NW * 2 + 1] - '0'
|
||||
}
|
||||
|
||||
internal class NightChapter(val name: String, val levels: List<NightLevel>)
|
||||
|
||||
/** Owl's par for a difficulty: a little more room on Gentle, a little less on Tricky (never below what it really takes). */
|
||||
internal fun nightPar(level: NightLevel, d: Difficulty) = when (d) { Difficulty.Gentle -> level.par + 3; Difficulty.Normal -> level.par; Difficulty.Tricky -> level.par - 1 }
|
||||
|
||||
/** Stars for a finished level: three on or under par, two a little over, one however long it took. */
|
||||
internal fun nightStars(moves: Int, par: Int) = when { moves <= par -> 3; moves <= par + maxOf(3, par / 3) -> 2; else -> 1 }
|
||||
|
||||
/** Where a cloud on [lane] is after [hops] hops: along the lane and back again. */
|
||||
internal fun cloudAt(lane: List<Pair<Int, Int>>, hops: Int): Int {
|
||||
if (lane.size == 1) return lane[0].second * NW + lane[0].first
|
||||
val period = 2 * lane.size - 2
|
||||
val k = hops % period
|
||||
val p = if (k < lane.size) lane[k] else lane[period - k]
|
||||
return p.second * NW + p.first
|
||||
}
|
||||
|
||||
/** One level being played. Turns count as moves; hops don't, but each hop moves the clouds on. */
|
||||
internal class NightGame(val level: NightLevel, val turns: IntArray = IntArray(NW * NH) { level.turns(it) }, val owl: Int = start(level), val moves: Int = 0, val hops: Int = 0) {
|
||||
fun piece(i: Int) = level.piece(i)
|
||||
|
||||
/** Nite Owl hops to the next tile, if there is one; the clouds drift on a tile. */
|
||||
fun hop(dx: Int, dy: Int): NightGame {
|
||||
val x = owl % NW + dx; val y = owl / NW + dy
|
||||
if (x !in 0 until NW || y !in 0 until NH) return this
|
||||
return NightGame(level, turns, y * NW + x, moves, hops + 1)
|
||||
}
|
||||
|
||||
/** OK: the piece under Nite Owl turns a quarter, clockwise. Nothing there to turn, nothing happens. */
|
||||
fun turn(): NightGame {
|
||||
if (!turnable(piece(owl))) return this
|
||||
val t = turns.copyOf(); t[owl] = (t[owl] + 1) % 4
|
||||
return NightGame(level, t, owl, moves + 1, hops)
|
||||
}
|
||||
|
||||
/** The tiles a cloud sits on now ([at] hops), each blocking the light. */
|
||||
fun cloudTiles(at: Int = hops): IntArray = IntArray(level.clouds.size) { cloudAt(level.clouds[it], at) }
|
||||
|
||||
/** Every tile the light reaches: from the star along its beam, through pieces whose sides meet; clouds stop it. */
|
||||
fun lit(): BooleanArray {
|
||||
val on = BooleanArray(NW * NH)
|
||||
val clouds = cloudTiles()
|
||||
val star = (0 until NW * NH).first { piece(it) == 'S' }
|
||||
on[star] = true
|
||||
val todo = IntArray(NW * NH); var n = 0; todo[n++] = star
|
||||
while (n > 0) {
|
||||
val i = todo[--n]
|
||||
val here = sides(piece(i), turns[i])
|
||||
for (k in 0..3) {
|
||||
if (here and Sides[k] == 0) continue
|
||||
val x = i % NW + Dx[k]; val y = i / NW + Dy[k]
|
||||
if (x !in 0 until NW || y !in 0 until NH) continue
|
||||
val j = y * NW + x
|
||||
if (on[j] || clouds.contains(j)) continue
|
||||
if (sides(piece(j), turns[j]) and opposite(Sides[k]) == 0) continue
|
||||
on[j] = true; todo[n++] = j
|
||||
}
|
||||
}
|
||||
return on
|
||||
}
|
||||
|
||||
val masts get() = (0 until NW * NH).filter { piece(it) == 'M' }
|
||||
/** Every mast lit: the star's home. */
|
||||
val won get() = lit().let { on -> masts.all { on[it] } }
|
||||
|
||||
companion object {
|
||||
/** Nite Owl starts beside the star. */
|
||||
fun start(level: NightLevel): Int { val s = (0 until NW * NH).first { level.piece(it) == 'S' }; return if (s % NW + 1 < NW) s + 1 else s - 1 }
|
||||
}
|
||||
}
|
||||
|
||||
/** Where a profile has got to: each level's best (stars and moves), saved in the game's level progress. */
|
||||
internal object NightProgress {
|
||||
fun key(chapter: Int, level: Int) = "ns.$chapter.$level"
|
||||
fun best(saved: Map<String, String>, chapter: Int, level: Int): Pair<Int, Int>? =
|
||||
saved[key(chapter, level)]?.split(',')?.let { p -> p.getOrNull(0)?.toIntOrNull()?.let { s -> s to (p.getOrNull(1)?.toIntOrNull() ?: 0) } }
|
||||
fun done(saved: Map<String, String>, chapter: Int) = NightChapters[chapter].levels.indices.count { best(saved, chapter, it) != null }
|
||||
fun stars(saved: Map<String, String>, chapter: Int) = NightChapters[chapter].levels.indices.sumOf { best(saved, chapter, it)?.first ?: 0 }
|
||||
fun totalStars(saved: Map<String, String>) = NightChapters.indices.sumOf { stars(saved, it) }
|
||||
/** A chapter opens when the one before is finished; the first is always open. */
|
||||
fun open(saved: Map<String, String>, chapter: Int) = chapter == 0 || done(saved, chapter - 1) == NightChapters[chapter - 1].levels.size
|
||||
/** A level opens when the one before it in its chapter is done. */
|
||||
fun levelOpen(saved: Map<String, String>, chapter: Int, level: Int) = open(saved, chapter) && (level == 0 || best(saved, chapter, level - 1) != null)
|
||||
/** Where Continue goes: the first level not yet done in the furthest open chapter, or the very last. */
|
||||
fun next(saved: Map<String, String>): Pair<Int, Int> {
|
||||
for (c in NightChapters.indices) {
|
||||
if (!open(saved, c)) break
|
||||
val l = NightChapters[c].levels.indices.firstOrNull { best(saved, c, it) == null }
|
||||
if (l != null) return c to l
|
||||
}
|
||||
return NightChapters.lastIndex to NightChapters.last().levels.lastIndex
|
||||
}
|
||||
/** A level's best after a finish: more stars, or the same stars in fewer moves. */
|
||||
fun better(old: Pair<Int, Int>?, stars: Int, moves: Int) = old == null || stars > old.first || (stars == old.first && moves < old.second)
|
||||
fun value(stars: Int, moves: Int) = "$stars,$moves"
|
||||
}
|
||||
@@ -0,0 +1,453 @@
|
||||
package tv.orbit.classic.arcade.nightshift
|
||||
|
||||
import android.view.KeyEvent
|
||||
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.focusable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawWithCache
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.focus.onFocusChanged
|
||||
import androidx.compose.ui.geometry.CornerRadius
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.Path
|
||||
import androidx.compose.ui.graphics.StrokeCap
|
||||
import androidx.compose.ui.graphics.drawscope.DrawScope
|
||||
import androidx.compose.ui.graphics.drawscope.Stroke
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
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.Motion
|
||||
import tv.orbit.classic.arcade.ArcadeButton
|
||||
import tv.orbit.classic.arcade.ArcadeColours
|
||||
import tv.orbit.classic.arcade.ArcadeGames
|
||||
import tv.orbit.classic.arcade.ArcadeKey
|
||||
import tv.orbit.classic.arcade.ArcadePauseMenu
|
||||
import tv.orbit.classic.arcade.ArcadePlay
|
||||
import tv.orbit.classic.arcade.Control
|
||||
import tv.orbit.classic.arcade.HowToPlayCard
|
||||
import tv.orbit.classic.arcade.KeyFooter
|
||||
import tv.orbit.classic.arcade.RunEnd
|
||||
import tv.orbit.classic.arcade.gameKeys
|
||||
import tv.orbit.classic.arcade.onBackKey
|
||||
import tv.orbit.classic.drawNightCap
|
||||
import tv.orbit.classic.drawNiteOwl
|
||||
import tv.orbit.classic.starPath
|
||||
|
||||
/** Night Shift's own colours (frames 40–43): muted indigo, nothing bright but the starlight. */
|
||||
internal object NightColours {
|
||||
val Top = Color(0xFF0D1140)
|
||||
val Bottom = Color(0xFF2A1F5E)
|
||||
val Tile = Color(0xFF262C6B)
|
||||
val TileEdge = Color(0xFF3A428C)
|
||||
val Beam = Color(0xFF4A55A8)
|
||||
val Lit = Color(0xFFE9E6FF)
|
||||
val Glow = Color(0xFF9AA6FF)
|
||||
val Star = Color(0xFFFFE9A8)
|
||||
val Ink = Color(0xFFE6E2FF)
|
||||
val Muted = Color(0xFFA9A4D9)
|
||||
val Panel = Color(0xFF1B1D55)
|
||||
}
|
||||
|
||||
/** The night sky behind every Night Shift screen: drawn once, in its own layer. */
|
||||
private fun Modifier.nightSky(): Modifier = graphicsLayer().drawWithCache {
|
||||
val rnd = java.util.Random(999)
|
||||
val stars = FloatArray(120 * 3) { k -> when (k % 3) { 0 -> rnd.nextFloat() * size.width; 1 -> rnd.nextFloat() * size.height; else -> .6f + rnd.nextFloat() * 1.3f } }
|
||||
val sky = Brush.verticalGradient(listOf(NightColours.Top, NightColours.Bottom))
|
||||
onDrawBehind {
|
||||
drawRect(sky)
|
||||
for (i in 0 until 120) drawCircle(Color.White.copy(alpha = .15f + stars[i * 3 + 2] / 6), stars[i * 3 + 2], Offset(stars[i * 3], stars[i * 3 + 1]))
|
||||
}
|
||||
}
|
||||
|
||||
private enum class NightStage { Title, Chapters, Play, Complete }
|
||||
|
||||
/** Nite Owl's lines when a level's done, by stars (frame 42). */
|
||||
internal fun owlLine(stars: Int) = when (stars) { 3 -> "Right on par. Very tidy."; 2 -> "Took the scenic route, did we?"; else -> "Got there in the end. The stars don't mind." }
|
||||
internal fun parLine(moves: Int, par: Int) = when {
|
||||
moves < par -> "${par - moves} under par. Show-off."
|
||||
moves == par -> "Bang on Owl's par."
|
||||
moves - par == 1 -> "One over par. The stars don't mind."
|
||||
else -> "${words(moves - par)} over par. The stars don't mind."
|
||||
}
|
||||
private fun words(n: Int) = listOf("Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten").getOrElse(n) { "$n" }
|
||||
|
||||
@Composable
|
||||
internal fun NightShiftScreen(play: ArcadePlay) {
|
||||
val gameDef = ArcadeGames.NightShift
|
||||
val latestPlay by rememberUpdatedState(play)
|
||||
// The profile's progress, kept here as it changes (the Arcade saves it with each finished level).
|
||||
var saved by remember { mutableStateOf(play.level) }
|
||||
var stage by remember { mutableStateOf(NightStage.Title) }
|
||||
var chapter by remember { mutableIntStateOf(NightProgress.next(play.level).first) }
|
||||
var levelIx by remember { mutableIntStateOf(NightProgress.next(play.level).second) }
|
||||
var game by remember { mutableStateOf(NightGame(NightChapters[chapter].levels[levelIx])) }
|
||||
var paused by remember { mutableStateOf(false) }
|
||||
var howTo by remember { mutableStateOf(false) }
|
||||
var finished by remember { mutableStateOf<Triple<Int, Int, Int>?>(null) } // stars, moves, par
|
||||
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 }
|
||||
// A finished level: its best saved (more stars, or fewer moves), and the profile's total stars in the High Scores.
|
||||
LaunchedEffect(game) {
|
||||
if (stage != NightStage.Play || !game.won) return@LaunchedEffect
|
||||
val stars = nightStars(game.moves, par)
|
||||
val old = NightProgress.best(saved, chapter, levelIx)
|
||||
if (NightProgress.better(old, stars, game.moves)) {
|
||||
val v = NightProgress.value(maxOf(stars, old?.first ?: 0), if (old != null && old.first > stars) old.second else game.moves)
|
||||
saved = saved + (NightProgress.key(chapter, levelIx) to v)
|
||||
latestPlay.setLevel(NightProgress.key(chapter, levelIx), v)
|
||||
}
|
||||
latestPlay.onRunEnd(RunEnd(NightProgress.totalStars(saved), finished = true, detail = "Ch ${chapter + 1} · Level ${levelIx + 1}"))
|
||||
finished = Triple(stars, game.moves, par)
|
||||
stage = NightStage.Complete
|
||||
}
|
||||
LaunchedEffect(stage, paused) { if (stage == NightStage.Play && !paused) runCatching { focus.requestFocus() } }
|
||||
BackHandler(stage == NightStage.Play && !paused) { paused = true }
|
||||
|
||||
Box(Modifier.fillMaxSize().nightSky()) {
|
||||
when (stage) {
|
||||
NightStage.Title -> {
|
||||
NightTitle(saved, refocus = !howTo, onContinue = { NightProgress.next(saved).let { (c, l) -> startLevel(c, l) } },
|
||||
onChapters = { stage = NightStage.Chapters }, onHowTo = { howTo = true }, onBack = { latestPlay.onLeave() })
|
||||
if (howTo) HowToPlayCard(gameDef, firstRun = false, everyTime = null, onEveryTime = {}, onPlay = { howTo = false }, onBack = { howTo = false })
|
||||
}
|
||||
NightStage.Chapters -> NightChaptersPage(saved, chapter, onPlay = ::startLevel, onBack = { stage = NightStage.Title })
|
||||
NightStage.Play, NightStage.Complete -> {
|
||||
val keys = Modifier.focusRequester(focus).focusable().gameKeys(enabled = stage == NightStage.Play && !paused, pause = { paused = true }) { key, native ->
|
||||
if (native.action != KeyEvent.ACTION_DOWN) return@gameKeys key != ArcadeKey.Other
|
||||
val next = when (key) {
|
||||
ArcadeKey.Left -> game.hop(-1, 0)
|
||||
ArcadeKey.Right -> game.hop(1, 0)
|
||||
ArcadeKey.Up -> game.hop(0, -1)
|
||||
ArcadeKey.Down -> game.hop(0, 1)
|
||||
ArcadeKey.Ok -> if (native.repeatCount > 0) game else game.turn()
|
||||
else -> null
|
||||
}
|
||||
if (next != null) game = next
|
||||
next != null
|
||||
}
|
||||
NightPlay(game, chapter, levelIx, par, keys, still = Motion.reduce || play.reduceFlashing)
|
||||
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 = {
|
||||
val c = chapter; val l = levelIx
|
||||
if (l + 1 < NightChapters[c].levels.size) startLevel(c, l + 1)
|
||||
else if (c + 1 < NightChapters.size && NightProgress.open(saved, c + 1)) startLevel(c + 1, 0)
|
||||
else { chapter = c; stage = NightStage.Chapters }
|
||||
},
|
||||
onReplay = { startLevel(chapter, levelIx) }, onChapters = { stage = NightStage.Chapters })
|
||||
}
|
||||
if (paused && stage == NightStage.Play) ArcadePauseMenu(gameDef, "Chapter ${chapter + 1} · Level ${levelIx + 1} · ${game.moves} moves",
|
||||
onResume = { paused = false }, onRestart = { startLevel(chapter, levelIx) }, onExit = { latestPlay.onLeave() },
|
||||
extra = "Chapters" to { paused = false; stage = NightStage.Chapters })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Title (frame 40) ----------
|
||||
|
||||
@Composable
|
||||
private fun NightTitle(saved: Map<String, String>, refocus: Boolean, onContinue: () -> Unit, onChapters: () -> Unit, onHowTo: () -> Unit, onBack: () -> Unit) {
|
||||
val first = remember { FocusRequester() }
|
||||
LaunchedEffect(refocus) { if (refocus) runCatching { first.requestFocus() } }
|
||||
val (nc, nl) = NightProgress.next(saved)
|
||||
Box(Modifier.fillMaxSize().onBackKey(action = onBack)) {
|
||||
BackHandler(onBack = onBack)
|
||||
// The moon, a constellation or two, and Nite Owl on his mast sending the star home.
|
||||
Canvas(Modifier.fillMaxSize()) {
|
||||
val w = size.width; val h = size.height
|
||||
drawCircle(Color(0xFFD9D4FF).copy(alpha = .12f), h * .12f, Offset(w * .92f, h * .13f))
|
||||
drawCircle(Color(0xFFD9D4FF), h * .062f, Offset(w * .92f, h * .13f)); drawCircle(NightColours.Top, h * .055f, Offset(w * .935f, h * .115f))
|
||||
val c1 = listOf(.61f to .11f, .65f to .17f, .69f to .14f, .73f to .2f, .77f to .175f)
|
||||
for (i in 1 until c1.size) drawLine(NightColours.Muted.copy(alpha = .6f), Offset(w * c1[i - 1].first, h * c1[i - 1].second), Offset(w * c1[i].first, h * c1[i].second), 1.5f)
|
||||
c1.forEach { (x, y) -> drawCircle(Color.White, 3f, Offset(w * x, h * y)) }
|
||||
val mastTop = Offset(w * .395f, h * .6f); val mastFoot = h * .82f
|
||||
drawOval(Color(0xFF15164A), Offset(w * .21f, h * .79f), Size(w * .37f, h * .08f))
|
||||
mast(mastTop, mastFoot - mastTop.y, NightColours.Glow)
|
||||
val star = Offset(w * .15f, h * .48f)
|
||||
drawLine(NightColours.Glow.copy(alpha = .35f), star, mastTop - Offset(0f, h * .06f), 10f, StrokeCap.Round)
|
||||
drawLine(NightColours.Lit, star, mastTop - Offset(0f, h * .06f), 3f, StrokeCap.Round)
|
||||
drawCircle(NightColours.Star.copy(alpha = .25f), h * .05f, star)
|
||||
drawPath(starPath(star, h * .028f, h * .012f, 0f), NightColours.Star)
|
||||
drawNiteOwl(mastTop - Offset(0f, h * .1f), h * .1f, lid = .45f)
|
||||
}
|
||||
Column(Modifier.fillMaxSize().padding(start = 48.dp, end = 48.dp, top = 40.dp, bottom = 12.dp)) {
|
||||
Row(Modifier.fillMaxWidth().weight(1f)) {
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text("NITE OWL'S", color = NightColours.Muted, fontSize = 18.sp, letterSpacing = 6.sp)
|
||||
Text("NIGHT SHIFT", color = NightColours.Ink, fontFamily = Anton, fontSize = 64.sp)
|
||||
Text("A calm puzzle for the late shift. No timer, no rush.", color = NightColours.Muted, fontSize = 15.sp)
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text("CHAPTERS", color = NightColours.Muted, fontSize = 14.sp, letterSpacing = 3.sp)
|
||||
Row(Modifier.padding(vertical = 6.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
for (c in NightChapters.indices) {
|
||||
val open = NightProgress.open(saved, c); val done = NightProgress.done(saved, c) == NightChapters[c].levels.size
|
||||
Box(Modifier.size(28.dp).background(if (c == nc) Color(0xFF5865D8) else if (done) NightColours.Tile else NightColours.Panel, CircleShape)
|
||||
.border(1.dp, if (open) NightColours.Glow else NightColours.TileEdge, CircleShape), contentAlignment = Alignment.Center) {
|
||||
Text(if (open) "${c + 1}" else "🔒", color = NightColours.Ink, fontSize = if (open) 13.sp else 10.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
Text(chapterStatus(saved), color = NightColours.Muted, fontSize = 14.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
Column(Modifier.width(270.dp).align(Alignment.CenterVertically), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
ArcadeButton("Continue", Modifier.fillMaxWidth().focusRequester(first), icon = "▶", detail = "Ch ${nc + 1} · Level ${nl + 1}", primary = true, height = 34.dp, onClick = onContinue)
|
||||
ArcadeButton("Chapters", Modifier.fillMaxWidth(), icon = "☰", height = 34.dp, onClick = onChapters)
|
||||
ArcadeButton("How to Play", Modifier.fillMaxWidth(), icon = "?", height = 34.dp, onClick = onHowTo)
|
||||
ArcadeButton("Back to Arcade", Modifier.fillMaxWidth(), icon = "←", height = 34.dp, onClick = onBack)
|
||||
}
|
||||
}
|
||||
KeyFooter(listOf(Control("▲▼", "Choose"), Control("OK", "Select"), Control("Back", "Arcade home")))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** "First Light done · The Quiet Mast in progress" under the title's chapters. */
|
||||
internal fun chapterStatus(saved: Map<String, String>): String {
|
||||
val parts = ArrayList<String>()
|
||||
for (c in NightChapters.indices) {
|
||||
val done = NightProgress.done(saved, c)
|
||||
if (done == NightChapters[c].levels.size) parts += "${NightChapters[c].name} done"
|
||||
else if (done > 0 || (NightProgress.open(saved, c) && parts.isNotEmpty())) { parts += "${NightChapters[c].name} in progress"; break }
|
||||
else if (c == 0) { parts += "First Light awaits"; break }
|
||||
}
|
||||
return parts.takeLast(2).joinToString(" · ")
|
||||
}
|
||||
|
||||
/** The relay mast: a lattice tower, [top] its peak, [height] tall. */
|
||||
private fun DrawScope.mast(top: Offset, height: Float, colour: Color) {
|
||||
val half = height * .3f
|
||||
val l = Offset(top.x - half, top.y + height); val r = Offset(top.x + half, top.y + height)
|
||||
val stroke = maxOf(1.5f, height / 90f)
|
||||
drawLine(colour, top, l, stroke); drawLine(colour, top, r, stroke)
|
||||
for (k in 1..4) {
|
||||
val f = k / 4.5f; val g = (k - 1) / 4.5f
|
||||
val a = top + (l - top) * f; val b = top + (r - top) * f
|
||||
drawLine(colour, a, b, stroke)
|
||||
drawLine(colour, top + (l - top) * g, b, stroke); drawLine(colour, top + (r - top) * g, a, stroke)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Chapters (frame 43) ----------
|
||||
|
||||
@Composable
|
||||
private fun NightChaptersPage(saved: Map<String, String>, current: Int, onPlay: (Int, Int) -> Unit, onBack: () -> Unit) {
|
||||
var shown by remember { mutableIntStateOf(current) }
|
||||
val firstCard = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) { runCatching { firstCard.requestFocus() } }
|
||||
Box(Modifier.fillMaxSize().onBackKey(action = onBack)) {
|
||||
BackHandler(onBack = onBack)
|
||||
Column(Modifier.fillMaxSize().padding(start = 32.dp, end = 32.dp, top = 28.dp, bottom = 12.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text("NITE OWL'S NIGHT SHIFT", color = NightColours.Muted, fontSize = 14.sp, letterSpacing = 4.sp)
|
||||
Text("CHOOSE A CHAPTER", color = NightColours.Ink, fontFamily = Anton, fontSize = 34.sp)
|
||||
}
|
||||
Text("Pick up where\nwe left off?", Modifier.background(NightColours.Ink, RoundedCornerShape(12.dp)).padding(horizontal = 12.dp, vertical = 6.dp),
|
||||
color = NightColours.Top, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, textAlign = TextAlign.Center)
|
||||
Canvas(Modifier.size(64.dp)) { drawNiteOwl(center, size.minDimension * .4f, lid = .45f) }
|
||||
}
|
||||
Row(Modifier.fillMaxWidth().height(160.dp), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
for (c in NightChapters.indices) {
|
||||
val open = NightProgress.open(saved, c)
|
||||
var focused by remember { mutableStateOf(false) }
|
||||
val corner = RoundedCornerShape(10.dp)
|
||||
Column(Modifier.weight(1f).fillMaxHeight().then(if (c == current) Modifier.focusRequester(firstCard) else Modifier)
|
||||
.onFocusChanged { focused = it.isFocused; if (it.isFocused) shown = c }
|
||||
.background(if (focused) Color(0xFF3B3F9E) else NightColours.Panel, corner).border(if (focused) 3.dp else 1.dp, if (focused) ArcadeColours.Yellow else NightColours.TileEdge, corner)
|
||||
.clickable { if (open) onPlay(c, NightProgress.next(saved).let { (nc, nl) -> if (nc == c) nl else 0 }) }) {
|
||||
Canvas(Modifier.fillMaxWidth().height(56.dp)) {
|
||||
// The chapter's constellation (locked: faint, with a padlock).
|
||||
val pts = List(5) { k -> Offset(size.width * (.2f + k * .15f), size.height * (.4f + .25f * kotlin.math.sin(k * 1.7 + c).toFloat())) }
|
||||
for (k in 1 until pts.size) drawLine(NightColours.Muted.copy(alpha = if (open) .8f else .3f), pts[k - 1], pts[k], 1.5f)
|
||||
pts.forEach { drawCircle(Color.White.copy(alpha = if (open) 1f else .35f), 3.5f, it) }
|
||||
}
|
||||
Column(Modifier.padding(horizontal = 12.dp, vertical = 6.dp)) {
|
||||
Text("CHAPTER ${c + 1}", color = NightColours.Muted, fontSize = 13.sp, letterSpacing = 2.sp)
|
||||
Text(NightChapters[c].name.uppercase(), color = if (open) NightColours.Ink else NightColours.Muted, fontFamily = Anton, fontSize = 17.sp, maxLines = 2, lineHeight = 19.sp)
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text(if (open) "${NightProgress.done(saved, c)} of ${NightChapters[c].levels.size} levels" else "Opens after", color = NightColours.Ink, fontSize = 13.sp)
|
||||
Text(if (open) "${NightProgress.stars(saved, c)} of ${NightChapters[c].levels.size * 3} stars" else "Chapter $c", color = NightColours.Muted, fontSize = 13.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// The chosen chapter's levels: done, the next, and the rest still dark.
|
||||
Column(Modifier.fillMaxWidth().background(NightColours.Panel, RoundedCornerShape(12.dp)).border(1.dp, NightColours.TileEdge, RoundedCornerShape(12.dp)).padding(14.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
Row { Text("Chapter ${shown + 1}: ${NightChapters[shown].name}", color = NightColours.Ink, fontSize = 15.sp, fontWeight = FontWeight.SemiBold)
|
||||
Text(" ${NightProgress.done(saved, shown)} of ${NightChapters[shown].levels.size} levels · par is a guide, not a rule", color = NightColours.Muted, fontSize = 13.sp) }
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
for (l in NightChapters[shown].levels.indices) {
|
||||
val open = NightProgress.levelOpen(saved, shown, l); val best = NightProgress.best(saved, shown, l)
|
||||
var focused by remember(shown) { mutableStateOf(false) }
|
||||
Box(Modifier.size(38.dp).onFocusChanged { focused = it.isFocused }
|
||||
.background(if (focused) Color(0xFF5865D8) else if (best != null) NightColours.Tile else NightColours.Panel, CircleShape)
|
||||
.border(if (focused) 3.dp else 1.dp, if (focused) ArcadeColours.Yellow else if (open) NightColours.Glow else NightColours.TileEdge, CircleShape)
|
||||
.clickable(enabled = open) { onPlay(shown, l) }, contentAlignment = Alignment.Center) {
|
||||
Text("${l + 1}", color = if (open) NightColours.Ink else NightColours.Muted, fontSize = 14.sp, fontWeight = FontWeight.SemiBold)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.weight(1f))
|
||||
KeyFooter(listOf(Control("◀▶", "Choose a chapter"), Control("▼", "Levels"), Control("OK", "Play"), Control("Back", "Title")))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Play (frame 41) ----------
|
||||
|
||||
@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) {
|
||||
val on = remember(game) { game.lit() }
|
||||
val clouds = remember(game) { game.cloudTiles() }
|
||||
val nextClouds = remember(game) { game.cloudTiles(game.hops + 1) }
|
||||
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)) {
|
||||
Text("CHAPTER ${chapter + 1} · LEVEL ${level + 1}", color = NightColours.Muted, fontSize = 14.sp, letterSpacing = 2.sp, maxLines = 1)
|
||||
Text(NightChapters[chapter].name.uppercase(), color = NightColours.Ink, fontFamily = Anton, fontSize = 22.sp, maxLines = 2, lineHeight = 24.sp)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(18.dp)) {
|
||||
Column { Text("MOVES", color = NightColours.Muted, fontSize = 14.sp, letterSpacing = 2.sp); Text("${game.moves}", color = NightColours.Ink, fontFamily = Anton, fontSize = 30.sp) }
|
||||
Column { Text("OWL'S PAR", color = NightColours.Muted, fontSize = 14.sp, letterSpacing = 2.sp); Text("$par", color = Color(0xFFC9C3FF), fontFamily = Anton, fontSize = 30.sp) }
|
||||
}
|
||||
Spacer(Modifier.height(6.dp))
|
||||
Text("STARS", color = NightColours.Muted, fontSize = 14.sp, letterSpacing = 2.sp)
|
||||
val s = nightStars(game.moves, par)
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Canvas(Modifier.size(84.dp, 24.dp)) { for (k in 0 until 3) { val c = Offset(12f + k * 28.dp.toPx() * .95f, size.height / 2); if (k < s) drawPath(starPath(c, 10.dp.toPx(), 4.dp.toPx(), 0f), NightColours.Star) else drawPath(starPath(c, 10.dp.toPx(), 4.dp.toPx(), 0f), NightColours.Muted, style = Stroke(1.5f)) } }
|
||||
Text("if you finish now", color = NightColours.Muted, fontSize = 13.sp)
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text("No timer. Take your time.", color = NightColours.Muted, fontSize = 15.sp)
|
||||
if (game.level.clouds.isNotEmpty()) Text("Clouds drift a tile each hop and hide the light.", color = NightColours.Muted, fontSize = 14.sp)
|
||||
}
|
||||
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) }
|
||||
}
|
||||
Column(Modifier.width(110.dp).fillMaxHeight(), horizontalAlignment = Alignment.End) {
|
||||
Spacer(Modifier.weight(1f))
|
||||
// Luna in her Night Cap keeps Nite Owl company.
|
||||
Canvas(Modifier.size(80.dp)) { drawNightCap(center + Offset(0f, size.height * .08f), size.minDimension * .34f) }
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(6.dp))
|
||||
KeyFooter(listOf(Control("◀▶▲▼", "Hop"), Control("OK", "Turn the beam"), Control("Back", "Pause")))
|
||||
}
|
||||
}
|
||||
|
||||
/** 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) {
|
||||
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
|
||||
for (i in 0 until NW * NH) {
|
||||
val x = ox + i % NW * cell; val y = oy + i / NW * cell
|
||||
drawRoundRect(NightColours.Tile.copy(alpha = .8f), Offset(x + pad, y + pad), Size(cell - 2 * pad, cell - 2 * pad), CornerRadius(cell * .14f))
|
||||
// Where a cloud goes next: a dashed outline, so a hop is never a surprise.
|
||||
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))))
|
||||
val c = Offset(x + cell / 2, y + cell / 2)
|
||||
val p = game.piece(i)
|
||||
when (p) {
|
||||
'S' -> {
|
||||
val dirs = sides(p, game.turns[i])
|
||||
beam(c, dirs, cell, NightColours.Lit, true)
|
||||
drawCircle(NightColours.Star.copy(alpha = .28f), cell * .36f, c)
|
||||
drawPath(starPath(c, cell * .26f, cell * .11f, 0f), NightColours.Star)
|
||||
}
|
||||
'M' -> mast(Offset(c.x, c.y - cell * .34f), cell * .66f, if (on[i]) NightColours.Lit else NightColours.Glow.copy(alpha = .7f))
|
||||
'.' -> if ((i * 7) % 5 == 0) drawCircle(Color.White.copy(alpha = .25f), 1.6f, Offset(x + cell * .3f, y + cell * .3f))
|
||||
else -> beam(c, sides(p, game.turns[i]), cell, if (on[i]) NightColours.Lit else NightColours.Beam, on[i])
|
||||
}
|
||||
}
|
||||
// Clouds: soft puffs over their tiles.
|
||||
for (t in clouds) {
|
||||
val c = Offset(ox + t % NW * cell + cell / 2, oy + t / NW * cell + cell / 2)
|
||||
val cloud = Color(0xFFB8B4E6).copy(alpha = .85f)
|
||||
drawCircle(cloud, cell * .2f, c + Offset(-cell * .14f, cell * .04f)); drawCircle(cloud, cell * .24f, c + Offset(cell * .04f, -cell * .04f))
|
||||
drawCircle(cloud, cell * .18f, c + Offset(cell * .2f, cell * .06f)); drawRect(cloud, c + Offset(-cell * .3f, cell * .04f), Size(cell * .6f, cell * .16f))
|
||||
}
|
||||
// Nite Owl on his tile, ringed, with the turn sign when there's a piece to turn.
|
||||
val o = Offset(ox + game.owl % NW * cell + cell / 2, oy + game.owl / NW * cell + cell / 2)
|
||||
drawRoundRect(NightColours.Ink.copy(alpha = .9f), Offset(o.x - cell / 2 + pad, o.y - cell / 2 + pad), Size(cell - 2 * pad, cell - 2 * pad), CornerRadius(cell * .14f), style = Stroke(2.5f))
|
||||
drawNiteOwl(o, cell * .34f, lid = .45f)
|
||||
if (turnable(game.piece(game.owl))) {
|
||||
val b = Offset(o.x + cell * .3f, o.y + cell * .3f)
|
||||
drawCircle(NightColours.Top, cell * .13f, b); drawCircle(NightColours.Ink, cell * .13f, b, style = Stroke(2f))
|
||||
drawArc(NightColours.Ink, -60f, 270f, false, Offset(b.x - cell * .07f, b.y - cell * .07f), Size(cell * .14f, cell * .14f), style = Stroke(2f))
|
||||
}
|
||||
}
|
||||
|
||||
/** A beam piece: a pipe from the centre to each of its sides, with a node in the middle; lit, it glows. */
|
||||
private fun DrawScope.beam(c: Offset, dirs: Int, cell: Float, colour: Color, lit: Boolean) {
|
||||
val reach = cell * .5f
|
||||
val ends = arrayOf(Offset(0f, -reach), Offset(reach, 0f), Offset(0f, reach), Offset(-reach, 0f))
|
||||
for (k in 0..3) if (dirs and (1 shl k) != 0) {
|
||||
if (lit) drawLine(NightColours.Glow.copy(alpha = .35f), c, c + ends[k], cell * .16f, StrokeCap.Round)
|
||||
drawLine(colour, c, c + ends[k], cell * .07f, StrokeCap.Round)
|
||||
}
|
||||
drawCircle(if (lit) NightColours.Glow else NightColours.Beam, cell * .11f, c)
|
||||
drawCircle(colour, cell * .11f, c, style = Stroke(cell * .03f))
|
||||
}
|
||||
|
||||
// ---------- Level complete (frame 42) ----------
|
||||
|
||||
@Composable
|
||||
private fun NightComplete(chapter: Int, level: Int, stars: Int, moves: Int, par: Int, last: Boolean, onNext: () -> Unit, onReplay: () -> Unit, onChapters: () -> Unit) {
|
||||
val first = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) { runCatching { first.requestFocus() } }
|
||||
BackHandler(onBack = onChapters)
|
||||
Box(Modifier.fillMaxSize().onBackKey(action = onChapters).background(NightColours.Top.copy(alpha = .8f)), contentAlignment = Alignment.Center) {
|
||||
Row(Modifier.width(600.dp).background(NightColours.Panel, RoundedCornerShape(16.dp)).border(1.dp, NightColours.TileEdge, RoundedCornerShape(16.dp)).padding(22.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||
Canvas(Modifier.size(110.dp)) { drawNiteOwl(center, size.minDimension * .4f, lid = if (stars == 3) 0f else .25f, glance = .3f) }
|
||||
Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Text("CHAPTER ${chapter + 1} · LEVEL ${level + 1} COMPLETE", color = NightColours.Muted, fontSize = 13.sp, letterSpacing = 2.sp)
|
||||
Text(NightChapters[chapter].name.uppercase(), color = NightColours.Ink, fontFamily = Anton, fontSize = 30.sp)
|
||||
Text(owlLine(stars), Modifier.background(NightColours.Ink, RoundedCornerShape(12.dp)).padding(horizontal = 12.dp, vertical = 6.dp),
|
||||
color = NightColours.Top, fontSize = 15.sp, fontWeight = FontWeight.SemiBold)
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Canvas(Modifier.size(96.dp, 30.dp)) { for (k in 0 until 3) { val c = Offset(15.dp.toPx() + k * 32.dp.toPx(), size.height / 2); if (k < stars) drawPath(starPath(c, 13.dp.toPx(), 5.dp.toPx(), 0f), NightColours.Star) else drawPath(starPath(c, 13.dp.toPx(), 5.dp.toPx(), 0f), NightColours.Muted, style = Stroke(2f)) } }
|
||||
Text("$stars of 3 stars", color = NightColours.Ink, fontSize = 15.sp, fontWeight = FontWeight.SemiBold)
|
||||
}
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(18.dp), verticalAlignment = Alignment.Bottom) {
|
||||
Text("MOVES", color = NightColours.Muted, fontSize = 14.sp, letterSpacing = 2.sp); Text("$moves", color = NightColours.Ink, fontFamily = Anton, fontSize = 26.sp)
|
||||
Text("OWL'S PAR", color = NightColours.Muted, fontSize = 14.sp, letterSpacing = 2.sp); Text("$par", color = Color(0xFFC9C3FF), fontFamily = Anton, fontSize = 26.sp)
|
||||
}
|
||||
Text(parLine(moves, par), color = NightColours.Muted, fontSize = 14.sp)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
ArcadeButton(if (last) "Chapters" else "Next Level", Modifier.width(150.dp).focusRequester(first), icon = "▶", primary = true, height = 34.dp, onClick = if (last) onChapters else onNext)
|
||||
ArcadeButton("Replay", Modifier.width(120.dp), icon = "↻", height = 34.dp, onClick = onReplay)
|
||||
if (!last) ArcadeButton("Chapters", Modifier.width(140.dp), icon = "☰", height = 34.dp, onClick = onChapters)
|
||||
}
|
||||
}
|
||||
}
|
||||
KeyFooter(listOf(Control("◀▶", "Choose"), Control("OK", "Select"), Control("Back", "Chapters")), Modifier.align(Alignment.BottomStart).padding(start = 24.dp, end = 24.dp, bottom = 10.dp))
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,6 @@ class ArcadeSessionTest {
|
||||
assertTrue(resetAllowed(ResetAction.ResetLevelProgress, sky, "p", "p", false))
|
||||
assertTrue(resetAllowed(ResetAction.ResetLevelProgress, hive, "p", "p", false))
|
||||
// A coming-soon card has nothing to clear.
|
||||
assertFalse(resetAllowed(ResetAction.ClearHighScores, ArcadeGames.NightShift, "p", "p", false))
|
||||
assertFalse(resetAllowed(ResetAction.ClearHighScores, ArcadeGames.Orbiteroids, "p", "p", false))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,21 +57,21 @@ class KidsArcadeTest {
|
||||
}
|
||||
|
||||
@Test fun pickRecentAndHighScoresFollowTheFilter() {
|
||||
val chosen = kids.withKidsArcade(KidsArcade.Chosen, setOf("Pairs", "Snake", "NightShift"))
|
||||
val chosen = kids.withKidsArcade(KidsArcade.Chosen, setOf("Pairs", "Snake", "Orbiteroids"))
|
||||
val visible = arcadeVisible(chosen)
|
||||
// Star Chase isn't chosen, so it can't be the pick.
|
||||
assertEquals("Snake", arcadePick(visible)!!.id)
|
||||
assertEquals("OrbMan", arcadePick(arcadeVisible(grown))!!.id)
|
||||
// Recent keeps only games this profile can still see and play.
|
||||
assertEquals(listOf("Pairs", "Snake"), recentVisible(listOf("Blast", "Pairs", "NightShift", "Snake", "Gone"), visible).map { it.id })
|
||||
assertEquals(listOf("Pairs", "Snake"), recentVisible(listOf("Blast", "Pairs", "Orbiteroids", "Snake", "Gone"), visible).map { it.id })
|
||||
assertNull(arcadePick(emptyList()))
|
||||
}
|
||||
|
||||
@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: 9 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.KidsSuitable)))
|
||||
assertEquals("Chosen games: 2 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Chosen, setOf("Pairs", "Sky", "NightShift"))))
|
||||
assertEquals("Kids-suitable games: 10 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.KidsSuitable)))
|
||||
assertEquals("Chosen games: 2 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Chosen, setOf("Pairs", "Sky", "Orbiteroids"))))
|
||||
assertEquals("Chosen games: none chosen yet, so no Arcade", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Chosen, emptySet())))
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class KidsArcadeTest {
|
||||
assertEquals(ArcadeGames.all.size, ArcadeGames.all.map { it.id }.toSet().size)
|
||||
assertEquals(5, ArcadeGames.originals.size); assertEquals(8, ArcadeGames.classics.size)
|
||||
// BumbleHive and (Stage D) Orbi-Raiders are the Originals that play; every Classic does.
|
||||
assertEquals(listOf("OrbiRaiders", "ChannelChaos", "Hive"), ArcadeGames.originals.filter { it.launchable }.map { it.id })
|
||||
assertEquals(listOf("OrbiRaiders", "ChannelChaos", "Hive", "NightShift"), 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())
|
||||
|
||||
@@ -104,4 +104,27 @@ class TitleTextFitsTest {
|
||||
assertTrue("$label is ${"%.0f".format(w)} dp in $column", w <= column - 2 * 12 - 4)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun nightShiftsWordsFit() {
|
||||
val anton = Font.createFont(Font.TRUETYPE_FONT, File("src/main/res/font/anton_regular.ttf"))
|
||||
// Each chapter card is a fifth of the row (896 dp less four 10 dp gaps), less 24 dp padding: every word of a name fits a line, at most two lines.
|
||||
val card = (896.0 - 40) / 5 - 24
|
||||
for (ch in tv.orbit.classic.arcade.nightshift.NightChapters) {
|
||||
val name = ch.name.uppercase(); val f = anton.deriveFont(17f * 1.3f)
|
||||
assertTrue("$name: a word is too wide", name.split(' ').all { width(f, it) <= card })
|
||||
var lines = 1; var line = 0.0
|
||||
for (w in name.split(' ')) { val ww = width(f, "$w "); if (line + ww > card) { lines++; line = ww } else line += ww }
|
||||
assertTrue("$name takes $lines lines", lines <= 2)
|
||||
}
|
||||
// The title and the HUD's chapter name.
|
||||
assertTrue(width(anton.deriveFont(64f), "NIGHT SHIFT") <= 960.0 - 96 - 270 - 16)
|
||||
val sans = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
for ((label, column) in listOf("▶ Next Level" to 150, "↻ Replay" to 120, "☰ Chapters" to 140, "☰ Chapters" to 230))
|
||||
assertTrue("$label in $column", width(sans, label) <= column - 2 * 12 - 4)
|
||||
// Continue carries where it goes on the right of the title's 230 dp button.
|
||||
val detail = Font(Font.SANS_SERIF, Font.PLAIN, 1).deriveFont(12f * 1.3f)
|
||||
assertTrue(width(sans, "▶ Continue") + 8 + width(detail, "Ch 5 · Level 12") <= 270 - 2 * 12 - 4)
|
||||
// The level-complete panel's three buttons fit beside Nite Owl.
|
||||
assertTrue(150 + 120 + 140 + 2 * 10 <= 600 - 44 - 110 - 16)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package tv.orbit.classic.arcade.nightshift
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import tv.orbit.classic.arcade.Difficulty
|
||||
|
||||
/** Night Shift's sixty levels: well formed, not solved at the start, and each one played through by a bot within Owl's par. */
|
||||
class NightShiftLevelsTest {
|
||||
private fun solutionTurns(level: NightLevel, i: Int) = level.solution[i / NW][i % NW * 2 + 1] - '0'
|
||||
|
||||
/**
|
||||
* The bot: hops Nite Owl to each piece that isn't turned the solution's way and turns it until it is (a straight
|
||||
* matches either way round), then hops on the spot until the clouds are clear of the light. Turns only count as moves.
|
||||
*/
|
||||
private fun bot(level: NightLevel): NightGame {
|
||||
var g = NightGame(level)
|
||||
// Only the pieces the solution's light runs through need to be right (the decoys can stay as they are).
|
||||
val solved = NightGame(NightLevel(level.solution, level.solution, level.par, emptyList())).lit()
|
||||
for (i in 0 until NW * NH) {
|
||||
val p = level.piece(i); if (!turnable(p) || !solved[i]) continue
|
||||
val target = solutionTurns(level, i)
|
||||
while (sides(p, g.turns[i]) != sides(p, target)) {
|
||||
while (g.owl != i) g = g.hop(Integer.signum(i % NW - g.owl % NW), if (i % NW == g.owl % NW) Integer.signum(i / NW - g.owl / NW) else 0)
|
||||
if (sides(p, g.turns[i]) != sides(p, target)) g = g.turn()
|
||||
}
|
||||
if (g.won) return g
|
||||
}
|
||||
var tries = 0
|
||||
while (!g.won && tries++ < 200) g = g.hop(if (g.owl % NW == 0) 1 else -1, 0)
|
||||
return g
|
||||
}
|
||||
|
||||
@Test fun fiveChaptersOfTwelveEachWellFormed() {
|
||||
assertEquals(listOf("First Light", "The Quiet Mast", "Cloudbank", "Northern Relay", "Last Light Before Dawn"), NightChapters.map { it.name })
|
||||
for ((c, ch) in NightChapters.withIndex()) {
|
||||
assertEquals(12, ch.levels.size)
|
||||
for ((l, lv) in ch.levels.withIndex()) {
|
||||
assertEquals(NH, lv.rows.size); assertTrue(lv.rows.all { it.length == NW * 2 })
|
||||
val all = (0 until NW * NH).map { lv.piece(it) }
|
||||
assertEquals("${c + 1}.${l + 1} star", 1, all.count { it == 'S' })
|
||||
assertTrue(all.count { it == 'M' } >= 1)
|
||||
assertFalse("${c + 1}.${l + 1} starts solved", NightGame(lv).won)
|
||||
// Clouds only from Cloudbank; a second mast from the Northern Relay.
|
||||
if (c < 2) assertTrue(lv.clouds.isEmpty())
|
||||
if (c >= 3) assertEquals(2, all.count { it == 'M' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun aBotLightsEveryMastWithinOwlsParOnEveryDifficulty() {
|
||||
val failed = ArrayList<String>()
|
||||
for ((c, ch) in NightChapters.withIndex()) for ((l, lv) in ch.levels.withIndex()) {
|
||||
val g = bot(lv)
|
||||
if (!g.won) failed += "${c + 1}.${l + 1} not lit"
|
||||
else for (d in Difficulty.entries) if (g.moves > nightPar(lv, d)) failed += "${c + 1}.${l + 1} ${g.moves} moves, par ${nightPar(lv, d)} on $d"
|
||||
}
|
||||
assertTrue("$failed", failed.isEmpty())
|
||||
}
|
||||
|
||||
@Test fun owlTurnsOnlyBeamPiecesAndHopsStayOnTheBoard() {
|
||||
val lv = NightChapters[0].levels[0]
|
||||
val g = NightGame(lv)
|
||||
val star = (0 until NW * NH).first { lv.piece(it) == 'S' }
|
||||
val onStar = NightGame(lv, owl = star)
|
||||
assertSame(onStar, onStar.turn())
|
||||
var edge = g; repeat(20) { edge = edge.hop(-1, 0) }
|
||||
assertEquals(0, edge.owl % NW); assertEquals(0, edge.moves)
|
||||
}
|
||||
|
||||
@Test fun cloudsDriftAlongTheirLanesAndBack() {
|
||||
val lane = listOf(1 to 2, 2 to 2, 3 to 2)
|
||||
assertEquals(listOf(15, 16, 17, 16, 15, 16), (0..5).map { cloudAt(lane, it) })
|
||||
}
|
||||
|
||||
@Test fun starsAndParAreKind() {
|
||||
assertEquals(3, nightStars(18, 18)); assertEquals(2, nightStars(21, 18)); assertEquals(1, nightStars(40, 18))
|
||||
assertEquals("Took the scenic route, did we?", owlLine(2))
|
||||
assertEquals("Three over par. The stars don't mind.", parLine(21, 18))
|
||||
val lv = NightChapters[1].levels[3]
|
||||
assertEquals(lv.par + 3, nightPar(lv, Difficulty.Gentle))
|
||||
}
|
||||
|
||||
@Test fun progressOpensLevelsAndChaptersInTurn() {
|
||||
var saved = emptyMap<String, String>()
|
||||
assertEquals(0 to 0, NightProgress.next(saved))
|
||||
assertTrue(NightProgress.levelOpen(saved, 0, 0)); assertFalse(NightProgress.levelOpen(saved, 0, 1)); assertFalse(NightProgress.open(saved, 1))
|
||||
for (l in 0 until 12) saved = saved + (NightProgress.key(0, l) to NightProgress.value(2, 20))
|
||||
assertTrue(NightProgress.open(saved, 1)); assertEquals(1 to 0, NightProgress.next(saved))
|
||||
assertEquals(24, NightProgress.totalStars(saved)); assertEquals("First Light done · The Quiet Mast in progress", chapterStatus(saved))
|
||||
assertTrue(NightProgress.better(2 to 20, 3, 30)); assertTrue(NightProgress.better(2 to 20, 2, 19)); assertFalse(NightProgress.better(2 to 20, 2, 25))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
"""Night Shift's levels (9 November 2026). Each level is laid by hand-tuned rules per chapter, then checked: the stored
|
||||
solution lights every mast with no cloud in the way at some cloud step, and the scrambled start isn't already solved.
|
||||
Writes NightLevels.kt. Run: python3 make_levels.py <out.kt>"""
|
||||
import random, sys
|
||||
W, H = 7, 5
|
||||
N, E, S, Wd = 1, 2, 4, 8
|
||||
DIRS = {N: (0, -1), E: (1, 0), S: (0, 1), Wd: (-1, 0)}
|
||||
OPP = {N: S, S: N, E: Wd, Wd: E}
|
||||
BASE = {'I': N | S, 'L': N | E, 'T': N | E | S, 'X': 15, 'S': N}
|
||||
def rot(mask, r):
|
||||
for _ in range(r % 4):
|
||||
mask = ((mask << 1) | (mask >> 3)) & 15
|
||||
return mask
|
||||
def conns(t, r): return 15 if t == 'M' else (0 if t == '.' else rot(BASE[t], r))
|
||||
def rot_for(t, want):
|
||||
return [r for r in range(4) if rot(BASE[t], r) == want]
|
||||
|
||||
def lit(grid, clouds_at):
|
||||
"""Tiles the light reaches: from the star along its beam, through pieces whose sides match; clouds block."""
|
||||
sx, sy = next((x, y) for y in range(H) for x in range(W) if grid[y][x][0] == 'S')
|
||||
seen = {(sx, sy)}; todo = [(sx, sy)]
|
||||
while todo:
|
||||
x, y = todo.pop(); t, r = grid[y][x]
|
||||
for d in (N, E, S, Wd):
|
||||
if not conns(t, r) & d: continue
|
||||
nx, ny = x + DIRS[d][0], y + DIRS[d][1]
|
||||
if not (0 <= nx < W and 0 <= ny < H) or (nx, ny) in seen or (nx, ny) in clouds_at: continue
|
||||
nt, nr = grid[ny][nx]
|
||||
if nt == '.' or not conns(nt, nr) & OPP[d]: continue
|
||||
seen.add((nx, ny)); todo.append((nx, ny))
|
||||
return seen
|
||||
|
||||
def cloud_phases(lanes):
|
||||
n = 1
|
||||
for l in lanes: n = n * (2 * len(l) - 2) if len(l) > 1 else n
|
||||
out = []
|
||||
for k in range(max(n, 1)):
|
||||
at = set()
|
||||
for l in lanes:
|
||||
p = 2 * len(l) - 2; i = k % p if p else 0
|
||||
at.add(l[i] if i < len(l) else l[p - i])
|
||||
out.append(at)
|
||||
return out
|
||||
|
||||
def solved(grid, lanes):
|
||||
masts = [(x, y) for y in range(H) for x in range(W) if grid[y][x][0] == 'M']
|
||||
return any(all(m in lit(grid, c) for m in masts) for c in cloud_phases(lanes))
|
||||
|
||||
def walk(rng, start, goal, min_len, avoid, max_extra=4):
|
||||
"""A path from start to goal at least min_len tiles between them and not much longer: it leans towards the goal,
|
||||
wandering more as the chapters go on."""
|
||||
for _ in range(4000):
|
||||
path = [start]; seen = {start}
|
||||
while path[-1] != goal and len(path) < min_len + max_extra + 2:
|
||||
x, y = path[-1]
|
||||
opts = [(x + dx, y + dy) for dx, dy in DIRS.values() if 0 <= x + dx < W and 0 <= y + dy < H and (x + dx, y + dy) not in seen and (x + dx, y + dy) not in avoid]
|
||||
if not opts: break
|
||||
if len(path) - 1 >= min_len and goal in opts: nxt = goal
|
||||
else:
|
||||
opts = [o for o in opts if o != goal] or opts
|
||||
closer = [o for o in opts if abs(o[0] - goal[0]) + abs(o[1] - goal[1]) < abs(x - goal[0]) + abs(y - goal[1])]
|
||||
nxt = rng.choice(closer) if closer and rng.random() < .55 else rng.choice(opts)
|
||||
path.append(nxt); seen.add(nxt)
|
||||
if path[-1] == goal and min_len <= len(path) - 2 <= min_len + max_extra:
|
||||
return path
|
||||
return None
|
||||
|
||||
def dir_of(a, b):
|
||||
for d, (dx, dy) in DIRS.items():
|
||||
if (a[0] + dx, a[1] + dy) == b: return d
|
||||
|
||||
def make(chapter, level, rng):
|
||||
for attempt in range(500):
|
||||
grid = [[('.', 0) for _ in range(W)] for _ in range(H)]
|
||||
# Star on the left, mast on the right (two masts in the Northern Relay and after).
|
||||
star = (0, rng.randrange(H)); mast = (W - 1, rng.randrange(H))
|
||||
min_len = [5, 6, 7, 7, 8][chapter] + level // 4
|
||||
path = walk(rng, star, mast, min_len, set())
|
||||
if not path: continue
|
||||
sol = {}
|
||||
sol[star] = ('S', rot_for('S', dir_of(star, path[1]))[0])
|
||||
for i in range(1, len(path) - 1):
|
||||
want = OPP[dir_of(path[i - 1], path[i])] | dir_of(path[i], path[i + 1])
|
||||
t = 'I' if want in (N | S, E | Wd) else 'L'
|
||||
sol[path[i]] = (t, rot_for(t, want)[0])
|
||||
sol[mast] = ('M', 0)
|
||||
masts = [mast]
|
||||
if chapter >= 3:
|
||||
# A second mast, fed by a tee on the path.
|
||||
ok = False
|
||||
for _ in range(60):
|
||||
i = rng.randrange(2, len(path) - 2); p = path[i]
|
||||
for d in (N, S, E, Wd):
|
||||
q = (p[0] + DIRS[d][0], p[1] + DIRS[d][1])
|
||||
if not (0 <= q[0] < W and 0 <= q[1] < H) or q in sol: continue
|
||||
branch = walk(rng, q, (q[0], q[1]), 0, set())
|
||||
# the second mast right beside the tee, or two steps on in a straight line
|
||||
q2 = (q[0] + DIRS[d][0], q[1] + DIRS[d][1])
|
||||
t_want = OPP[dir_of(path[i - 1], p)] | dir_of(p, path[i + 1]) | d
|
||||
rs = rot_for('T', t_want)
|
||||
if not rs: continue
|
||||
if 0 <= q2[0] < W and 0 <= q2[1] < H and q2 not in sol and rng.random() < .6:
|
||||
sol[p] = ('T', rs[0]); sol[q] = ('I', rot_for('I', d | OPP[d])[0]); sol[q2] = ('M', 0); masts.append(q2)
|
||||
else:
|
||||
sol[p] = ('T', rs[0]); sol[q] = ('M', 0); masts.append(q)
|
||||
ok = True; break
|
||||
if ok: break
|
||||
if not ok: continue
|
||||
for (x, y), v in sol.items(): grid[y][x] = v
|
||||
# Decoys: more pieces on empty tiles as the chapters go on.
|
||||
empties = [(x, y) for y in range(H) for x in range(W) if grid[y][x][0] == '.']
|
||||
rng.shuffle(empties)
|
||||
for (x, y) in empties[: [2, 5, 6, 7, 9][chapter] + level // 3]:
|
||||
grid[y][x] = (rng.choice('IILLT' if chapter >= 1 else 'IL'), rng.randrange(4))
|
||||
# Clouds from Cloudbank on: one or two lanes across the path, ping-ponging a tile a hop.
|
||||
lanes = []
|
||||
if chapter >= 2:
|
||||
for k in range(1 if chapter == 2 and level < 6 else 2):
|
||||
for _ in range(50):
|
||||
p = rng.choice(path[1:-1])
|
||||
if rng.random() < .5:
|
||||
x0 = max(0, p[0] - rng.randrange(1, 3)); lane = [(x, p[1]) for x in range(x0, min(W, x0 + 3 + rng.randrange(2)))]
|
||||
else:
|
||||
y0 = max(0, p[1] - rng.randrange(1, 3)); lane = [(p[0], y) for y in range(y0, min(H, y0 + 3))]
|
||||
if len(lane) >= 3 and not any(c in masts or grid[c[1]][c[0]][0] == 'S' for c in lane) and not any(set(lane) & set(l) for l in lanes):
|
||||
lanes.append(lane); break
|
||||
solution = [row[:] for row in grid]
|
||||
if not solved(solution, lanes): continue
|
||||
# Scramble every turnable piece; the start mustn't already be solved.
|
||||
# The first levels turn only some of the path's pieces out of place, to learn on.
|
||||
keep = .6 if chapter == 0 and level < 4 else 0
|
||||
start = [[(t, r if (t in 'ILT' and (x, y) in sol and rng.random() < keep) else ((r + rng.randrange(1, 4)) % 4 if t in 'ILT' else r)) for x, (t, r) in enumerate(row)] for y, row in enumerate(grid)]
|
||||
if solved(start, lanes): continue
|
||||
# Owl's par: the fewest turns that reach the stored solution (a straight is the same both ways round).
|
||||
turns = 0
|
||||
lit_solution = lit(solution, set())
|
||||
for y in range(H):
|
||||
for x in range(W):
|
||||
t, r0 = start[y][x]; t2, r1 = solution[y][x]
|
||||
if (x, y) in lit_solution and t in 'ILT':
|
||||
period = 2 if t == 'I' else 4
|
||||
turns += (r1 - r0) % period
|
||||
par = turns + [2, 2, 3, 3, 4][chapter]
|
||||
return start, solution, lanes, par
|
||||
raise SystemExit(f"couldn't make chapter {chapter + 1} level {level + 1}")
|
||||
|
||||
def enc(grid): return ['"' + ''.join(t + str(r) for t, r in row) + '"' for row in grid]
|
||||
|
||||
rng = random.Random(9_112_026)
|
||||
chapters = ["First Light", "The Quiet Mast", "Cloudbank", "Northern Relay", "Last Light Before Dawn"]
|
||||
out = ['package tv.orbit.classic.arcade.nightshift', '', '// Generated by design/night-shift/make_levels.py (9 November 2026): five chapters of twelve, each checked solvable there',
|
||||
'// and again by NightShiftLevelsTest. Each row is 7 tiles of two characters: the piece (. empty, S star, M mast, I straight,',
|
||||
'// L corner, T tee) and its quarter turns. Clouds: each lane\'s tiles, a cloud moving one along it (and back) a hop.', '',
|
||||
'internal val NightChapters: List<NightChapter> = listOf(']
|
||||
for c, name in enumerate(chapters):
|
||||
out.append(f' NightChapter("{name}", listOf(')
|
||||
for l in range(12):
|
||||
start, solution, lanes, par = make(c, l, rng)
|
||||
lane_txt = 'listOf(' + ', '.join('listOf(' + ', '.join(f'{x} to {y}' for x, y in lane) + ')' for lane in lanes) + ')'
|
||||
out.append(f' NightLevel(listOf({", ".join(enc(start))}),')
|
||||
out.append(f' solution = listOf({", ".join(enc(solution))}),')
|
||||
out.append(f' par = {par}, clouds = {lane_txt}),')
|
||||
out.append(' )),')
|
||||
out.append(')')
|
||||
open(sys.argv[1], 'w').write('\n'.join(out) + '\n')
|
||||
print('ok')
|
||||
@@ -0,0 +1,93 @@
|
||||
# Nite Owl's Night Shift (0.115.0, versionCode 305, 9 November 2026)
|
||||
|
||||
Branch `classics-modes`, on top of 0.114.0. The fourth Orbit Original, from the approved Stage B frames 40 to 43
|
||||
(`orbit-tv/design/arcade/stage-b/night-shift.figcraft` and its PNGs). Not installed; nothing seen running.
|
||||
|
||||
## The game
|
||||
|
||||
A calm puzzle for the late shift: no timer, no fail.
|
||||
|
||||
- **The board.** A 7×5 night sky. Nite Owl hops tile to tile with the arrows, and OK turns the beam piece under him a
|
||||
quarter turn. The pieces are straights, corners and tees.
|
||||
- **The goal.** Route the lost star's light to the relay mast. The light runs from the star through every piece whose
|
||||
sides meet, and the pieces it reaches glow. When every mast is lit, the level's done.
|
||||
- **Moves.** Turns count as moves; hops don't. Owl's par is the fewest turns that light the mast, plus a little room (a
|
||||
little more on Gentle, one less on Tricky). Three stars on par or under, two a little over, one however long it takes.
|
||||
- **Clouds** (from Cloudbank on) drift one tile along their lane per hop, there and back, and block the light where they
|
||||
sit. Their next tiles are outlined, so a hop is never a surprise.
|
||||
- **Five chapters of twelve:** First Light, The Quiet Mast, Cloudbank, Northern Relay (two masts, fed by a tee) and Last
|
||||
Light Before Dawn.
|
||||
- Levels open one after another, and a chapter opens when the one before it is finished.
|
||||
- The first levels turn only some pieces out of place, to learn on.
|
||||
- **The cast.** Nite Owl and Luna in her Night Cap use their existing art, unchanged.
|
||||
|
||||
## Screens
|
||||
|
||||
- **Title (40):**
|
||||
- The moon, a constellation, and Nite Owl on his mast sending the star home.
|
||||
- The chapter dots and a line on how far you've got.
|
||||
- Continue (with where it goes), Chapters, How to Play, Back to Arcade.
|
||||
- There's no Mode button: Night Shift has one mode, its chapters.
|
||||
- **Play (41):**
|
||||
- The chapter and level, Moves and Owl's par, the stars you'd get if you finished now, and "No timer. Take your time."
|
||||
- Luna in her Night Cap keeps him company.
|
||||
- Footer: ◀▶▲▼ Hop, OK Turn the beam, Back Pause.
|
||||
- **Level complete (42):**
|
||||
- Waits for OK.
|
||||
- Nite Owl's line by stars ("Took the scenic route, did we?"), the stars, moves against par, and a par line.
|
||||
- Next Level (first), Replay, Chapters. Back goes to Chapters.
|
||||
- **Chapters (43):**
|
||||
- Five cards with each chapter's constellation, levels done and stars. Locked chapters say "Opens after Chapter n".
|
||||
- The chosen chapter's twelve levels underneath.
|
||||
- **Pause:** the shared pause menu, with Chapters added.
|
||||
- **Back by context:** in play Back pauses (nothing is ever held). On the Chapters page it goes to the title, and on
|
||||
Level complete to Chapters.
|
||||
- Muted indigo throughout, nothing flashes and nothing moves on its own, so Reduce motion and Reduce flashing have
|
||||
nothing to stop. There's no frame loop at all: the board redraws only when Owl hops or turns.
|
||||
|
||||
## Saves and High Scores
|
||||
|
||||
- Per profile, in the game's level progress: each level's best (`ns.<chapter>.<level>` = stars and moves; more stars, or
|
||||
the same stars in fewer moves).
|
||||
- "Reset level progress" clears it.
|
||||
- High Scores (Points) keep the profile's total stars, recorded with each finished level ("Ch 2 · Level 4").
|
||||
- Kids-suitable.
|
||||
|
||||
## The levels
|
||||
|
||||
- Made by `design/night-shift/make_levels.py` (fixed seed), which writes `arcade/nightshift/NightLevels.kt`:
|
||||
- It lays a path from the star to the mast, leaning towards the mast, a little longer each chapter.
|
||||
- From the Northern Relay on, a tee and a second mast.
|
||||
- Decoy pieces, more each chapter.
|
||||
- From Cloudbank on, one or two cloud lanes across the path.
|
||||
- Then every turnable piece is turned out of place.
|
||||
- It keeps a level only if:
|
||||
- its stored solution lights every mast at some cloud step;
|
||||
- the scrambled start isn't already solved.
|
||||
- **Par** is the turns from the start to the solution over every tile the solution lights, plus 2 to 4 by chapter.
|
||||
- `NightShiftLevelsTest` checks all 60 again in Kotlin:
|
||||
- Each is well formed: one star, the masts, no clouds before Cloudbank, two masts from the Northern Relay.
|
||||
- None starts solved.
|
||||
- A bot plays each through the game's own moves (hop to each piece the light needs, turn it right, hop until the clouds
|
||||
clear) and lights every mast within Owl's par on Gentle, Normal and Tricky.
|
||||
|
||||
## Not in this first build: Paul's call
|
||||
|
||||
- **Power-ups** (frame 41's Moonbeam, Sleepy Time, Star Magnet and Night Vision, "Menu: use one") are left out. The
|
||||
design uses the Menu key, which the Xiaomi remote doesn't seem to have; that's what broke Patience's Send home. They need
|
||||
another way to be chosen (the pause menu, or a long press of OK) before they go in.
|
||||
- **Settings** on the title is left out; the Arcade's own Settings cover difficulty and accessibility.
|
||||
- **The right lid lifting** on frame 42 is drawn as Nite Owl's lids part-lifted and a sideways glance. His art is unchanged,
|
||||
and it has no single-lid option.
|
||||
|
||||
## Checks
|
||||
|
||||
- Unit tests: 1,044 run, 24 skipped, 0 failed (`NightShiftLevelsTest` new, 6 tests).
|
||||
- Kids and session tests updated now that Night Shift plays: 10 Kids-suitable games, and Orbiteroids is the coming-soon
|
||||
example.
|
||||
- Lint: 0 errors, 87 warnings (none new).
|
||||
- Release APK: 48,121,447 bytes (+49,160 on 0.114.0).
|
||||
- `TitleTextFitsTest` at the largest font scale, at both 720p and 1080p (the box draws 960×540 dp for both):
|
||||
- every chapter name fits its card in at most two lines;
|
||||
- NIGHT SHIFT fits the title, with its buttons widened to 270 dp so "Continue · Ch 5 · Level 12" fits;
|
||||
- the level-complete panel (600 dp) fits its three buttons beside Nite Owl.
|
||||
Reference in New Issue
Block a user