2024-05-19 00:33:15 +00:00
|
|
|
package pokercore
|
|
|
|
|
2024-05-19 03:26:08 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
2024-05-19 00:33:15 +00:00
|
|
|
|
|
|
|
type HandScore int
|
|
|
|
|
|
|
|
const (
|
|
|
|
ScoreHighCard = HandScore(iota * 100_000_000_000)
|
|
|
|
ScorePair
|
|
|
|
ScoreTwoPair
|
|
|
|
ScoreThreeOfAKind
|
|
|
|
ScoreStraight
|
|
|
|
ScoreFlush
|
|
|
|
ScoreFullHouse
|
|
|
|
ScoreFourOfAKind
|
|
|
|
ScoreStraightFlush
|
|
|
|
ScoreRoyalFlush
|
|
|
|
)
|
|
|
|
|
|
|
|
func (c Card) Score() HandScore {
|
|
|
|
return HandScore(c.Rank.Score())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c Cards) PokerHandScore() (HandScore, error) {
|
|
|
|
ph, err := c.PokerHand()
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return ph.Score, nil
|
|
|
|
}
|
2024-05-19 05:10:53 +00:00
|
|
|
|
2024-05-19 00:33:15 +00:00
|
|
|
func (x HandScore) String() string {
|
|
|
|
return fmt.Sprintf("<HandScore %d>", x)
|
|
|
|
}
|