|
|
|
|
@@ -5,7 +5,7 @@ import (
|
|
|
|
|
"sort"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func royalFlush(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
func royalFlush(game *entity.Game, _ interface{}) int64 {
|
|
|
|
|
hand := getHand(game)
|
|
|
|
|
if !hand.Flush() || !hand.Straight() {
|
|
|
|
|
return 0
|
|
|
|
|
@@ -18,7 +18,7 @@ func royalFlush(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func straightFlush(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
func straightFlush(game *entity.Game, _ interface{}) int64 {
|
|
|
|
|
hand := getHand(game)
|
|
|
|
|
if !hand.Flush() || !hand.Straight() {
|
|
|
|
|
return 0
|
|
|
|
|
@@ -29,14 +29,14 @@ func straightFlush(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
biggest = card.Value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return uint64(biggest)
|
|
|
|
|
return int64(biggest)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func fourOfAKind(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
func fourOfAKind(game *entity.Game, _ interface{}) int64 {
|
|
|
|
|
return nOfAKind(game, 4)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func fullHouse(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
func fullHouse(game *entity.Game, _ interface{}) int64 {
|
|
|
|
|
hand := getHand(game)
|
|
|
|
|
counts := counts(hand)
|
|
|
|
|
trio := entity.Card{}
|
|
|
|
|
@@ -52,10 +52,10 @@ func fullHouse(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
if trio.Value == 0 || duo.Value == 0 {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
return uint64(trio.Value*100 + duo.Value)
|
|
|
|
|
return int64(trio.Value*100 + duo.Value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func flush(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
func flush(game *entity.Game, _ interface{}) int64 {
|
|
|
|
|
hand := getHand(game)
|
|
|
|
|
if !hand.Flush() {
|
|
|
|
|
return 0
|
|
|
|
|
@@ -63,7 +63,7 @@ func flush(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
return highCard(game, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func straight(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
func straight(game *entity.Game, _ interface{}) int64 {
|
|
|
|
|
hand := getHand(game)
|
|
|
|
|
if !hand.Straight() {
|
|
|
|
|
return 0
|
|
|
|
|
@@ -74,14 +74,14 @@ func straight(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
big = card.Value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return uint64(big)
|
|
|
|
|
return int64(big)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func threeOfAKind(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
func threeOfAKind(game *entity.Game, _ interface{}) int64 {
|
|
|
|
|
return nOfAKind(game, 3)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func twoPair(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
func twoPair(game *entity.Game, _ interface{}) int64 {
|
|
|
|
|
high := nOfAKind(game, 2)
|
|
|
|
|
if high == 0 {
|
|
|
|
|
return 0
|
|
|
|
|
@@ -92,7 +92,7 @@ func twoPair(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
low := 0
|
|
|
|
|
highCard := 0
|
|
|
|
|
for k, v := range counts {
|
|
|
|
|
if ((uint64(k.Value) != high && v >= 2) || v >= 4) && k.Value > low {
|
|
|
|
|
if ((int64(k.Value) != high && v >= 2) || v >= 4) && k.Value > low {
|
|
|
|
|
low = k.Value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -100,18 +100,18 @@ func twoPair(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
for k, v := range counts {
|
|
|
|
|
if ((uint64(k.Value) != high && k.Value != low) || v > 4 || v == 3) && k.Value > highCard {
|
|
|
|
|
if ((int64(k.Value) != high && k.Value != low) || v > 4 || v == 3) && k.Value > highCard {
|
|
|
|
|
highCard = k.Value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return high*100*100 + uint64(low*100+highCard)
|
|
|
|
|
return high*100*100 + int64(low*100+highCard)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func pair(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
func pair(game *entity.Game, _ interface{}) int64 {
|
|
|
|
|
return nOfAKind(game, 2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func nOfAKind(game *entity.Game, n int) uint64 {
|
|
|
|
|
func nOfAKind(game *entity.Game, n int) int64 {
|
|
|
|
|
hand := getHand(game)
|
|
|
|
|
counts := counts(hand)
|
|
|
|
|
best := entity.Card{}
|
|
|
|
|
@@ -129,19 +129,19 @@ func nOfAKind(game *entity.Game, n int) uint64 {
|
|
|
|
|
if best.Value == 0 {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
return uint64(best.Value*100 + high.Value)
|
|
|
|
|
return int64(best.Value*100 + high.Value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func highCard(game *entity.Game, _ interface{}) uint64 {
|
|
|
|
|
func highCard(game *entity.Game, _ interface{}) int64 {
|
|
|
|
|
hand := getHand(game)
|
|
|
|
|
values := make([]int, 0)
|
|
|
|
|
for _, card := range hand.AllCards() {
|
|
|
|
|
values = append(values, card.Value)
|
|
|
|
|
}
|
|
|
|
|
sort.Ints(values)
|
|
|
|
|
value := uint64(0)
|
|
|
|
|
value := int64(0)
|
|
|
|
|
for i := len(values) - 1; i >= 0; i-- {
|
|
|
|
|
value = value*100 + uint64(values[i])
|
|
|
|
|
value = value*100 + int64(values[i])
|
|
|
|
|
}
|
|
|
|
|
return value
|
|
|
|
|
}
|
|
|
|
|
|