dkforest

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

commit dd62f9e76dba57a2c6ac40f13fd341f55e141747
parent 71e0202874a42f9668d8159100798fc556e1ef55
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu,  7 Dec 2023 16:35:47 -0500

cleanup

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

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -699,7 +699,7 @@ END: mainPot := g.Ongoing.MainPot g.Ongoing.MainPotMtx.RUnlock() - winnersStr, winnerHand := processPot(winners, mainPot) + winnersStr, winnerHand := processPot(winners, len(g.Players), mainPot) g.Ongoing.MainPotMtx.Lock() g.Ongoing.MainPot = 0 @@ -727,8 +727,7 @@ END: g.IsGameStarted.Store(false) } -func processPot(winners []GameResult, mainPot int) (winnersStr, winnerHand string) { - // TODO: handle all-ins +func processPot(winners []GameResult, nbPlayers, mainPot int) (winnersStr, winnerHand string) { if len(winners) == 0 { logrus.Error("winners has len 0") } else if len(winners) == 1 && len(winners[0].Players) == 1 { @@ -747,9 +746,13 @@ func processPot(winners []GameResult, mainPot int) (winnersStr, winnerHand strin winnersStr += group.Players[0].Username } else if len(group.Players) == 1 && group.Players[0].Cash == 0 { // Only 1 player win but is all-in + maxGain := group.Players[0].RoundTotalBet * nbPlayers + group.Players[0].Cash += maxGain + mainPot -= maxGain isDone = false } else if len(group.Players) > 1 { // Multiple winners, split pot + // TODO: handle all-ins nb := len(group.Players) piece := mainPot / nb // TODO: fix this for _, p := range group.Players {