dkforest

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

commit f85e0ee6122bb0b17231ba13f25b01d13a625cc2
parent 538fc86cc8940c2314fcb01e56b74778bd7e5a07
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon, 25 Dec 2023 11:38:21 -0500

cleanup

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

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -228,6 +228,11 @@ type PokerPlayer struct { countChancesToAction int } +func (p *PokerPlayer) maxGain(mainPot database.PokerChip) database.PokerChip { + m := utils.MinInt(p.allInMaxGain, mainPot) + return utils.Ternary(p.isAllIn(), m, mainPot) +} + func (g *Game) IsBet() (out bool) { if g.ongoing != nil { return !g.ongoing.hasBet.Get() @@ -1532,10 +1537,7 @@ func processPot(winners []gameResult, mainPot, pokerTableMinBet database.PokerCh handStr := poker.RankString(group.handScore) if groupPlayersLen == 1 { player := groupPlayers[0] - piece := mainPot - if player.isAllIn() { - piece = utils.MinInt(player.allInMaxGain, piece) - } + piece := player.maxGain(mainPot) res = append(res, newPlayerGain(player, piece, groupIdx, handStr)) mainPot -= piece if player.isAllIn() { // Only 1 player win but is all-in @@ -1543,12 +1545,12 @@ func processPot(winners []gameResult, mainPot, pokerTableMinBet database.PokerCh } } else if groupPlayersLen > 1 { // Multiple winners, split pot - expectedSplit := mainPot / database.PokerChip(groupPlayersLen) allInCount := 0 + expectedSplit := mainPot / database.PokerChip(groupPlayersLen-allInCount) for _, p := range groupPlayers { if p.isAllIn() { allInCount++ - piece := utils.MinInt(p.allInMaxGain, expectedSplit, mainPot) + piece := utils.MinInt(p.maxGain(mainPot), expectedSplit) res = append(res, newPlayerGain(p, piece, groupIdx, handStr)) mainPot -= piece if groupPlayersLen-allInCount > 0 {