commit 7e009c05ba59879b0e7781e1badb28eeaafe6c15
parent ad7307d70252097027700c1df7de4a9767a7362c
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 12 Dec 2023 14:42:26 -0500
fix unsit/sit
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -109,7 +109,7 @@ func (p *PokerStandingPlayer) isEligible() bool {
func (p *PokerStandingPlayer) getDisplayCash(g *PokerGame) int {
if g.Ongoing != nil {
- if op := g.Ongoing.GetPlayer(p.Username); op != nil {
+ if op := g.Ongoing.GetPlayer(p.Username); op != nil && !op.Unsit.Load() {
return op.Cash
}
}
@@ -125,6 +125,7 @@ type PokerPlayer struct {
Cards []PlayerCard
CardsMtx sync.RWMutex
Folded atomic.Bool
+ Unsit atomic.Bool
}
func (p *PokerPlayer) isAllIn() bool {
@@ -340,6 +341,12 @@ func (g *PokerGame) incrDealerIdx() {
}
func (g *PokerGame) UnSitPlayer(db *database.DkfDB, roomID string, authUser *database.User, pokerTable database.PokerTable) error {
+ if g.Ongoing != nil {
+ if p := g.Ongoing.GetPlayer(authUser.Username.String()); p != nil {
+ p.Unsit.Store(true)
+ }
+ }
+
g.PlayersMtx.RLock()
defer g.PlayersMtx.RUnlock()
for idx, p := range g.Players {