dkforest

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

commit 6c854f13203338f7d36f35cd9870fd54f2e70214
parent 0d696ca9432c576b6f2e418af847594f7b507d40
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon, 25 Dec 2023 12:11:13 -0500

cleanup

Diffstat:
Mpkg/web/handlers/poker/poker.go | 42++++++++++++++++--------------------------
1 file changed, 16 insertions(+), 26 deletions(-)

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -1535,35 +1535,25 @@ func processPot(winners []gameResult, mainPot, pokerTableMinBet database.PokerCh groupPlayers := group.players groupPlayersLen := len(groupPlayers) handStr := poker.RankString(group.handScore) - if groupPlayersLen == 1 { - player := groupPlayers[0] - piece := player.maxGain(mainPot) - res = append(res, newPlayerGain(player, piece, groupIdx, handStr)) + // 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 := 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 player.isAllIn() { // Only 1 player win but is all-in - continue - } - } 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 := 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++ - 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 + if p.isAllIn() { + allInCount++ + 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 + } break } }