dkforest

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

commit cc97239f2355ec80f367e14cf0772f0f00e34e52
parent ed82386e955355e3b951de4ea91b0a6b3b69d6a9
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sun, 17 Dec 2023 05:21:18 -0500

cleanup

Diffstat:
Mpkg/web/handlers/poker/poker.go | 32+++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -550,7 +550,8 @@ type AutoAction struct { } // Return either or not the game ended because only 1 player left playing (or none) -func execBettingRound(g *PokerGame, roomID RoomID, skip int, minBet database.PokerChip) bool { +func execBettingRound(g *PokerGame, skip int, minBet database.PokerChip) bool { + roomID := g.RoomID roomTopic := roomID.Topic() dealerIdx := g.Ongoing.getPlayerIdxBySeatIdx(int(g.DealerSeatIdx.Load())) playerToPlayIdx := (dealerIdx + skip) % len(g.Ongoing.Players) @@ -951,7 +952,8 @@ func computeAllInMaxGain(g *PokerGame, newlyAllInPlayers []*PokerPlayer, mainPot } } -func dealerThread(g *PokerGame, roomID RoomID) { +func dealerThread(g *PokerGame) { + roomID := g.RoomID roomTopic := roomID.Topic() bigBlindBet := g.PokerTableMinBet collectRake := false @@ -1005,10 +1007,10 @@ func dealerThread(g *PokerGame, roomID RoomID) { PokerPubSub.Pub(roomTopic, GameStartedEvent{DealerSeatIdx: int(g.DealerSeatIdx.Load())}) g.newLogEvent(fmt.Sprintf("-- New game --")) - applySmallBlindBet(g, bigBlindBet, roomID) + applySmallBlindBet(g, bigBlindBet) time.Sleep(time.Second) - applyBigBlindBet(g, bigBlindBet, roomID) + applyBigBlindBet(g, bigBlindBet) time.Sleep(time.Second) // Deal players cards @@ -1017,7 +1019,7 @@ func dealerThread(g *PokerGame, roomID RoomID) { // Wait for players to bet/call/check/fold... time.Sleep(time.Second) skip := utils.Ternary(isHeadsUpGame, 1, 2) - if execBettingRound(g, roomID, skip, bigBlindBet) { + if execBettingRound(g, skip, bigBlindBet) { goto END } @@ -1036,7 +1038,7 @@ func dealerThread(g *PokerGame, roomID RoomID) { // Wait for players to bet/call/check/fold... time.Sleep(time.Second) - if execBettingRound(g, roomID, skip, 0) { + if execBettingRound(g, skip, 0) { goto END } @@ -1048,7 +1050,7 @@ func dealerThread(g *PokerGame, roomID RoomID) { // Wait for players to bet/call/check/fold... time.Sleep(time.Second) - if execBettingRound(g, roomID, skip, 0) { + if execBettingRound(g, skip, 0) { goto END } @@ -1060,7 +1062,7 @@ func dealerThread(g *PokerGame, roomID RoomID) { // Wait for players to bet/call/check/fold... time.Sleep(time.Second) - if execBettingRound(g, roomID, skip, 0) { + if execBettingRound(g, skip, 0) { goto END } @@ -1088,17 +1090,17 @@ END: g.IsGameStarted.Store(false) } -func applySmallBlindBet(g *PokerGame, bigBlindBet database.PokerChip, roomID RoomID) { - applyBlindBet(g, g.smallBlindIdx, bigBlindBet/2, roomID, "small blind") +func applySmallBlindBet(g *PokerGame, bigBlindBet database.PokerChip) { + applyBlindBet(g, g.smallBlindIdx, bigBlindBet/2, "small blind") } -func applyBigBlindBet(g *PokerGame, bigBlindBet database.PokerChip, roomID RoomID) { - applyBlindBet(g, g.bigBlindIdx, bigBlindBet, roomID, "big blind") +func applyBigBlindBet(g *PokerGame, bigBlindBet database.PokerChip) { + applyBlindBet(g, g.bigBlindIdx, bigBlindBet, "big blind") } -func applyBlindBet(g *PokerGame, playerIdx int, bet database.PokerChip, roomID RoomID, name string) { +func applyBlindBet(g *PokerGame, playerIdx int, bet database.PokerChip, name string) { p := g.Ongoing.Players[playerIdx] - p.doBetAndNotif(g.DB, g.PokerTableID, bet, roomID.Topic()) + p.doBetAndNotif(g.DB, g.PokerTableID, bet, g.RoomID.Topic()) g.newLogEvent(fmt.Sprintf("%s %s %d", p.Username, name, bet)) } @@ -1292,7 +1294,7 @@ func (g *PokerGame) Deal(roomID RoomID, authUser *database.User) { g.Ongoing = NewOngoing(g) - go dealerThread(g, roomID) + go dealerThread(g) } func (g *PokerGame) CountEligibleSeated() (count int) {