dkforest

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

commit fc5d524d05e4f8d6738f5d50f49511ed9b426e7a
parent aa969934194d7e92799a872a1a1017aa54ceb470
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri, 15 Dec 2023 05:56:00 -0500

cleanup

Diffstat:
Mpkg/web/handlers/poker/poker.go | 37+++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -510,8 +510,9 @@ func waitPlayersActionFn(db *database.DkfDB, g *PokerGame, roomID RoomID, skip i // TODO: implement maximum re-raise -OUTER: +RoundIsSettledLoop: for { // Repeat until the round is settled (all players have equals bet or fold or all-in) + AllPlayersLoop: for { // Repeat until all players have played playerToPlayIdx = (playerToPlayIdx + 1) % len(g.Ongoing.Players) p := g.Ongoing.Players[playerToPlayIdx] @@ -519,13 +520,13 @@ OUTER: roomUserTopic := roomID.UserTopic(pUsername) if playerToPlayIdx == lastRaisePlayerIdx { - break + break AllPlayersLoop } if lastRaisePlayerIdx == -1 { lastRaisePlayerIdx = playerToPlayIdx } if p.Folded.Load() || p.isAllIn() { - continue + continue AllPlayersLoop } setWaitTurn(g, roomTopic, p.SeatIdx) @@ -533,7 +534,7 @@ OUTER: // Maximum time allowed for the player to send his action waitCh := time.After(MaxUserCountdown * time.Second) - LOOP: + GetPlayerEventLoop: for { // Repeat until we get an event from the player we're interested in var evt PlayerEvent @@ -547,24 +548,24 @@ OUTER: playerAlive-- if playerAlive == 1 { - break OUTER + break RoundIsSettledLoop } - break LOOP + break GetPlayerEventLoop } newLogEvent(g, roomLogsTopic, fmt.Sprintf("%s auto check", pUsername)) - break LOOP + break GetPlayerEventLoop } if evt.Unsit { playerAlive = g.Ongoing.CountAlivePlayers() if playerAlive == 1 { - break OUTER + break RoundIsSettledLoop } - continue LOOP + continue GetPlayerEventLoop } if evt.Player != pUsername { - continue LOOP + continue GetPlayerEventLoop } p.LastActionTS = time.Now() @@ -576,13 +577,13 @@ OUTER: playerAlive-- if playerAlive == 1 { PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: ""}) - break OUTER + break RoundIsSettledLoop } } else if evt.Check { if p.Bet < minBet { msg := fmt.Sprintf("Need to bet %d", minBet-p.Bet) PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: msg}) - continue LOOP + continue GetPlayerEventLoop } newLogEvent(g, roomLogsTopic, fmt.Sprintf("%s check", pUsername)) @@ -622,17 +623,17 @@ OUTER: if bet < pokerTableMinBet { msg := fmt.Sprintf("Bet (%d) is too low. Must bet at least %d", bet, pokerTableMinBet) PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: msg}) - continue LOOP + continue GetPlayerEventLoop } if (p.Bet + bet) < minBet { msg := fmt.Sprintf("Bet (%d) is too low. Must bet at least %d", bet, minBet-p.Bet) PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: msg}) - continue LOOP + continue GetPlayerEventLoop } if bet > p.Cash { msg := fmt.Sprintf("Bet (%d) is too high. Must bet at most %d", bet, p.Cash) PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: msg}) - continue LOOP + continue GetPlayerEventLoop } if (p.Bet + bet) > minBet { lastRaisePlayerIdx = playerToPlayIdx @@ -648,15 +649,15 @@ OUTER: newLogEvent(g, roomLogsTopic, logMsg) } else { - continue LOOP + continue GetPlayerEventLoop } PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: ""}) - break LOOP + break GetPlayerEventLoop } // End of repeat until we get an event from the player we're interested in } // End of repeat until all players have played // All settle when all players have the same bet amount if isRoundSettled(g.Ongoing.Players) { - break OUTER + break RoundIsSettledLoop } } // End of repeat until the round is settled (all players have equals bet or fold or all-in)