|
|
|
@@ -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)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|