dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit ad1476a94ba1b98bf84722db725e9757666b0b58
parent 5eb1901c351f1ba95337c2958f690374df8de4bd
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu,  7 Dec 2023 18:31:11 -0500

cleanup

Diffstat:
Mpkg/web/handlers/poker/poker.go | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -752,6 +752,7 @@ type PlayerGain struct { } func processPot(winners []GameResult, nbPlayers, mainPot int) (winnersStr, winnerHand string, res []PlayerGain) { + winnersStrArr := make([]string, 0) if len(winners) == 0 { logrus.Error("winners has len 0") } else if len(winners) == 1 && len(winners[0].Players) == 1 { @@ -759,7 +760,7 @@ func processPot(winners []GameResult, nbPlayers, mainPot int) (winnersStr, winne player := winners[0].Players[0] winnerHand = "Only player alive" res = append(res, PlayerGain{player, mainPot}) - winnersStr += player.Username + winnersStrArr = append(winnersStrArr, player.Username) } else { isDone := true for _, group := range winners { @@ -769,7 +770,7 @@ func processPot(winners []GameResult, nbPlayers, mainPot int) (winnersStr, winne player := group.Players[0] winnerHand = poker.RankString(group.HandScore) res = append(res, PlayerGain{player, mainPot}) - winnersStr += player.Username + 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] @@ -789,7 +790,7 @@ func processPot(winners []GameResult, nbPlayers, mainPot int) (winnersStr, winne piece := utils.MinInt(maxGain, expectedSplit) res = append(res, PlayerGain{p, piece}) mainPot -= piece - winnersStr += p.Username + winnersStrArr = append(winnersStrArr, p.Username) if nbPlayersInGroup-allInCount > 0 { expectedSplit = mainPot / (nbPlayersInGroup - allInCount) } else { @@ -805,7 +806,7 @@ func processPot(winners []GameResult, nbPlayers, mainPot int) (winnersStr, winne for _, p := range group.Players { if p.Cash > 0 { res = append(res, PlayerGain{p, piece}) - winnersStr += p.Username + winnersStrArr = append(winnersStrArr, p.Username) } } winnerHand = poker.RankString(group.HandScore) @@ -815,6 +816,7 @@ func processPot(winners []GameResult, nbPlayers, mainPot int) (winnersStr, winne } } } + winnersStr = strings.Join(winnersStrArr, ", ") return winnersStr, winnerHand, res }