fix: ensure HighCard only applies when no other combination matches

This commit is contained in:
2025-04-21 22:08:11 -04:00
parent e66488d814
commit b911b1e648
2 changed files with 19 additions and 9 deletions

View File

@@ -5,7 +5,7 @@ import cards._
class HighCardTest extends FunSuite {
test("HighCard accepts any hand") {
test("HighCard returns true only when no other combination applies") {
val hand = List(
Card(Two, Hearts),
Card(Four, Clubs),
@@ -13,16 +13,21 @@ class HighCardTest extends FunSuite {
Card(Jack, Spades),
Card(Ace, Hearts)
)
val combination = HighCard()
assert(combination.verify(hand))
assert(combination.verify(hand)) // No other combination applies
assertEquals(combination.score.chips, 5)
assertEquals(combination.score.multiplier, 1)
}
test("HighCard accepts even a single card") {
val hand = List(Card(King, Clubs))
test("HighCard returns false when hand has a pair") {
val hand = List(
Card(Two, Hearts),
Card(Two, Spades), // pair
Card(Four, Clubs),
Card(Six, Diamonds),
Card(Nine, Hearts)
)
val combination = HighCard()
assert(combination.verify(hand))
assert(!combination.verify(hand)) // Because it's a pair
}
}