dkforest

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

commit 0d696ca9432c576b6f2e418af847594f7b507d40
parent f85e0ee6122bb0b17231ba13f25b01d13a625cc2
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon, 25 Dec 2023 12:05:51 -0500

cleanup

Diffstat:
Mpkg/web/handlers/poker/poker.go | 25++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -1545,33 +1545,24 @@ func processPot(winners []gameResult, mainPot, pokerTableMinBet database.PokerCh } } else if groupPlayersLen > 1 { // Multiple winners, split pot + calcExpectedSplit := func(mainPot database.PokerChip, allInCount int) database.PokerChip { + return mainPot / utils.MaxInt(database.PokerChip(groupPlayersLen-allInCount), 1) + } allInCount := 0 - expectedSplit := mainPot / database.PokerChip(groupPlayersLen-allInCount) + expectedSplit := calcExpectedSplit(mainPot, allInCount) for _, p := range groupPlayers { + piece := utils.MinInt(p.maxGain(mainPot), expectedSplit) + res = append(res, newPlayerGain(p, piece, groupIdx, handStr)) + mainPot -= piece if p.isAllIn() { allInCount++ - piece := utils.MinInt(p.maxGain(mainPot), expectedSplit) - res = append(res, newPlayerGain(p, piece, groupIdx, handStr)) - mainPot -= piece - if groupPlayersLen-allInCount > 0 { - expectedSplit = mainPot / database.PokerChip(groupPlayersLen-allInCount) - } else { - expectedSplit = mainPot - } + expectedSplit = calcExpectedSplit(mainPot, allInCount) } } // If everyone in the group was all-in, we need to evaluate the next group as well if allInCount == groupPlayersLen { continue } - piece := mainPot / database.PokerChip(groupPlayersLen-allInCount) - for _, p := range groupPlayers { - if p.getCash() > 0 { - piece = utils.MinInt(piece, mainPot) - res = append(res, newPlayerGain(p, piece, groupIdx, handStr)) - mainPot -= piece - } - } } break }