commit 702f61281731920e0fb7b007afe35f40fdb9cbd8
parent 8e061cc7d0a366459441f31457e153d1d8f4fad1
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 25 Dec 2023 10:44:57 -0500
cleanup
Diffstat:
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -865,34 +865,33 @@ func doAllIn(g *Game, p *PokerPlayer,
}
func doRaise(g *Game, p *PokerPlayer,
- newlyAllInPlayers *[]*PokerPlayer, lastBetPlayerIdx *int, playerToPlayIdx int, evt playerEvent) int {
- evt.Bet = g.ongoing.MinRaise.Get()
- return doBet(g, p, newlyAllInPlayers, lastBetPlayerIdx, playerToPlayIdx, evt)
+ newlyAllInPlayers *[]*PokerPlayer, lastBetPlayerIdx *int, playerToPlayIdx int) int {
+ return doBet(g, p, newlyAllInPlayers, lastBetPlayerIdx, playerToPlayIdx, g.ongoing.MinRaise.Get())
}
func doBet(g *Game, p *PokerPlayer,
- newlyAllInPlayers *[]*PokerPlayer, lastBetPlayerIdx *int, playerToPlayIdx int, evt playerEvent) int {
+ newlyAllInPlayers *[]*PokerPlayer, lastBetPlayerIdx *int, playerToPlayIdx int, evtBet database.PokerChip) int {
roomTopic := g.roomID.Topic()
roomUserTopic := g.roomID.UserTopic(p.userID)
minBet := g.ongoing.MinBet.Get()
minRaise := g.ongoing.MinRaise.Get()
playerBet := p.bet.Get() // Player's chips already on the table
callDelta := minBet - playerBet // Chips missing to equalize the minBet
- bet := evt.Bet + callDelta // Amount of chips player need to put on the table to make the raise
+ bet := evtBet + callDelta // Amount of chips player need to put on the table to make the raise
playerTotalBet := bet + playerBet // Player's total bet during the betting round
if bet >= p.cash.Get() {
return doAllIn(g, p, newlyAllInPlayers, lastBetPlayerIdx, playerToPlayIdx)
}
betLbl := utils.Ternary(g.IsBet(), "bet", "raise")
// Ensure the player cannot bet below the table minimum bet (amount of the big blind)
- if evt.Bet < minRaise {
- msg := fmt.Sprintf("%s (%d) is too low. Must %s at least %d", betLbl, evt.Bet, betLbl, minRaise)
+ if evtBet < minRaise {
+ msg := fmt.Sprintf("%s (%d) is too low. Must %s at least %d", betLbl, evtBet, betLbl, minRaise)
PubSub.Pub(roomUserTopic, NewErrorMsgEvent(msg))
return continueGetPlayerEventLoop
}
*lastBetPlayerIdx = playerToPlayIdx
- PubSub.Pub(g.roomID.Topic(), PokerMinRaiseUpdatedEvent{MinRaise: evt.Bet})
- g.ongoing.MinRaise.Set(evt.Bet)
+ PubSub.Pub(g.roomID.Topic(), PokerMinRaiseUpdatedEvent{MinRaise: evtBet})
+ g.ongoing.MinRaise.Set(evtBet)
g.ongoing.MinBet.Set(playerTotalBet)
p.doBetAndNotif(g.db, g.pokerTableID, bet, roomTopic)
@@ -965,9 +964,9 @@ func handlePlayerActionEvent(g *Game, p *PokerPlayer,
} else if evt.AllIn {
actionResult = doAllIn(g, p, newlyAllInPlayers, lastBetPlayerIdx, playerToPlayIdx)
} else if evt.Raise {
- actionResult = doRaise(g, p, newlyAllInPlayers, lastBetPlayerIdx, playerToPlayIdx, evt)
+ actionResult = doRaise(g, p, newlyAllInPlayers, lastBetPlayerIdx, playerToPlayIdx)
} else if evt.Bet > 0 {
- actionResult = doBet(g, p, newlyAllInPlayers, lastBetPlayerIdx, playerToPlayIdx, evt)
+ actionResult = doBet(g, p, newlyAllInPlayers, lastBetPlayerIdx, playerToPlayIdx, evt.Bet)
} else {
actionResult = continueGetPlayerEventLoop
}