commit 5db8bfa5dbe7c11c2539934ea3bfa21da9ecf611
parent 83fbf2932571cac53ad57b77c10edc3e3e254543
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 18 Dec 2023 06:48:45 -0500
cleanup
Diffstat:
1 file changed, 26 insertions(+), 21 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -1178,6 +1178,31 @@ type PlayerGain struct {
HandStr string
}
+func calculateRake(mainPot, pokerTableMinBet database.PokerChip, nbPlayers int) (rake database.PokerChip) {
+ // https://www.pokerstars.com/poker/room/rake
+ // BB: pct, 2P, 3-4P, 5+P
+ rakeTable := map[database.PokerChip][]float64{
+ 3: {0.035, 178, 178, 178},
+ 20: {0.0415, 297, 297, 595},
+ 200: {0.05, 446, 446, 1190},
+ }
+ maxRake := pokerTableMinBet * 15
+ rakePct := 0.045
+ if val, ok := rakeTable[pokerTableMinBet]; ok {
+ rakePct = val[0]
+ if nbPlayers == 2 {
+ maxRake = database.PokerChip(val[1])
+ } else if nbPlayers == 3 || nbPlayers == 4 {
+ maxRake = database.PokerChip(val[2])
+ } else if nbPlayers >= 5 {
+ maxRake = database.PokerChip(val[3])
+ }
+ }
+ rake = database.PokerChip(math.RoundToEven(rakePct * float64(mainPot)))
+ rake = utils.MinInt(rake, maxRake) // Max rake
+ return rake
+}
+
func processPot(winners []GameResult, mainPot, pokerTableMinBet database.PokerChip, collectRake bool, nbPlayers int) (res []PlayerGain, rake database.PokerChip) {
newPlayerGain := func(player *PokerPlayer, gain database.PokerChip, groupIdx int, handStr string) PlayerGain {
return PlayerGain{Player: player, Gain: gain, Group: groupIdx, HandStr: handStr}
@@ -1189,27 +1214,7 @@ func processPot(winners []GameResult, mainPot, pokerTableMinBet database.PokerCh
}
if collectRake {
- // https://www.pokerstars.com/poker/room/rake
- // BB: pct, 2P, 3-4P, 5+P
- rakeTable := map[database.PokerChip][]float64{
- 3: {0.035, 178, 178, 178},
- 20: {0.0415, 297, 297, 595},
- 200: {0.05, 446, 446, 1190},
- }
- maxRake := pokerTableMinBet * 15
- rakePct := 0.045
- if val, ok := rakeTable[pokerTableMinBet]; ok {
- rakePct = val[0]
- if nbPlayers == 2 {
- maxRake = database.PokerChip(val[1])
- } else if nbPlayers == 3 || nbPlayers == 4 {
- maxRake = database.PokerChip(val[2])
- } else if nbPlayers >= 5 {
- maxRake = database.PokerChip(val[3])
- }
- }
- rake = database.PokerChip(math.RoundToEven(rakePct * float64(mainPot)))
- rake = utils.MinInt(rake, maxRake) // Max rake
+ rake = calculateRake(mainPot, pokerTableMinBet, nbPlayers)
mainPot -= rake
}