Maps a collection of cards to a poker hand, based on the rules of Texas hold'em.
- Dependency: PlayingCards
- Demo: Texas
import PlayingCards
let cards: [PlayingCard]
let hand: Hand? = Hand(cards: cards)
// Provides the highest relevant rank of the hand.
// The winning hand can be established using the less than operator (<) or sort().
enum Hand: Comparable {
case highCard(Rank)
case pair(Rank)
case twoPair(Rank)
case threeKind(Rank)
case straight(Rank)
case fourKind(Rank)
case flush(Rank)
case fullHouse(Rank)
case straightFlush(Rank)
case royalFlush
}
print(hand?.description ?? "Only able to parse card count 2...7.")