commit 846e561676224146e27c5f8a8ef5200a76ecc840
parent df7e843b024a8de728e0b0edf85422a8e6e3c935
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 7 Dec 2023 23:15:12 -0500
improve log
Diffstat:
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -748,7 +748,7 @@ END:
} else if len(playersGain) > 1 {
winnerHand = "Split pot"
for idx, el := range playersGain {
- newLogEvent(g, roomLogsTopic, fmt.Sprintf("Winner #%d: %s %s %d", idx+1, el.Player.Username, el.HandStr, el.Gain))
+ newLogEvent(g, roomLogsTopic, fmt.Sprintf("Winner #%d: %s %s %d", el.Group, el.Player.Username, el.HandStr, el.Gain))
}
}
for _, el := range playersGain {
@@ -790,6 +790,7 @@ END:
type PlayerGain struct {
Player *PokerPlayer
Gain int
+ Group int
HandStr string
}
@@ -800,11 +801,11 @@ func processPot(winners []GameResult, nbPlayers, mainPot int) (res []PlayerGain)
} else if len(winners) == 1 && len(winners[0].Players) == 1 {
// Everyone fold but 1 player
player := winners[0].Players[0]
- res = append(res, PlayerGain{player, mainPot, "Only player alive"})
+ res = append(res, PlayerGain{player, mainPot, 0, "Only player alive"})
winnersStrArr = append(winnersStrArr, player.Username)
} else {
isDone := true
- for _, group := range winners {
+ for groupIdx, group := range winners {
if mainPot == 0 {
break
}
@@ -812,14 +813,14 @@ func processPot(winners []GameResult, nbPlayers, mainPot int) (res []PlayerGain)
if len(group.Players) == 1 && group.Players[0].Cash > 0 {
// Only 1 player win and is not all-in
player := group.Players[0]
- res = append(res, PlayerGain{player, mainPot, poker.RankString(group.HandScore)})
+ res = append(res, PlayerGain{player, mainPot, groupIdx, poker.RankString(group.HandScore)})
winnersStrArr = append(winnersStrArr, player.Username)
} else if len(group.Players) == 1 && group.Players[0].Cash == 0 {
// Only 1 player win but is all-in
player := group.Players[0]
maxGain := player.RoundTotalBet * nbPlayers
piece := utils.MinInt(maxGain, mainPot)
- res = append(res, PlayerGain{player, piece, poker.RankString(group.HandScore)})
+ res = append(res, PlayerGain{player, piece, groupIdx, poker.RankString(group.HandScore)})
winnersStrArr = append(winnersStrArr, player.Username)
mainPot -= piece
isDone = false
@@ -833,7 +834,7 @@ func processPot(winners []GameResult, nbPlayers, mainPot int) (res []PlayerGain)
allInCount++
maxGain := p.RoundTotalBet * nbPlayers
piece := utils.MinInt(maxGain, expectedSplit)
- res = append(res, PlayerGain{p, piece, poker.RankString(group.HandScore)})
+ res = append(res, PlayerGain{p, piece, groupIdx, poker.RankString(group.HandScore)})
mainPot -= piece
winnersStrArr = append(winnersStrArr, p.Username)
if nbPlayersInGroup-allInCount > 0 {
@@ -850,7 +851,7 @@ func processPot(winners []GameResult, nbPlayers, mainPot int) (res []PlayerGain)
piece := mainPot / (nbPlayersInGroup - allInCount) // TODO: fix this
for _, p := range group.Players {
if p.Cash > 0 {
- res = append(res, PlayerGain{p, piece, poker.RankString(group.HandScore)})
+ res = append(res, PlayerGain{p, piece, groupIdx, poker.RankString(group.HandScore)})
winnersStrArr = append(winnersStrArr, p.Username)
}
}