37 lines
553 B
Go
37 lines
553 B
Go
package pokercore
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
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
|
|
}
|
|
|
|
func (x HandScore) String() string {
|
|
return fmt.Sprintf("<HandScore %d>", x)
|
|
}
|