dkforest

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

commit ce84abad18429e0727931c4bf5d950f9c4d4f368
parent 0e40b1ef9e2bc3781a8ea43b8ae8ef8ea25b7fa6
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu, 21 Dec 2023 22:00:24 -0500

cannot fold when there is no bet

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

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -716,13 +716,19 @@ func doTimeout(g *PokerGame, p *pokerPlayer, minBet *database.PokerChip, playerA return breakGetPlayerEventLoop } -func doFold(g *PokerGame, p *pokerPlayer, playerAlive *int) int { +func doFold(g *PokerGame, p *pokerPlayer, minBet *database.PokerChip, playerAlive *int) int { + roomUserTopic := g.roomID.UserTopic(p.userID) + if p.getBet() == *minBet { + msg := fmt.Sprintf("Cannot fold if there is no bet") + PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: msg}) + return continueGetPlayerEventLoop + } foldPlayer(g, p) g.newLogEvent(fmt.Sprintf("%s fold", p.username)) *playerAlive-- if *playerAlive == 1 { - PokerPubSub.Pub(g.roomID.UserTopic(p.userID), ErrorMsgEvent{Message: ""}) + PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: ""}) return breakRoundIsSettledLoop } return doNothing @@ -844,7 +850,7 @@ func applyAutoAction(g *PokerGame, p *pokerPlayer, minBet *database.PokerChip, switch autoAction.action { case NoAction: case FoldAction: - actionResult = doFold(g, p, playerAlive) + actionResult = doFold(g, p, minBet, playerAlive) case CheckAction: actionResult = doCheck(g, p, minBet) case CallAction: @@ -866,7 +872,7 @@ func handlePlayerActionEvent(g *PokerGame, p *pokerPlayer, minBet *database.Poke p.lastActionTS = time.Now() if evt.Fold { - actionResult = doFold(g, p, playerAlive) + actionResult = doFold(g, p, minBet, playerAlive) } else if evt.Check { actionResult = doCheck(g, p, minBet) } else if evt.Call {