commit 72c1a1562dface05a2ab2f37014491f4fb0e6365
parent ebad1bb0e900c730ab27d475f0f1c2cc991c72ef
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 12 Dec 2023 19:16:39 -0500
cleanup
Diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -955,6 +955,10 @@ type PlayerGain struct {
}
func processPot(winners []GameResult, mainPot int) (res []PlayerGain) {
+ newPlayerGain := func(player *PokerPlayer, gain, groupIdx int, handStr string) PlayerGain {
+ return PlayerGain{Player: player, Gain: gain, Group: groupIdx, HandStr: handStr}
+ }
+
if len(winners) == 0 {
logrus.Error("winners has len 0")
return
@@ -962,7 +966,7 @@ func processPot(winners []GameResult, mainPot int) (res []PlayerGain) {
// Everyone fold but 1 player
player := winners[0].Players[0]
piece := mainPot
- res = append(res, PlayerGain{player, piece, 0, "Only player alive"})
+ res = append(res, newPlayerGain(player, piece, 0, "Only player alive"))
mainPot -= piece
} else {
isDone := true
@@ -976,13 +980,13 @@ func processPot(winners []GameResult, mainPot int) (res []PlayerGain) {
// Only 1 player win and is not all-in
player := group.Players[0]
piece := mainPot
- res = append(res, PlayerGain{player, piece, groupIdx, handStr})
+ res = append(res, newPlayerGain(player, piece, groupIdx, handStr))
mainPot -= piece
} else if len(group.Players) == 1 && group.Players[0].isAllIn() {
// Only 1 player win but is all-in
player := group.Players[0]
piece := utils.MinInt(player.AllInMaxGain, mainPot)
- res = append(res, PlayerGain{player, piece, groupIdx, handStr})
+ res = append(res, newPlayerGain(player, piece, groupIdx, handStr))
mainPot -= piece
isDone = false
} else if len(group.Players) > 1 {
@@ -996,7 +1000,7 @@ func processPot(winners []GameResult, mainPot int) (res []PlayerGain) {
maxGain := p.AllInMaxGain
piece := utils.MinInt(maxGain, expectedSplit)
piece = utils.MinInt(piece, mainPot)
- res = append(res, PlayerGain{p, piece, groupIdx, handStr})
+ res = append(res, newPlayerGain(p, piece, groupIdx, handStr))
mainPot -= piece
if nbPlayersInGroup-allInCount > 0 {
expectedSplit = mainPot / (nbPlayersInGroup - allInCount)
@@ -1014,7 +1018,7 @@ func processPot(winners []GameResult, mainPot int) (res []PlayerGain) {
for _, p := range group.Players {
if p.Cash > 0 {
piece = utils.MinInt(piece, mainPot)
- res = append(res, PlayerGain{p, piece, groupIdx, handStr})
+ res = append(res, newPlayerGain(p, piece, groupIdx, handStr))
mainPot -= piece
}
}