commit c5eafec7af83d692693d97762433e2279c41a446
parent 316465843e7b4720d39668708a14f6e514fda04b
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 11 Dec 2023 17:28:20 -0500
cleanup
Diffstat:
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -411,6 +411,15 @@ func showCards(g *PokerGame, roomTopic string, seats []Seat) {
}
}
+func setWaitTurn(g *PokerGame, roomTopic string, seatIdx int) {
+ evt := PokerWaitTurnEvent{Idx: seatIdx}
+ PokerPubSub.Pub(roomTopic, evt)
+
+ g.Ongoing.WaitTurnEventMtx.Lock()
+ g.Ongoing.WaitTurnEvent = evt
+ g.Ongoing.WaitTurnEventMtx.Unlock()
+}
+
// Return either or not the game ended because only 1 player left playing (or none)
func waitPlayersActionFn(g *PokerGame, roomID string, skip, minBet int) bool {
roomTopic := "room_" + roomID
@@ -460,12 +469,8 @@ OUTER:
if player.Folded.Load() || player.isAllIn() {
continue
}
- evt := PokerWaitTurnEvent{Idx: p.SeatIdx}
- PokerPubSub.Pub(roomTopic, evt)
- g.Ongoing.WaitTurnEventMtx.Lock()
- g.Ongoing.WaitTurnEvent = evt
- g.Ongoing.WaitTurnEventMtx.Unlock()
+ setWaitTurn(g, roomTopic, p.SeatIdx)
// Maximum time allowed for the player to send his action
waitCh := time.After(MaxUserCountdown * time.Second)
@@ -606,12 +611,7 @@ END1:
newLogEvent(g, roomLogsTopic, fmt.Sprintf("--"))
- evt := PokerWaitTurnEvent{Idx: -1}
- PokerPubSub.Pub(roomTopic, evt)
-
- g.Ongoing.WaitTurnEventMtx.Lock()
- g.Ongoing.WaitTurnEvent = evt
- g.Ongoing.WaitTurnEventMtx.Unlock()
+ setWaitTurn(g, roomTopic, -1)
time.Sleep(time.Second)