dkforest

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

commit ec4a6cf4ae6e1e12a11602538ff0403b528146d0
parent cf4a20e47e46648926e03ad7cebaa35c73d7ec8e
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sat, 16 Dec 2023 15:58:51 -0500

improve auto-unsit

Diffstat:
Mpkg/web/handlers/poker/poker.go | 28++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -1061,18 +1061,22 @@ func autoUnsitInactivePlayers(db *database.DkfDB, g *PokerGame, roomID RoomID) { roomTopic := roomID.Topic() roomLogsTopic := roomID.LogsTopic() for idx, p := range g.Players { - playerShallBeBooted := false - if p != nil && p.LastActionTS.Before(g.Ongoing.CreatedAt) { - // If the player was playing the game, must be booted if he had the chance to make actions and did not. - // If the player was not playing the game, must be booted if he's not eligible to play the next one. - op := g.Ongoing.GetPlayer(p.Username) - playerShallBeBooted = (op != nil && op.countChancesToAction > 0) || - (op == nil && !p.isEligible(g.PokerTableMinBet)) - } - if playerShallBeBooted { - if err := g.UnSitPlayer1(db, roomID, p, idx); err == nil { - PokerPubSub.Pub(roomTopic, PokerSeatLeftEvent{}) - newLogEvent(g, roomLogsTopic, fmt.Sprintf("%s auto un-sit", p.Username)) + if p != nil { + playerShallBeBooted := false + if !p.isEligible(g.PokerTableMinBet) { + playerShallBeBooted = true + } else if p.LastActionTS.Before(g.Ongoing.CreatedAt) { + // If the player was playing the game, must be booted if he had the chance to make actions and did not. + // If the player was not playing the game, must be booted if he's not eligible to play the next one. + op := g.Ongoing.GetPlayer(p.Username) + playerShallBeBooted = (op != nil && op.countChancesToAction > 0) || + (op == nil && !p.isEligible(g.PokerTableMinBet)) + } + if playerShallBeBooted { + if err := g.UnSitPlayer1(db, roomID, p, idx); err == nil { + PokerPubSub.Pub(roomTopic, PokerSeatLeftEvent{}) + newLogEvent(g, roomLogsTopic, fmt.Sprintf("%s auto un-sit", p.Username)) + } } } }