Orbit Arcade: Pairs and Patience, completing Paul's game list
Pairs: twenty cards, ten pairs of Orbit's own channel logos; arrows move, OK turns a card, a match stays up, a miss turns back after a moment; the fewest moves is kept. Patience: classic one-card-draw, with a pointer over the stock, turned card, home piles and columns; OK picks up and puts down, up and down in a column choose how deep, Back puts a card back, Menu sends a card home; games won are counted. The honeycomb now holds all six games. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
/** Pairs and Patience: the rules, as the remote plays them. */
|
||||
class PairsPatienceTest {
|
||||
@Test fun pairsMatchStaysUpAndAMissTurnsBack() {
|
||||
val g = PairsGame(listOf(0, 1, 0, 1) + List(16) { 2 + it / 2 })
|
||||
val matched = g.copy(cursor = 0).flip().copy(cursor = 2).flip()
|
||||
assertEquals(setOf(0, 2), matched.matched); assertEquals(1, matched.moves); assertFalse(matched.waiting)
|
||||
val missed = g.copy(cursor = 0).flip().copy(cursor = 1).flip()
|
||||
assertTrue(missed.waiting); assertEquals(missed, missed.copy(cursor = 3).flip().copy(cursor = 1)) // no third card while two are up
|
||||
assertTrue(missed.hide().open.isEmpty())
|
||||
assertEquals(g.copy(cursor = 0).flip(), g.copy(cursor = 0).flip().flip()) // the same card twice does nothing
|
||||
assertEquals(PAIRS_COLUMNS - 1, g.moveCursor(9, 0).cursor); assertEquals(0, g.moveCursor(-1, -1).cursor)
|
||||
val deal = PairsGame.deal(java.util.Random(3)); assertEquals(20, deal.cards.size); assertTrue(deal.cards.groupingBy { it }.eachCount().values.all { it == 2 })
|
||||
}
|
||||
|
||||
@Test fun patienceDealsTheClassicLayout() {
|
||||
val g = PatienceGame.deal(java.util.Random(5))
|
||||
assertEquals((1..7).toList(), COLUMNS.map { g.piles[it].size })
|
||||
assertTrue(COLUMNS.all { c -> g.piles[c].last().up && g.piles[c].dropLast(1).none { it.up } })
|
||||
assertEquals(24, g.piles[STOCK].size); assertEquals(52, g.piles.sumOf { it.size })
|
||||
// The stock turns one card at a time, and an empty stock takes the turned cards back.
|
||||
var s = g.point(STOCK); repeat(24) { s = s.press() }
|
||||
assertEquals(24, s.piles[WASTE].size); assertEquals(24, s.press().piles[STOCK].size)
|
||||
}
|
||||
|
||||
private fun game(vararg piles: Pair<Int, List<PlayingCard>>) = PatienceGame(List(13) { i -> piles.firstOrNull { it.first == i }?.second.orEmpty() })
|
||||
|
||||
@Test fun cardsGoHomeBySuitAndColumnsBuildDownInAlternateColours() {
|
||||
val g = game(6 to listOf(PlayingCard(1, 0)), 7 to listOf(PlayingCard(9, 1)), 8 to listOf(PlayingCard(5, 3, false), PlayingCard(8, 0)))
|
||||
val home = g.point(6).press().point(2).press()
|
||||
assertEquals(listOf(PlayingCard(1, 0)), home.piles[2]); assertEquals(1, home.moves)
|
||||
val built = g.point(8).press().point(7).press() // black 8 on red 9
|
||||
assertEquals(2, built.piles[7].size); assertTrue(built.piles[8].single().up) // the card beneath turns up
|
||||
assertEquals(g.piles, g.point(7).press().point(8).press().piles) // red 9 can't go on black 8: nothing moves
|
||||
assertFalse(g.allowed(listOf(PlayingCard(12, 0)), 9)); assertTrue(g.allowed(listOf(PlayingCard(13, 0)), 9)) // only a king on an empty column
|
||||
assertEquals(listOf(PlayingCard(1, 0)), g.point(6).sendHome().piles[2])
|
||||
}
|
||||
|
||||
@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()
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user