commit 20cb131965a31fac6da4f657b2ee8ec9b9f6c73f
parent b8e7fc235da45d1bac87bf4603be90b76edac910
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 19 Dec 2023 11:19:14 -0500
cleanup
Diffstat:
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -208,7 +208,7 @@ type playerCard struct {
type PokerGame struct {
Players utils.RWMtx[[]*seatedPlayer]
- Ongoing *Ongoing
+ ongoing *Ongoing
db *database.DkfDB
roomID RoomID
pokerTableID int64
@@ -226,8 +226,8 @@ type gameResult struct {
}
func (g *PokerGame) GetLogs() (out []LogEvent) {
- if g.Ongoing != nil {
- g.Ongoing.logEvents.RWith(func(logEvents *[]LogEvent) {
+ if g.ongoing != nil {
+ g.ongoing.logEvents.RWith(func(logEvents *[]LogEvent) {
out = make([]LogEvent, len(*logEvents))
copy(out, *logEvents)
})
@@ -448,7 +448,7 @@ func isRoundSettled(players []*pokerPlayer) bool {
}
func (g *PokerGame) incrDealerIdx() (smallBlindIdx, bigBlindIdx int) {
- ongoing := g.Ongoing
+ ongoing := g.ongoing
nbPlayers := len(ongoing.players)
dealerSeatIdx := g.dealerSeatIdx.Load()
var dealerPlayer *pokerPlayer
@@ -510,7 +510,7 @@ func (g *PokerGame) UnSit(userID database.UserID) {
}
func (g *PokerGame) unSitPlayer(gPlayers *[]*seatedPlayer, seatedPlayer *seatedPlayer) {
- ongoing := g.Ongoing
+ ongoing := g.ongoing
if ongoing != nil {
if player := ongoing.getPlayer(seatedPlayer.userID); player != nil {
g.sendUnsitPlayerEvent(player.userID)
@@ -559,7 +559,7 @@ func newOngoing(g *PokerGame) *Ongoing {
}
func (g *PokerGame) newLogEvent(msg string) {
- ongoing := g.Ongoing
+ ongoing := g.ongoing
logEvt := LogEvent{Message: msg}
PokerPubSub.Pub(g.roomID.LogsTopic(), logEvt)
if ongoing != nil {
@@ -570,7 +570,7 @@ func (g *PokerGame) newLogEvent(msg string) {
}
func showCards(g *PokerGame, seats []Seat) {
- ongoing := g.Ongoing
+ ongoing := g.ongoing
roomTopic := g.roomID.Topic()
for _, p := range ongoing.players {
if !p.folded.Load() {
@@ -599,13 +599,13 @@ func showCards(g *PokerGame, seats []Seat) {
func setWaitTurn(g *PokerGame, seatIdx int) {
evt := PokerWaitTurnEvent{Idx: seatIdx, CreatedAt: time.Now()}
PokerPubSub.Pub(g.roomID.Topic(), evt)
- g.Ongoing.waitTurnEvent.With(func(v *PokerWaitTurnEvent) { *v = evt })
+ g.ongoing.waitTurnEvent.With(func(v *PokerWaitTurnEvent) { *v = evt })
}
func setAutoAction(g *PokerGame, roomUserTopic, msg string) {
evt := AutoActionEvent{Message: msg}
PokerPubSub.Pub(roomUserTopic, evt)
- g.Ongoing.autoActionEvent.With(func(v *AutoActionEvent) { *v = evt })
+ g.ongoing.autoActionEvent.With(func(v *AutoActionEvent) { *v = evt })
}
type PlayerAction int
@@ -661,11 +661,11 @@ func foldPlayer(g *PokerGame, p *pokerPlayer) {
evt2 := PokerEvent{ID: "card" + itoa(secondCardIdx), Name: "", Idx: secondCardIdx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false}
PokerPubSub.Pub(roomTopic, evt1)
PokerPubSub.Pub(roomTopic, evt2)
- g.Ongoing.addEvent(evt1, evt2)
+ g.ongoing.addEvent(evt1, evt2)
}
func doUnsit(g *PokerGame, p *pokerPlayer, playerAlive *int) int {
- *playerAlive = g.Ongoing.countAlivePlayers()
+ *playerAlive = g.ongoing.countAlivePlayers()
if *playerAlive == 1 {
p.countChancesToAction--
return breakRoundIsSettledLoop
@@ -853,7 +853,7 @@ func handlePlayerActionEvent(g *PokerGame, p *pokerPlayer, minBet *database.Poke
// Return either or not the game ended because only 1 player left playing (or none)
func execBettingRound(g *PokerGame, skip int, minBet database.PokerChip) bool {
db := g.db
- ongoing := g.Ongoing
+ ongoing := g.ongoing
roomID := g.roomID
roomTopic := roomID.Topic()
_, dealerIdx := ongoing.getPlayerBySeatIdx(int(g.dealerSeatIdx.Load()))
@@ -1014,7 +1014,7 @@ var dealerTokenPos = [][]int{
}
func burnCard(g *PokerGame, idx, burnIdx *int) {
- ongoing := g.Ongoing
+ ongoing := g.ongoing
*idx++
evt := PokerEvent{
ID: "card" + itoa(*idx),
@@ -1029,7 +1029,7 @@ func burnCard(g *PokerGame, idx, burnIdx *int) {
}
func dealCard(g *PokerGame, idx *int, dealCardIdx int) {
- ongoing := g.Ongoing
+ ongoing := g.ongoing
card := ongoing.deck[*idx]
*idx++
evt := PokerEvent{
@@ -1047,7 +1047,7 @@ func dealCard(g *PokerGame, idx *int, dealCardIdx int) {
func dealPlayersCards(g *PokerGame, seats []Seat, idx *int) {
roomID := g.roomID
- ongoing := g.Ongoing
+ ongoing := g.ongoing
roomTopic := roomID.Topic()
var card string
for cardIdx := 1; cardIdx <= NbCardsPerPlayer; cardIdx++ {
@@ -1109,13 +1109,13 @@ func computeAllInMaxGain(ongoing *Ongoing, newlyAllInPlayers []*pokerPlayer, mai
}
func dealerThread(g *PokerGame) {
- g.Ongoing = newOngoing(g)
+ g.ongoing = newOngoing(g)
roomID := g.roomID
roomTopic := roomID.Topic()
bigBlindBet := g.PokerTableMinBet
collectRake := false
- ongoing := g.Ongoing
+ ongoing := g.ongoing
isHeadsUpGame := ongoing.isHeadsUpGame()
seats := []Seat{
@@ -1229,13 +1229,13 @@ func applyBigBlindBet(g *PokerGame, bigBlindBet database.PokerChip, bbIdx int) {
}
func applyBlindBet(g *PokerGame, playerIdx int, bet database.PokerChip, name string) {
- p := g.Ongoing.players[playerIdx]
+ p := g.ongoing.players[playerIdx]
p.doBetAndNotif(g.db, g.pokerTableID, bet, g.roomID.Topic())
g.newLogEvent(fmt.Sprintf("%s %s %d", p.username, name, bet))
}
func autoUnsitInactivePlayers(g *PokerGame) {
- ongoing := g.Ongoing
+ ongoing := g.ongoing
pokerTableMinBet := g.PokerTableMinBet
g.Players.With(func(gPlayers *[]*seatedPlayer) {
for _, p := range *gPlayers {
@@ -1272,7 +1272,7 @@ const (
)
func applyGains(g *PokerGame, playersGain []PlayerGain, mainPot, rake database.PokerChip) (winnersStr, winnerHand string) {
- ongoing := g.Ongoing
+ ongoing := g.ongoing
pokerTableID := g.pokerTableID
nbPlayersGain := len(playersGain)
g.db.With(func(tx *database.DkfDB) {
@@ -1512,7 +1512,7 @@ func colorForCard(name string) string {
func buildDealerTokenHtml(g *PokerGame) (html string) {
html += `<div id="dealerToken"><div class="inner"></div></div>`
- if g.Ongoing != nil {
+ if g.ongoing != nil {
pos := dealerTokenPos[g.dealerSeatIdx.Load()]
top := itoa(pos[0])
left := itoa(pos[1])
@@ -1586,7 +1586,7 @@ func buildGameDiv(g *PokerGame, authUser *database.User) (html string) {
}
func BuildBaseHtml(g *PokerGame, authUser *database.User) (html string) {
- ongoing := g.Ongoing
+ ongoing := g.ongoing
roomID := g.roomID
html += hutils.HtmlCssReset
html += pokerCss
@@ -1721,7 +1721,7 @@ func buildCardsHtml() (html string) {
}
func buildMainPotHtml(g *PokerGame) string {
- ongoing := g.Ongoing
+ ongoing := g.ongoing
html := `<div id="mainPot"></div>`
mainPot := uint64(0)
if ongoing != nil {
@@ -1803,7 +1803,7 @@ func buildSeatsHtml(g *PokerGame, authUser *database.User) (html string) {
}
func drawSeatsStyle(authUser *database.User, g *PokerGame) string {
- ongoing := g.Ongoing
+ ongoing := g.ongoing
html := "<style>"
seated := g.isSeated(authUser.ID)
g.Players.RWith(func(players *[]*seatedPlayer) {