Skydoku 8x8 brings in Night Cap; Patience Orbit Deck: channel suits, the cast on the court cards, Ollie's hints, Undo on Gentle, draw three on Tricky, its own wins

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 09:54:09 +00:00
co-authored by Claude Opus 5.5
parent 9cd43b1e40
commit 24e4b54d07
7 changed files with 152 additions and 28 deletions
@@ -15,6 +15,7 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.graphics.drawscope.rotate
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@@ -53,6 +54,9 @@ internal data class PlayingCard(val rank: Int, val suit: Int, val up: Boolean =
val label get() = when (rank) { 1 -> "A"; 11 -> "J"; 12 -> "Q"; 13 -> "K"; else -> rank.toString() } + "♠♥♦♣"[suit]
}
/** A move Ollie suggests: [n] cards from pile [from] onto pile [to]. */
internal data class PatienceHint(val from: Int, val n: Int, val to: Int)
/** Piles by index: 0 the stock, 1 the turned cards, 2 to 5 the home piles, 6 to 12 the columns. */
internal const val STOCK = 0
internal const val WASTE = 1
@@ -131,6 +135,25 @@ internal data class PatienceGame(val piles: List<List<PlayingCard>>, val pile: I
/** Back with a card in hand: it goes back where it was. */
fun drop() = copy(held = null)
/**
* Ollie's hint (the Orbit Deck): the most useful move there is, or null when the stock is the only thing left to try.
* In order: a card that can go home; a run that uncovers a face-down card; the turned card onto a column; a king into
* an empty column that frees a face-down card.
*/
fun hint(): PatienceHint? {
for (from in listOf(WASTE) + COLUMNS.toList()) homeFor(from)?.let { return PatienceHint(from, 1, it) }
for (from in COLUMNS) {
val up = faceUp(from); if (up == 0 || up == piles[from].size) continue
for (to in COLUMNS) if (to != from && allowed(piles[from].takeLast(up), to)) return PatienceHint(from, up, to)
}
if (piles[WASTE].isNotEmpty()) for (to in COLUMNS) if (allowed(listOf(piles[WASTE].last()), to)) return PatienceHint(WASTE, 1, to)
for (from in COLUMNS) {
val up = faceUp(from); if (up == 0 || up == piles[from].size) continue
if (piles[from].takeLast(up).first().rank == 13) COLUMNS.firstOrNull { piles[it].isEmpty() }?.let { return PatienceHint(from, up, it) }
}
return null
}
companion object {
/** The Daily Challenge's deal: the same for everyone on any Orbit all day. */
fun daily(day: java.time.LocalDate, draw: Int = 1) = deal(java.util.Random(day.toEpochDay() * 104_729 + 7)).copy(draw = draw)
@@ -151,8 +174,35 @@ internal fun dailyScore(moves: Int, seconds: Int) = moves * 10_000 + seconds.coe
internal fun dailyLine(score: Int) = "${score / 10_000} moves · %d:%02d".format(score % 10_000 / 60, score % 10_000 % 60)
/** The three ways to play: Classic, and the Daily Challenge drawing one or three. */
internal enum class PatienceMode(val title: String, val table: String?, val draw: Int) {
Classic("Classic", null, 1), Daily("Daily Challenge", tv.orbit.classic.arcade.PATIENCE_DAILY_SCORES, 1), DailyThree("Daily · Draw Three", tv.orbit.classic.arcade.PATIENCE_DAILY3_SCORES, 3)
internal enum class PatienceMode(val title: String, val table: String?, val draw: Int, val daily: Boolean = false, val orbit: Boolean = false) {
Classic("Classic", null, 1), Daily("Daily Challenge", tv.orbit.classic.arcade.PATIENCE_DAILY_SCORES, 1, daily = true),
DailyThree("Daily · Draw Three", tv.orbit.classic.arcade.PATIENCE_DAILY3_SCORES, 3, daily = true),
/** Orbit Patience (Phase 2): the channels' deck, Ollie's hints, Undo on Gentle, three at a time on Tricky. Wins in its own table. */
OrbitDeck("Orbit Deck", tv.orbit.classic.arcade.PATIENCE_ORBIT_SCORES, 1, orbit = true)
}
/**
* The Orbit Deck's four suits: Channel Chaos's channels. Orbit 1 and Terra are the cool suits, Riot and Tots the warm, so a
* column still goes warm, cool, warm (the same rule as red and black). The cast are on the face cards.
*/
internal val OrbitSuits = listOf("Orbit 1" to Color(0xFF35D6F2), "Riot" to Color(0xFFFF2EA6), "Tots" to Color(0xFFFFB52E), "Terra" to Color(0xFF9BE564))
internal fun orbitRank(rank: Int) = when (rank) { 1 -> "A"; 11 -> "J"; 12 -> "Q"; 13 -> "K"; else -> rank.toString() }
/** A card's name as Ollie says it: "the 7 of Riot", "the queen of Terra". */
internal fun orbitCardName(c: PlayingCard) = "the " + when (c.rank) { 1 -> "ace"; 11 -> "jack"; 12 -> "queen"; 13 -> "king"; else -> c.rank.toString() } + " of " + OrbitSuits[c.suit].first
/** A suit's mark: Orbit 1's star, Riot's bolt, Tots' sun, Terra's leaf. */
private fun androidx.compose.ui.graphics.drawscope.DrawScope.orbitSuit(suit: Int, c: androidx.compose.ui.geometry.Offset, r: Float) {
val colour = OrbitSuits[suit].second
when (suit) {
0 -> drawPath(starPath(c, r, r * .45f, 0f), colour)
1 -> drawPath(androidx.compose.ui.graphics.Path().apply {
moveTo(c.x + r * .25f, c.y - r); lineTo(c.x - r * .55f, c.y + r * .1f); lineTo(c.x - r * .02f, c.y + r * .1f)
lineTo(c.x - r * .25f, c.y + r); lineTo(c.x + r * .55f, c.y - r * .15f); lineTo(c.x + r * .02f, c.y - r * .15f); close() }, colour)
2 -> { drawCircle(colour, r * .5f, c); for (k in 0 until 8) { val a = k * Math.PI / 4; drawLine(colour, c + androidx.compose.ui.geometry.Offset((r * .7f * kotlin.math.cos(a)).toFloat(), (r * .7f * kotlin.math.sin(a)).toFloat()),
c + androidx.compose.ui.geometry.Offset((r * kotlin.math.cos(a)).toFloat(), (r * kotlin.math.sin(a)).toFloat()), r * .16f) } }
else -> { rotate(-35f, c) { drawOval(colour, c - androidx.compose.ui.geometry.Offset(r * .45f, r), androidx.compose.ui.geometry.Size(r * .9f, r * 2f)) }
drawLine(Color(0xFF0B3A1F).copy(alpha = .6f), c + androidx.compose.ui.geometry.Offset(-r * .5f, r * .7f), c + androidx.compose.ui.geometry.Offset(r * .5f, -r * .7f), r * .1f) }
}
}
private val CardW = 76.dp
@@ -162,11 +212,29 @@ private val HeldRing = ArcadeColours.Cyan
private val PointRing = ArcadeColours.Yellow
@Composable
private fun CardFace(card: PlayingCard?, empty: String = "", modifier: Modifier = Modifier) {
Box(modifier.width(CardW).height(CardH).background(when { card == null -> Color(0x22FFFFFF); card.up -> Color(0xFFF4F6FB); else -> ArcadeColours.Panel }, RoundedCornerShape(7.dp))
.border(1.dp, if (card?.up == false) ArcadeColours.Line else Color(0x55FFFFFF), RoundedCornerShape(7.dp)).padding(5.dp)) {
private fun CardFace(card: PlayingCard?, empty: String = "", modifier: Modifier = Modifier, orbit: Boolean = false) {
Box(modifier.width(CardW).height(CardH).background(when { card == null -> Color(0x22FFFFFF); card.up && orbit -> ArcadeColours.PanelDeep; card.up -> Color(0xFFF4F6FB); else -> ArcadeColours.Panel }, RoundedCornerShape(7.dp))
.border(1.dp, if (card?.up == false) ArcadeColours.Line else if (orbit && card != null) OrbitSuits[card.suit].second.copy(alpha = .7f) else Color(0x55FFFFFF), RoundedCornerShape(7.dp)).padding(5.dp)) {
when {
card == null -> Text(empty, Modifier.align(Alignment.Center), color = ArcadeColours.Muted.copy(alpha = .6f), fontSize = 18.sp)
// The Orbit Deck: the channel's mark and colour, and the cast on the court cards (Ollie on the aces).
card.up && orbit -> {
val colour = OrbitSuits[card.suit].second
Row(verticalAlignment = Alignment.CenterVertically) {
Text(orbitRank(card.rank), color = colour, fontSize = 18.sp, fontWeight = FontWeight.Bold)
Canvas(Modifier.size(14.dp).padding(start = 2.dp)) { orbitSuit(card.suit, center, size.minDimension / 2) }
}
Canvas(Modifier.fillMaxSize().padding(top = 18.dp)) {
val r = size.minDimension * .3f
when (card.rank) {
1 -> drawOrbMascot(center, r * .9f)
11 -> drawOrbChaser(center, r, OrbCharacter.Zip, OrbDir.Down, false, false, false, 0f)
12 -> drawOrbChaser(center, r, OrbCharacter.Luna, OrbDir.Down, false, false, false, 0f)
13 -> drawOrbChaser(center, r, OrbCharacter.Blaze, OrbDir.Down, false, false, false, 0f)
else -> orbitSuit(card.suit, center, r)
}
}
}
card.up -> {
val colour = if (card.red) Color(0xFFD32F2F) else Color(0xFF0B1B44)
Text(card.label, color = colour, fontSize = 18.sp, fontWeight = FontWeight.Bold)
@@ -208,17 +276,25 @@ internal fun PatienceScreen(play: ArcadePlay) {
val backdrop = ArcadeLook.forGame(gameDef.id)
// A won game counts for this profile; leaving part-way counts nothing. A daily win goes in its own table, moves then time.
val run = rememberRun({ end -> mode.table?.let { latestPlay.onRunEndIn(it, end) } ?: latestPlay.onRunEnd(end) }) {
if (mode.table != null) RunEnd(dailyScore(game.moves, seconds), finished = game.won) else RunEnd(game.moves, finished = game.won)
if (mode.daily) RunEnd(dailyScore(game.moves, seconds), finished = game.won) else RunEnd(game.moves, finished = game.won)
}
fun finishRun(won: Boolean) = run.end(if (mode.table != null) RunEnd(dailyScore(game.moves, seconds), finished = won, detail = today.toString()) else RunEnd(game.moves, finished = won))
// The Orbit Deck on Gentle keeps every move, for Undo (from the pause menu).
val undo = remember { ArrayList<PatienceGame>() }
val canUndo = mode.orbit && play.difficulty == tv.orbit.classic.arcade.Difficulty.Gentle
fun finishRun(won: Boolean) = run.end(if (mode.daily) RunEnd(dailyScore(game.moves, seconds), finished = won, detail = today.toString()) else RunEnd(game.moves, finished = won))
fun deal() {
winsBefore = latestPlay.best; dailyBefore = mode.table?.let { latestPlay.bestIn(it) } ?: 0; seconds = 0
game = if (mode.table != null) PatienceGame.daily(today, mode.draw) else PatienceGame.deal(random)
winsBefore = mode.table?.takeIf { mode.orbit }?.let { latestPlay.bestIn(it) } ?: latestPlay.best; dailyBefore = mode.table?.let { latestPlay.bestIn(it) } ?: 0; seconds = 0
undo.clear()
game = when {
mode.daily -> PatienceGame.daily(today, mode.draw)
mode.orbit -> PatienceGame.deal(random).copy(draw = if (latestPlay.difficulty == tv.orbit.classic.arcade.Difficulty.Tricky) 3 else 1)
else -> PatienceGame.deal(random)
}
run.begin(); paused = false; stage = ClassicStage.Play
}
fun leave() { finishRun(game.won); latestPlay.onLeave() }
LaunchedEffect(game.won) { if (game.won && stage == ClassicStage.Play) { finishRun(true); stage = ClassicStage.Result } }
LaunchedEffect(stage, paused, mode) { while (mode.table != null && stage == ClassicStage.Play && !paused && !game.won) { kotlinx.coroutines.delay(1_000); seconds++ } }
LaunchedEffect(stage, paused, mode) { while (mode.daily && stage == ClassicStage.Play && !paused && !game.won) { kotlinx.coroutines.delay(1_000); seconds++ } }
LaunchedEffect(stage, paused) { if (stage == ClassicStage.Play && !paused) runCatching { focus.requestFocus() } }
// "That can't go there", for a moment after a refused move.
var refusedShown by remember { mutableStateOf(false) }
@@ -227,12 +303,14 @@ internal fun PatienceScreen(play: ArcadePlay) {
if (stage == ClassicStage.Title) {
val dailyBest = mode.table?.let { play.bestIn(it) } ?: 0
ClassicTitle(gameDef, backdrop, ArcadeColours.Green, if (mode.table != null) "Today's deal is the same for everyone!" else "Deal you in?",
if (mode.table != null) listOf("Your best" to if (dailyBest > 0) dailyLine(dailyBest) else "Not won yet") else listOf("Games won" to "${play.best}"),
val orbitWins = if (mode.orbit) play.bestIn(tv.orbit.classic.arcade.PATIENCE_ORBIT_SCORES) else 0
ClassicTitle(gameDef, backdrop, ArcadeColours.Green, if (mode.daily) "Today's deal is the same for everyone!" else "Deal you in?",
if (mode.daily) listOf("Your best" to if (dailyBest > 0) dailyLine(dailyBest) else "Not won yet") else if (mode.orbit) listOf("Orbit Deck wins" to "$orbitWins") else listOf("Games won" to "${play.best}"),
timed = false, difficulty = play.difficulty, refocus = !howTo, onPlay = ::deal, onHowTo = { howTo = true }, onBack = { latestPlay.onLeave() },
playLabel = if (mode.table != null) "Today's deal" else "Deal", mode = mode.title, modes = PatienceMode.entries.size,
playLabel = if (mode.daily) "Today's deal" else "Deal", mode = mode.title, modes = PatienceMode.entries.size,
onMode = { mode = PatienceMode.entries[(mode.ordinal + 1) % PatienceMode.entries.size]; latestPlay.setLevel("mode", mode.name) },
note = if (mode.table != null) "One deal a day, the same on every Orbit, so the family can compare. Win it in the fewest moves, then the quickest." + (if (mode.draw == 3) " Three cards turn at a time." else "")
note = if (mode.orbit) "The channels' own deck: Orbit 1 and Terra are cool, Riot and Tots warm; columns go warm, cool, warm. Ollie hints the best move he can see. Undo on Gentle; three at a time on Tricky."
else if (mode.daily) "One deal a day, the same on every Orbit, so the family can compare. Win it in the fewest moves, then the quickest." + (if (mode.draw == 3) " Three cards turn at a time." else "")
else "Pick a card up and OK where it goes: as many as fit there move together. OK twice sends a card home.")
if (howTo) HowToPlayCard(gameDef, firstRun = false, everyTime = null, onEveryTime = {}, onPlay = { howTo = false }, onBack = { howTo = false })
return
@@ -250,6 +328,7 @@ internal fun PatienceScreen(play: ArcadePlay) {
ArcadeKey.Menu -> game.sendHome()
else -> if (native.keyCode == KeyEvent.KEYCODE_PROG_RED) game.sendHome() else null
}
if (next != null && canUndo && next.moves > game.moves) { undo += game; if (undo.size > 300) undo.removeAt(0) }
if (next != null) game = next
next != null
}
@@ -260,14 +339,25 @@ internal fun PatienceScreen(play: ArcadePlay) {
hud = {
HudLabel("MOVES"); HudValue("${game.moves}")
Spacer(Modifier.height(8.dp))
if (mode.table != null) { HudLabel(if (mode.draw == 3) "DAILY · DRAW 3" else "DAILY DEAL"); HudValue("%d:%02d".format(seconds / 60, seconds % 60)) }
if (mode.daily) { HudLabel(if (mode.draw == 3) "DAILY · DRAW 3" else "DAILY DEAL"); HudValue("%d:%02d".format(seconds / 60, seconds % 60)) }
else if (mode.orbit) { HudLabel(if (game.draw == 3) "ORBIT DECK · DRAW 3" else "ORBIT DECK"); HudValue("$winsBefore won") }
else { HudLabel("GAMES WON"); HudValue("${maxOf(play.best, winsBefore)}") }
Spacer(Modifier.height(8.dp))
HudLabel("IN HAND")
Text(game.held?.let { (from, n) -> game.piles[from].takeLast(n).first().label + if (n > 1) " and ${n - 1} more" else "" } ?: "Nothing",
Text(game.held?.let { (from, n) -> game.piles[from].takeLast(n).first().let { c -> if (mode.orbit) orbitRank(c.rank) + " " + OrbitSuits[c.suit].first else c.label } + if (n > 1) " and ${n - 1} more" else "" } ?: "Nothing",
color = if (game.held != null) HeldRing else ArcadeColours.Muted, fontSize = 16.sp, fontWeight = FontWeight.SemiBold)
Spacer(Modifier.weight(1f))
if (refusedShown) SpeechBubble("That can't go there") else if (game.held != null && game.homeFor(game.held!!.first) != null && game.pile == game.held!!.first) SpeechBubble("OK again: home!")
// Ollie's hints, in the Orbit Deck.
else if (mode.orbit && game.held == null) {
val h = game.hint()
SpeechBubble(when {
h == null && (game.piles[STOCK].isNotEmpty() || game.piles[WASTE].isNotEmpty()) -> "Try turning a card from the stock"
h == null -> "No moves left: a new deal?"
h.to in HOMES -> "Send ${orbitCardName(game.piles[h.from].last())} home!"
else -> "${orbitCardName(game.piles[h.from].takeLast(h.n).first()).replaceFirstChar { it.uppercase() }} can go on ${game.piles[h.to].lastOrNull()?.let(::orbitCardName) ?: "the empty column"}"
})
}
Canvas(Modifier.size(56.dp)) { drawOrbMascot(center, size.minDimension * .34f) }
}) {
BoxWithConstraints(Modifier.fillMaxSize()) {
@@ -277,7 +367,7 @@ internal fun PatienceScreen(play: ArcadePlay) {
listOf(STOCK, WASTE, -1, 2, 3, 4, 5).forEach { i ->
if (i < 0) Spacer(Modifier.width(CardW)) else {
CardFace(game.piles[i].lastOrNull()?.let { if (i == STOCK) it.copy(up = false) else it }, if (i == STOCK) "↺" else if (i in HOMES) "A" else "",
Modifier.ring(pointed = game.pile == i, held = game.held?.first == i))
Modifier.ring(pointed = game.pile == i, held = game.held?.first == i), orbit = mode.orbit)
}
}
}
@@ -291,7 +381,7 @@ internal fun PatienceScreen(play: ArcadePlay) {
if (cards.isEmpty()) CardFace(null, "K", Modifier.ring(pointed = game.pile == c, held = false))
cards.forEachIndexed { n, card ->
val y: Dp = if (n < down) 8.dp * n else 8.dp * down + upStep * (n - down)
CardFace(card, modifier = Modifier.offset(y = y).ring(pointed = game.pile == c && n == cards.lastIndex && held == 0, held = n >= cards.size - held))
CardFace(card, modifier = Modifier.offset(y = y).ring(pointed = game.pile == c && n == cards.lastIndex && held == 0, held = n >= cards.size - held), orbit = mode.orbit)
}
}
}
@@ -299,14 +389,17 @@ internal fun PatienceScreen(play: ArcadePlay) {
}
}
}
if (stage == ClassicStage.Result && mode.table != null) {
if (stage == ClassicStage.Result && mode.daily) {
val score = dailyScore(game.moves, seconds)
ClassicResult(gameDef, "PATIENCE · ${mode.title.uppercase()} · ${today}", "TODAY'S DEAL", dailyLine(score), newBest = dailyBefore == 0 || score < dailyBefore,
previous = if (dailyBefore > 0) "Best ${dailyLine(dailyBefore)}" else "Your first Daily Challenge win", detail = "Same deal all day: can anyone beat it?", heading = "WON!",
againLabel = "Try it again", cheer = Mascot.Luna, onAgain = ::deal, onBack = ::leave)
} else if (stage == ClassicStage.Result) ClassicResult(gameDef, "PATIENCE · WON IN ${game.moves} MOVES", "GAMES WON", "${winsBefore + 1}", newBest = false,
} else if (stage == ClassicStage.Result && mode.orbit) ClassicResult(gameDef, "PATIENCE · ORBIT DECK · WON IN ${game.moves} MOVES", "ORBIT DECK WINS", "${winsBefore + 1}", newBest = false,
previous = "Every channel home, ace to king", detail = null, heading = "WON!", againLabel = "Deal again", cheer = Mascot.Blaze, onAgain = ::deal, onBack = ::leave)
else if (stage == ClassicStage.Result) ClassicResult(gameDef, "PATIENCE · WON IN ${game.moves} MOVES", "GAMES WON", "${winsBefore + 1}", newBest = false,
previous = "Every suit home, ace to king", detail = null, heading = "WON!", againLabel = "Deal again", cheer = Mascot.Luna, onAgain = ::deal, onBack = ::leave)
if (paused && stage == ClassicStage.Play) ArcadePauseMenu(gameDef, "Patience · ${game.moves} moves",
onResume = { paused = false }, onRestart = { finishRun(false); deal() }, onExit = ::leave)
onResume = { paused = false }, onRestart = { finishRun(false); deal() }, onExit = ::leave,
extra = if (canUndo) "Undo a move" to { if (undo.isNotEmpty()) game = undo.removeAt(undo.size - 1); paused = false } else null)
}
}
@@ -175,7 +175,7 @@ internal fun skyDaily(day: java.time.LocalDate) = skyMake(java.util.Random(day.t
/** The cast in region order, each region in its member's colour. */
internal val SkyCast = listOf("Ollie", "Blaze", "Zip", "Drift", "Luna", "Bumble", "Nite Owl", "a star")
internal val SkyCast = listOf("Ollie", "Blaze", "Zip", "Drift", "Luna", "Bumble", "Nite Owl", "Night Cap")
internal val SkyColours = listOf(Color(0xFFF7A928), OrbCharacter.Blaze.colour, OrbCharacter.Zip.colour, OrbCharacter.Drift.colour, OrbCharacter.Luna.colour, Color(0xFF8BD86A), Color(0xFF6C7BD9), Color(0xFFFFDE59))
/** One of the six, by region, drawn to the cast's model sheet. */
@@ -186,9 +186,9 @@ internal fun DrawScope.drawSkyFace(region: Int, centre: Offset, r: Float) = when
3 -> drawOrbChaser(centre, r * .85f, OrbCharacter.Drift, OrbDir.Down, false, false, false, 0f)
4 -> drawOrbChaser(centre, r * .85f, OrbCharacter.Luna, OrbDir.Down, false, false, false, 0f)
5 -> drawOrbBee(centre + Offset(0f, r * .15f), r * .62f)
// The Challenge's bigger skies: Nite Owl, and a gold star (a stand-in until Paul picks the eighth).
// The Challenge's bigger skies: Nite Owl, and Night Cap (Luna in her late-night cap).
6 -> drawNiteOwl(centre, r * .8f)
else -> drawPath(starPath(centre, r * .8f, r * .36f, 0f), Color(0xFFFFDE59))
else -> drawNightCap(centre + Offset(0f, r * .1f), r * .7f)
}
/** The board: regions tinted in their member's colour with bold edges between them, the cast where placed, crosses where ruled out. */
@@ -101,7 +101,7 @@ internal fun ArcadeScrim(content: @Composable BoxScope.() -> Unit) {
*/
@Composable
internal fun ArcadePauseMenu(game: ArcadeGame, line: String, onResume: () -> Unit, onRestart: () -> Unit, onExit: () -> Unit,
sound: String? = null, onSound: (() -> Unit)? = null) {
sound: String? = null, onSound: (() -> Unit)? = null, extra: Pair<String, () -> Unit>? = null) {
var howTo by remember { mutableStateOf(false) }
if (howTo) { HowToPlayCard(game, firstRun = false, everyTime = null, onEveryTime = {}, onPlay = { howTo = false }, onBack = { howTo = false }); return }
val first = remember { FocusRequester() }
@@ -115,6 +115,8 @@ internal fun ArcadePauseMenu(game: ArcadeGame, line: String, onResume: () -> Uni
Text(line, color = ArcadeColours.Muted, fontSize = 13.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
Spacer(Modifier.height(2.dp))
ArcadeButton("Resume", Modifier.fillMaxWidth().focusRequester(first), icon = "▶", onClick = onResume)
// A game's own line, where it has one (Patience's Undo on Gentle).
if (extra != null) ArcadeButton(extra.first, Modifier.fillMaxWidth(), icon = "↶", onClick = extra.second)
ArcadeButton("Restart Level", Modifier.fillMaxWidth(), icon = "↻", onClick = onRestart)
ArcadeButton("How to Play", Modifier.fillMaxWidth(), icon = "?", onClick = { howTo = true })
if (sound != null && onSound != null) ArcadeButton("Sound", Modifier.fillMaxWidth(), icon = "♪", detail = sound, onClick = onSound)
@@ -106,6 +106,9 @@ internal const val BLOCKS_SPRINT_SCORES = "BlocksSprint"
internal const val PATIENCE_DAILY_SCORES = "PatienceDaily"
internal const val PATIENCE_DAILY3_SCORES = "PatienceDaily3"
/** Patience's Orbit Deck: games won, as Classic counts them, in its own table. */
internal const val PATIENCE_ORBIT_SCORES = "PatienceOrbit"
/** Pairs' Challenge: boards cleared then pairs matched, in one number ([tv.orbit.classic.pairsScore]). */
internal const val PAIRS_CHALLENGE_SCORES = "PairsChallenge"
@@ -124,7 +127,8 @@ internal val modeTables: Map<String, List<ScoreTable>> = mapOf(
"OrbMan" to listOf(ScoreTable(ORBMAN_SIGNAL_SCORES, "Signal Run", ScoreKind.Points)),
"Blocks" to listOf(ScoreTable(BLOCKS_SPRINT_SCORES, "40-Line Sprint", ScoreKind.FewestMoves) { tv.orbit.classic.sprintText(it) }),
"Patience" to listOf(ScoreTable(PATIENCE_DAILY_SCORES, "Daily", ScoreKind.FewestMoves) { tv.orbit.classic.dailyLine(it) },
ScoreTable(PATIENCE_DAILY3_SCORES, "Daily Draw 3", ScoreKind.FewestMoves) { tv.orbit.classic.dailyLine(it) }),
ScoreTable(PATIENCE_DAILY3_SCORES, "Daily Draw 3", ScoreKind.FewestMoves) { tv.orbit.classic.dailyLine(it) },
ScoreTable(PATIENCE_ORBIT_SCORES, "Orbit Deck", ScoreKind.Wins)),
"Pairs" to listOf(ScoreTable(PAIRS_CHALLENGE_SCORES, "Challenge", ScoreKind.Points) { tv.orbit.classic.pairsLine(it) }),
"Blast" to listOf(ScoreTable(BLAST_CHALLENGE_SCORES, "Challenges", ScoreKind.Points) { tv.orbit.classic.blastChallengeLine(it) }),
"Sky" to listOf(ScoreTable(SKY_CHALLENGE_SCORES, "Challenge", ScoreKind.Points) { tv.orbit.classic.challengeLine(it) }),
@@ -130,4 +130,29 @@ class PairsPatienceTest {
assertTrue(pairsScore(3, 1) > pairsScore(2, 40))
assertEquals("3 boards · 31 pairs", pairsLine(pairsScore(3, 31)))
}
// ---------- the Orbit Deck (Phase 2) ----------
@Test fun theOrbitDeckKeepsTheWarmCoolRuleAndNamesItsCards() {
// Riot and Tots are warm (the "red" suits), Orbit 1 and Terra cool: the column rule is unchanged.
assertTrue(PlayingCard(5, 1).red); assertTrue(PlayingCard(5, 2).red); assertFalse(PlayingCard(5, 0).red); assertFalse(PlayingCard(5, 3).red)
assertEquals(listOf("Orbit 1", "Riot", "Tots", "Terra"), OrbitSuits.map { it.first })
assertEquals("the queen of Terra", orbitCardName(PlayingCard(12, 3))); assertEquals("the 7 of Riot", orbitCardName(PlayingCard(7, 1)))
}
@Test fun olliesHintPrefersHomeThenUncoveringThenTheTurnedCard() {
// An ace on the turned pile: home first.
assertEquals(PatienceHint(WASTE, 1, 2), game(WASTE to listOf(PlayingCard(1, 0)), 6 to listOf(PlayingCard(9, 1))).hint())
// A run that uncovers a face-down card: a black 8 on a red 9.
val uncover = game(6 to listOf(PlayingCard(4, 0, false), PlayingCard(8, 0)), 7 to listOf(PlayingCard(9, 1)))
assertEquals(PatienceHint(6, 1, 7), uncover.hint())
// The turned card onto a column.
assertEquals(PatienceHint(WASTE, 1, 7), game(WASTE to listOf(PlayingCard(8, 3)), 7 to listOf(PlayingCard(9, 2))).hint())
// Nothing to do but turn the stock.
assertNull(game(STOCK to listOf(PlayingCard(5, 0, false)), 6 to listOf(PlayingCard(9, 1))).hint())
// Following the hint really is a legal move.
val h = uncover.hint()!!
val after = uncover.point(h.from).press().point(h.to).press()
assertEquals(2, after.piles[7].size); assertTrue(after.piles[6].single().up)
}
}
@@ -33,7 +33,7 @@ class ModeTablesTest {
@Test fun blockDropsSprintAndPatiencesDailiesKeepTheirOwnTables() {
assertEquals(listOf("Blocks", BLOCKS_SPRINT_SCORES), scoreTables("Blocks"))
assertEquals(listOf("Patience", PATIENCE_DAILY_SCORES, PATIENCE_DAILY3_SCORES), scoreTables("Patience"))
assertEquals(listOf("Patience", PATIENCE_DAILY_SCORES, PATIENCE_DAILY3_SCORES, PATIENCE_ORBIT_SCORES), scoreTables("Patience"))
var d = ArcadeProfileData(profileId = "p1")
// A Sprint counts only when finished, fastest first.
d = recordRun(d, BLOCKS_SPRINT_SCORES, tableKind("Blocks", BLOCKS_SPRINT_SCORES, ScoreKind.Points), RunEnd(9_000, false), 1)
+1 -1
View File
@@ -48,7 +48,7 @@ unchanged (`ModeTablesTest`).
| Blast Off | **Challenges** | Twenty numbered boards made by hand (Warm-up … Blast off!), each "clear so many lines with so many shapes". The shapes come in the same order every try, so each is a puzzle to learn. The next uncleared one is offered; the furthest cleared is saved. | `BlastChallenge`: furthest cleared |
- Skydoku's puzzle maker now takes a size; 6×6 runs exactly as before, so the daily puzzle is unchanged. The 7×7 brings in
Nite Owl; the 8×8's eighth is a gold star for now (Paul to pick who).
Nite Owl, the 8×8 Night Cap.
- Every Blast Off challenge is beaten by a plain test bot within its shapes (`BlastChallengesTest`); none starts with a full
line.
- The Mode button carries the mode's whole name (the title's buttons widened to 230 dp, Play Again to 180 dp to fit).