commit 6e771e4813f10c6fd7c40a40c7e646450934746f
parent 7f254db17234c333991c6ba3de0f97707f65d96a
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sun, 17 Dec 2023 05:00:06 -0500
cleanup
Diffstat:
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -475,7 +475,7 @@ func NewOngoing(g *PokerGame) *Ongoing {
return &Ongoing{Deck: deck, Players: players, WaitTurnEvent: PokerWaitTurnEvent{Idx: -1}, CreatedAt: time.Now()}
}
-func newLogEvent(g *PokerGame, msg string) {
+func (g *PokerGame) newLogEvent(msg string) {
logEvt := LogEvent{Message: msg}
PokerPubSub.Pub(g.RoomID.LogsTopic(), logEvt)
if g.Ongoing != nil {
@@ -595,7 +595,7 @@ RoundIsSettledLoop:
doTimeout := func() int {
if p.GetBet() < minBet {
foldPlayer(p)
- newLogEvent(g, fmt.Sprintf("%s auto fold", pUsername))
+ g.newLogEvent(fmt.Sprintf("%s auto fold", pUsername))
playerAlive--
if playerAlive == 1 {
@@ -603,7 +603,7 @@ RoundIsSettledLoop:
}
return breakGetPlayerEventLoop
}
- newLogEvent(g, fmt.Sprintf("%s auto check", pUsername))
+ g.newLogEvent(fmt.Sprintf("%s auto check", pUsername))
return breakGetPlayerEventLoop
}
@@ -618,7 +618,7 @@ RoundIsSettledLoop:
doFold := func() int {
foldPlayer(p)
- newLogEvent(g, fmt.Sprintf("%s fold", pUsername))
+ g.newLogEvent(fmt.Sprintf("%s fold", pUsername))
playerAlive--
if playerAlive == 1 {
@@ -634,14 +634,14 @@ RoundIsSettledLoop:
PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: msg})
return continueGetPlayerEventLoop
}
- newLogEvent(g, fmt.Sprintf("%s check", pUsername))
+ g.newLogEvent(fmt.Sprintf("%s check", pUsername))
return doNothing
}
doCall := func() int {
bet := utils.MinInt(minBet-p.GetBet(), p.GetCash())
if bet == 0 {
- newLogEvent(g, fmt.Sprintf("%s check", pUsername))
+ g.newLogEvent(fmt.Sprintf("%s check", pUsername))
} else {
p.doBetAndNotif(db, g.PokerTableID, bet, roomTopic)
logMsg := fmt.Sprintf("%s call (%d)", pUsername, bet)
@@ -649,7 +649,7 @@ RoundIsSettledLoop:
logMsg += " (all-in)"
newlyAllInPlayers = append(newlyAllInPlayers, p)
}
- newLogEvent(g, logMsg)
+ g.newLogEvent(logMsg)
}
return doNothing
}
@@ -665,7 +665,7 @@ RoundIsSettledLoop:
if p.isAllIn() {
newlyAllInPlayers = append(newlyAllInPlayers, p)
}
- newLogEvent(g, logMsg)
+ g.newLogEvent(logMsg)
return doNothing
}
@@ -698,7 +698,7 @@ RoundIsSettledLoop:
logMsg += " (all-in)"
newlyAllInPlayers = append(newlyAllInPlayers, p)
}
- newLogEvent(g, logMsg)
+ g.newLogEvent(logMsg)
return doNothing
}
@@ -829,7 +829,7 @@ RoundIsSettled:
PokerPubSub.Pub(roomTopic, AutoActionEvent{Message: ""})
PokerPubSub.Pub(roomTopic, ErrorMsgEvent{Message: ""})
- newLogEvent(g, fmt.Sprintf("--"))
+ g.newLogEvent(fmt.Sprintf("--"))
setWaitTurn(g, roomTopic, -1)
time.Sleep(time.Second)
@@ -993,7 +993,7 @@ func dealerThread(db *database.DkfDB, g *PokerGame, roomID RoomID) {
}
PokerPubSub.Pub(roomTopic, GameStartedEvent{DealerSeatIdx: int(g.DealerSeatIdx.Load())})
- newLogEvent(g, fmt.Sprintf("-- New game --"))
+ g.newLogEvent(fmt.Sprintf("-- New game --"))
applySmallBlindBet(db, g, bigBlindBet, roomID)
time.Sleep(time.Second)
@@ -1067,7 +1067,7 @@ END:
g.Ongoing.setMainPot(0)
PokerPubSub.Pub(roomTopic, GameIsDoneEvent{Winner: winnersStr, WinnerHand: winnerHand})
- newLogEvent(g, fmt.Sprintf("-- Game ended --"))
+ g.newLogEvent(fmt.Sprintf("-- Game ended --"))
// Wait a minimum of X seconds before allowing a new game
time.Sleep(MinTimeAfterGame * time.Second)
@@ -1089,7 +1089,7 @@ func applyBigBlindBet(db *database.DkfDB, g *PokerGame, bigBlindBet database.Pok
func applyBlindBet(db *database.DkfDB, g *PokerGame, playerIdx int, bet database.PokerChip, roomID RoomID, name string) {
p := g.Ongoing.Players[playerIdx]
p.doBetAndNotif(db, g.PokerTableID, bet, roomID.Topic())
- newLogEvent(g, fmt.Sprintf("%s %s %d", p.Username, name, bet))
+ g.newLogEvent(fmt.Sprintf("%s %s %d", p.Username, name, bet))
}
func autoUnsitInactivePlayers(db *database.DkfDB, g *PokerGame, roomID RoomID) {
@@ -1111,7 +1111,7 @@ func autoUnsitInactivePlayers(db *database.DkfDB, g *PokerGame, roomID RoomID) {
if playerShallBeBooted {
if err := g.UnSitPlayer1(db, roomID, p, idx); err == nil {
PokerPubSub.Pub(roomTopic, PokerSeatLeftEvent{})
- newLogEvent(g, fmt.Sprintf("%s auto un-sit", p.Username))
+ g.newLogEvent(fmt.Sprintf("%s auto un-sit", p.Username))
} else {
fmt.Println(err)
}
@@ -1129,10 +1129,10 @@ func applyGains(db *database.DkfDB, g *PokerGame, playersGain []PlayerGain, main
if !g.PokerTableIsTest {
_ = tx.IncrPokerCasinoRake(rake)
}
- newLogEvent(g, fmt.Sprintf("Rake %d (%.2f%%)", rake, (float64(rake)/float64(mainPot))*100))
+ g.newLogEvent(fmt.Sprintf("Rake %d (%.2f%%)", rake, (float64(rake)/float64(mainPot))*100))
for _, el := range playersGain {
- newLogEvent(g, fmt.Sprintf("Winner #%d: %s %s -> %d", el.Group, el.Player.Username, el.HandStr, el.Gain))
+ g.newLogEvent(fmt.Sprintf("Winner #%d: %s %s -> %d", el.Group, el.Player.Username, el.HandStr, el.Gain))
winnersStr += el.Player.Username.String() + " "
el.Player.gain(tx, g.PokerTableID, el.Gain)
}
@@ -1470,7 +1470,7 @@ func PokerUnSitHandler(c echo.Context) error {
if c.Request().Method == http.MethodPost {
if err := g.UnSitPlayer(db, roomID, authUser); err == nil {
PokerPubSub.Pub(roomTopic, PokerSeatLeftEvent{})
- newLogEvent(g, fmt.Sprintf("%s un-sit", authUser.Username.String()))
+ g.newLogEvent(fmt.Sprintf("%s un-sit", authUser.Username.String()))
} else {
logrus.Error(err)
}
@@ -1547,7 +1547,7 @@ func PokerSitHandler(c echo.Context) error {
tableAccount.DoSave(tx)
tx.Commit()
PokerPubSub.Pub(roomTopic, PokerSeatTakenEvent{})
- newLogEvent(g, fmt.Sprintf("%s sit", authUser.Username.String()))
+ g.newLogEvent(fmt.Sprintf("%s sit", authUser.Username.String()))
}
return c.HTML(http.StatusOK, html)
}