Classics family pass (0.111.0, versionCode 301): Back by context, family title/play/result, bug fixes, backdrop collection
- Back undoes what's in hand first (Patience's held card, Blast Off's tray), otherwise pauses; one rule, backStep/gameKeys - All eight Classics on the shared title, play frame, pause and result, in ArcadeColours and Anton, with KeyFooter keys - Patience controls fixed: Up to the top row, OK twice sends home, refused moves say so, distinct held/pointer, bigger cards - Star Chase maze with no lone walls or dead ends, solid walls, bigger stars; Comet Trail turn queue; paddle slide, held-Up spin, Zip-while-paused and Skydoku's main-thread puzzle making fixed - Eight code-drawn backdrops, one per Classic by default or one chosen for all; old choices carried over - Difficulty paces the four clock games (Normal unchanged); scores, Household keys and Skydoku's count untouched Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,13 +26,13 @@ class OrbManTest {
|
||||
g = play(g, OrbGame.READY_TICKS + g.playerEvery)
|
||||
assertEquals(OrbPos(maze.start.x - 1, maze.start.y), g.player.pos)
|
||||
assertEquals(10, g.score); assertTrue(OrbEvent.Star in g.events || g.score == 10)
|
||||
// Up is a wall at (8, 11): he carries on left, and goes up as soon as there's room, at (7, 11).
|
||||
val at = OrbPos(8, 11)
|
||||
// Up is a wall at (2, 11): he carries on left, and goes up as soon as there's room, at (1, 11).
|
||||
val at = OrbPos(2, 11)
|
||||
g = g.copy(player = OrbMover(at, at, OrbDir.Left, g.tick), wanted = OrbDir.Up)
|
||||
g = play(g, g.playerEvery)
|
||||
assertEquals(OrbPos(7, 11), g.player.pos); assertEquals(OrbDir.Left, g.player.dir)
|
||||
assertEquals(OrbPos(1, 11), g.player.pos); assertEquals(OrbDir.Left, g.player.dir)
|
||||
g = play(g, g.playerEvery)
|
||||
assertEquals(OrbPos(7, 10), g.player.pos); assertEquals(OrbDir.Up, g.player.dir)
|
||||
assertEquals(OrbPos(1, 10), g.player.pos); assertEquals(OrbDir.Up, g.player.dir)
|
||||
}
|
||||
|
||||
@Test fun aPowerHexagonFrightensTheRocksAndCatchingOneScores() {
|
||||
@@ -83,4 +83,15 @@ class OrbManTest {
|
||||
}
|
||||
assertTrue(g.alive); assertEquals(4, most)
|
||||
}
|
||||
|
||||
@Test fun noWallStandsOnItsOwnAndNoCorridorIsADeadEnd() {
|
||||
// Paul, 9 November 2026: "weird pillars or dots seem separate from the maze". Every wall joins another; every corridor goes on.
|
||||
for (y in 0 until maze.height) for (x in 0 until maze.width) {
|
||||
val p = OrbPos(x, y)
|
||||
val around = OrbDir.entries.map { OrbPos(x + it.dx, y + it.dy) }.filter { it.x in 0 until maze.width && it.y in 0 until maze.height }
|
||||
if (maze.wall(p)) assertTrue("lone wall at $p", around.any { maze.wall(it) })
|
||||
else if (!maze.door(p) && !maze.den(p)) assertTrue("dead end at $p", OrbDir.entries.count { d -> maze.step(p, d).let { n -> n.y in 0 until maze.height && !maze.wall(n) && !maze.door(n) && !maze.den(n) } } >= 2)
|
||||
}
|
||||
assertTrue(maze.walls.count { it } == maze.rows.sumOf { r -> r.count { it == '#' } })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,11 +42,46 @@ class PairsPatienceTest {
|
||||
|
||||
@Test fun aRunMovesTogetherAndBackPutsItDown() {
|
||||
val g = game(6 to listOf(PlayingCard(10, 1), PlayingCard(9, 0), PlayingCard(8, 2)), 7 to listOf(PlayingCard(11, 3)))
|
||||
val picked = g.point(6).steer(0, -1).steer(0, -1)
|
||||
assertEquals(3, picked.depth)
|
||||
val moved = picked.press().point(7).press()
|
||||
// A column is picked up whole; on the black jack only the red 10 and what's on it fit, so all three go.
|
||||
val picked = g.point(6).press()
|
||||
assertEquals(6 to 3, picked.held)
|
||||
val moved = picked.point(7).press()
|
||||
assertEquals(4, moved.piles[7].size); assertTrue(moved.piles[6].isEmpty())
|
||||
assertNull(g.point(6).press().drop().held)
|
||||
assertTrue(game(*HOMES.map { h -> h to (1..13).map { PlayingCard(it, h - 2) } }.toTypedArray()).won)
|
||||
}
|
||||
|
||||
@Test fun onlyAsManyAsFitMoveAndTheRestStay() {
|
||||
// Red 10, black 9, red 8 face up, onto a red 9: none of them fits, so nothing moves, the card stays in hand and it's refused.
|
||||
val g = game(6 to listOf(PlayingCard(10, 1), PlayingCard(9, 0), PlayingCard(8, 2)), 7 to listOf(PlayingCard(9, 1)))
|
||||
val refused = g.point(6).press().point(7).press()
|
||||
assertEquals(g.piles, refused.piles); assertEquals(1, refused.refusals); assertNotNull(refused.held)
|
||||
// Onto a black 9 only the red 8 fits: it moves on its own and the rest stay.
|
||||
val two = game(6 to listOf(PlayingCard(10, 1), PlayingCard(9, 0), PlayingCard(8, 2)), 7 to listOf(PlayingCard(9, 3)))
|
||||
val one = two.point(6).press().point(7).press()
|
||||
assertEquals(listOf(PlayingCard(9, 3), PlayingCard(8, 2)), one.piles[7]); assertEquals(2, one.piles[6].size)
|
||||
}
|
||||
|
||||
@Test fun upReachesTheTopRowInOnePressAndOkTwiceSendsHome() {
|
||||
val g = game(6 to listOf(PlayingCard(5, 0, false), PlayingCard(10, 1), PlayingCard(9, 0), PlayingCard(8, 2)), 12 to listOf(PlayingCard(1, 3)))
|
||||
assertEquals(STOCK, g.point(6).steer(0, -1).pile)
|
||||
assertEquals(5, g.point(12).steer(0, -1).pile)
|
||||
assertEquals(6, g.point(STOCK).steer(0, 1).pile)
|
||||
// The ace: OK picks it up, OK again on the same column sends it home.
|
||||
val home = g.point(12).press().press()
|
||||
assertEquals(listOf(PlayingCard(1, 3)), home.piles[2]); assertNull(home.held); assertEquals(1, home.moves) // the first empty home pile
|
||||
// A card with nowhere to go goes back where it was on the second OK.
|
||||
val back = g.point(6).press().press()
|
||||
assertNull(back.held); assertEquals(g.piles, back.piles)
|
||||
// The Menu key still sends home where there is one; with nothing to send it says so.
|
||||
assertEquals(1, g.point(12).sendHome().piles[2].size)
|
||||
assertEquals(1, g.point(6).sendHome().refusals)
|
||||
}
|
||||
|
||||
@Test fun longColumnsAlwaysFitTheirSpace() {
|
||||
// Six face-down and thirteen face-up cards in 340 dp, cards 104 tall.
|
||||
val step = patienceSteps(6, 13, 340f, 104f)
|
||||
assertTrue(104f + 6 * 8f + 12 * step <= 340f + .01f || step == 12f)
|
||||
assertEquals(26f, patienceSteps(0, 3, 400f, 104f), .01f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,4 +82,25 @@ class SnakeGameTest {
|
||||
assertEquals(3, snakeBackdrop(300))
|
||||
assertEquals(0, snakeBackdrop(400))
|
||||
}
|
||||
|
||||
@Test fun aSecondQuickTurnIsKeptForTheNextStep() {
|
||||
// Heading right: up then left pressed within one step. Up is taken now, left on the step after: a tight U-turn works.
|
||||
val random = java.util.Random(3)
|
||||
var g = game(3 to 5, 2 to 5).turn(SnakeDirection.Up).turn(SnakeDirection.Left)
|
||||
assertEquals(SnakeDirection.Left, g.queued)
|
||||
g = g.step(random)
|
||||
assertEquals(SnakeCell(3, 4), g.body.first()); assertEquals(SnakeDirection.Left, g.wanted)
|
||||
g = g.step(random)
|
||||
assertEquals(SnakeCell(2, 4), g.body.first())
|
||||
// A queued turn can't reverse the one before it.
|
||||
assertNull(game(3 to 5, 2 to 5).turn(SnakeDirection.Up).turn(SnakeDirection.Down).queued)
|
||||
}
|
||||
|
||||
@Test fun foodIsPickedFromTheFreeSquaresAsBefore() {
|
||||
val body = listOf(SnakeCell(0, 0), SnakeCell(1, 0))
|
||||
val r1 = java.util.Random(11); val r2 = java.util.Random(11)
|
||||
val old = ((0 until 4).flatMap { y -> (0 until 5).map { x -> SnakeCell(x, y) } } - body.toSet()).let { it[r2.nextInt(it.size)] }
|
||||
assertEquals(old, SnakeGame.nextFood(5, 4, body, r1))
|
||||
assertNull(SnakeGame.nextFood(1, 2, listOf(SnakeCell(0, 0), SnakeCell(0, 1)), r1))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package tv.orbit.classic.arcade
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import tv.orbit.classic.ArcadeBackdrop
|
||||
import tv.orbit.classic.BlastGame
|
||||
import tv.orbit.classic.PatienceGame
|
||||
import tv.orbit.classic.PlayingCard
|
||||
|
||||
/**
|
||||
* Paul, 9 November 2026: "Fix Back properly, not just universally. In Patience, pressing Back while holding a card should
|
||||
* cancel that action. Pressing Back when nothing is held should pause. The same principle should apply to other games with
|
||||
* active selections."
|
||||
*/
|
||||
class BackByContextTest {
|
||||
@Test fun backCancelsWhatIsInHandFirstAndOnlyThenPauses() {
|
||||
assertEquals(BackStep.Cancel, backStep(ArcadeKey.Back, down = true, repeatCount = 0, active = true))
|
||||
assertEquals(BackStep.Pause, backStep(ArcadeKey.Back, down = true, repeatCount = 0, active = false))
|
||||
// Play/pause always pauses, even with something in hand.
|
||||
assertEquals(BackStep.Pause, backStep(ArcadeKey.PlayPause, down = true, repeatCount = 0, active = true))
|
||||
// Only the press acts: not its repeats, not its release.
|
||||
assertEquals(BackStep.None, backStep(ArcadeKey.Back, down = true, repeatCount = 1, active = true))
|
||||
assertEquals(BackStep.None, backStep(ArcadeKey.Back, down = false, repeatCount = 0, active = false))
|
||||
assertEquals(BackStep.None, backStep(ArcadeKey.Ok, down = true, repeatCount = 0, active = true))
|
||||
}
|
||||
|
||||
@Test fun patienceBackPutsAHeldCardBackAndTheNextBackPauses() {
|
||||
val g = PatienceGame(List(13) { i -> if (i == 6) listOf(PlayingCard(7, 1)) else emptyList() })
|
||||
val held = g.point(6).press()
|
||||
assertNotNull(held.held)
|
||||
// Back with a card in hand: Cancel, which puts it back with nothing moved.
|
||||
assertEquals(BackStep.Cancel, backStep(ArcadeKey.Back, true, 0, active = held.held != null))
|
||||
val back = held.drop()
|
||||
assertNull(back.held); assertEquals(g.piles, back.piles); assertEquals(0, back.moves)
|
||||
// Nothing in hand now: the next Back pauses.
|
||||
assertEquals(BackStep.Pause, backStep(ArcadeKey.Back, true, 0, active = back.held != null))
|
||||
}
|
||||
|
||||
@Test fun blastOffBackFromTheTrayReturnsToTheBoardWithTheShapeItHad() {
|
||||
val g = BlastGame.start(java.util.Random(4))
|
||||
var inTray = g
|
||||
repeat(10) { inTray = inTray.move(0, 1) }
|
||||
assertTrue(inTray.inTray)
|
||||
assertEquals(BackStep.Cancel, backStep(ArcadeKey.Back, true, 0, active = inTray.inTray))
|
||||
val board = inTray.move(0, -1)
|
||||
assertFalse(board.inTray); assertEquals(inTray.selected, board.selected)
|
||||
assertEquals(BackStep.Pause, backStep(ArcadeKey.Back, true, 0, active = board.inTray))
|
||||
}
|
||||
|
||||
@Test fun theOtherClassicsHaveNothingInHandSoBackPauses() {
|
||||
// Star Chase, Brick Break, Block Drop and Comet Trail run on a clock; a turned card in Pairs can't be turned back; a Skydoku
|
||||
// star is placed by its one press. Each passes active = false (the default), so Back pauses.
|
||||
assertEquals(BackStep.Pause, backStep(ArcadeKey.Back, true, 0, active = false))
|
||||
}
|
||||
|
||||
@Test fun backdropsKeepAnOldChoiceAndEveryClassicHasItsOwn() {
|
||||
assertNull(ArcadeBackdrop.parse(null)); assertNull(ArcadeBackdrop.parse("NightSky")); assertNull(ArcadeBackdrop.parse("Auto"))
|
||||
assertEquals(ArcadeBackdrop.Nebula, ArcadeBackdrop.parse("Nebula"))
|
||||
assertEquals(ArcadeBackdrop.Rooftops, ArcadeBackdrop.parse("Moonrise"))
|
||||
assertEquals(ArcadeBackdrop.Teletext, ArcadeBackdrop.parse("Teletext"))
|
||||
assertNull(ArcadeBackdrop.parse("SomethingElse"))
|
||||
val defaults = ArcadeGames.classics.map { ArcadeBackdrop.forGame(it.id) }
|
||||
assertEquals(8, defaults.size)
|
||||
// Seven of the eight backdrops are a Classic's own; the eighth (Aurora) is one of Comet Trail's changing skies.
|
||||
assertEquals(ArcadeBackdrop.entries.toSet(), (defaults + ArcadeBackdrop.cometSkies).toSet())
|
||||
}
|
||||
}
|
||||
@@ -65,4 +65,25 @@ class TitleTextFitsTest {
|
||||
val caption = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(20f * 1.3f)
|
||||
for (l in tv.orbit.classic.arcade.chaos.Interludes.ALL) for (w in l.text.split(' ')) assertTrue(w, width(caption, w) < 420 - 28)
|
||||
}
|
||||
|
||||
@Test fun classicTitlesAndButtonsFitAtTheLargestFontScale() {
|
||||
// The box draws 960 × 540 dp at 720p and at 1080p alike, so one check covers both.
|
||||
// Each name in Anton at 76 sp in the title's left column: 960 less the side padding (2 × 48) and the 210 dp button column.
|
||||
val anton = Font.createFont(Font.TRUETYPE_FONT, File("src/main/res/font/anton_regular.ttf")).deriveFont(76f)
|
||||
for (g in ArcadeGames.classics) {
|
||||
val w = width(anton, g.title.uppercase())
|
||||
assertTrue("${g.title} is ${"%.0f".format(w)} dp", w <= 960.0 - 96 - 210 - 16)
|
||||
}
|
||||
val font = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val labels = listOf("▶ Play" to 210, "▶ Deal" to 210, "▶ Today's puzzle" to 210, "▶ New puzzle" to 210, "? How to Play" to 210, "← Back to Arcade" to 210,
|
||||
"▶ Play Again" to 160, "▶ Deal again" to 160, "▶ Try it again" to 160, "▶ New puzzle" to 160, "✦ New puzzle" to 160, "← Back to Arcade" to 200)
|
||||
for ((label, column) in labels) {
|
||||
val w = width(font, label)
|
||||
assertTrue("$label is ${"%.0f".format(w)} dp in $column", w <= column - 2 * 12 - 4)
|
||||
}
|
||||
// The result's three buttons (Skydoku out of hearts) fit its wider card: 600 dp less 2 × 20 padding.
|
||||
assertTrue(160 + 160 + 200 + 2 * 10 <= 600 - 40)
|
||||
// And the whole result row fits the screen: the cast either side.
|
||||
assertTrue(100 + 16 + 600 + 16 + 100 <= 960)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user