commit 37af0585106bb5627c14b16018aec1b127ba62ec
parent 9b92fe0eb84b2bc0438ceff11173cc19b7af0725
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sun, 17 Dec 2023 06:10:24 -0500
cleanup
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -197,6 +197,10 @@ type GameResult struct {
Players []*PokerPlayer
}
+func (g *Ongoing) isHeadsUpGame() bool {
+ return len(g.Players) == 2 // https://en.wikipedia.org/wiki/Heads-up_poker
+}
+
func (g *Ongoing) getMainPot() (out database.PokerChip) {
return database.PokerChip(g.mainPot.Load())
}
@@ -384,7 +388,7 @@ func (g *PokerGame) incrDealerIdx() {
}
g.DealerSeatIdx.Store(dealerSeatIdx)
dealerIdx := g.Ongoing.getPlayerIdxBySeatIdx(int(dealerSeatIdx))
- startIDx := utils.Ternary(nbPlayers == 2, 0, 1)
+ startIDx := utils.Ternary(g.Ongoing.isHeadsUpGame(), 0, 1)
g.smallBlindIdx = (dealerIdx + startIDx) % nbPlayers
g.bigBlindIdx = (dealerIdx + startIDx + 1) % nbPlayers
}
@@ -959,8 +963,7 @@ func dealerThread(g *PokerGame) {
roomTopic := roomID.Topic()
bigBlindBet := g.PokerTableMinBet
collectRake := false
- nbOngoingPlayers := len(g.Ongoing.Players)
- isHeadsUpGame := nbOngoingPlayers == 2 // https://en.wikipedia.org/wiki/Heads-up_poker
+ isHeadsUpGame := g.Ongoing.isHeadsUpGame()
g.incrDealerIdx()