dkforest

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

commit fc887d971e5f957f7c4b937802b777e8e73bdca1
parent 1f4a2a15357ddc6fab1db061ee30834868842b68
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri, 15 Dec 2023 05:33:29 -0500

cleanup

Diffstat:
Mpkg/web/handlers/poker/poker.go | 35+++++++++++++----------------------
1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -487,6 +487,17 @@ func waitPlayersActionFn(db *database.DkfDB, g *PokerGame, roomID RoomID, skip i lastRaisePlayerIdx := -1 newlyAllInPlayers := make([]*PokerPlayer, 0) + foldPlayer := func(p *PokerPlayer) { + p.Folded.Store(true) + p.CardsMtx.RLock() + evt1 := PokerEvent{ID: "card" + itoa(p.Cards[0].Idx), Name: "", Idx: p.Cards[0].Idx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false} + evt2 := PokerEvent{ID: "card" + itoa(p.Cards[1].Idx), Name: "", Idx: p.Cards[1].Idx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false} + p.CardsMtx.RUnlock() + PokerPubSub.Pub(roomTopic, evt1) + PokerPubSub.Pub(roomTopic, evt2) + g.Ongoing.AddEvent(evt1, evt2) + } + playerAlive := g.Ongoing.CountAlivePlayers() // Avoid asking for actions if only 1 player can do so (because others are all-in) @@ -535,17 +546,7 @@ OUTER: break LOOP } if p.Bet < minBet { - p.Folded.Store(true) - - p.CardsMtx.RLock() - evt1 := PokerEvent{ID: "card" + itoa(p.Cards[0].Idx), Name: "", Idx: p.Cards[0].Idx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false} - evt2 := PokerEvent{ID: "card" + itoa(p.Cards[1].Idx), Name: "", Idx: p.Cards[1].Idx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false} - p.CardsMtx.RUnlock() - PokerPubSub.Pub(roomTopic, evt1) - PokerPubSub.Pub(roomTopic, evt2) - g.Ongoing.AddEvent(evt1, evt2) - - //PokerPubSub.Pub(roomTopic, PlayerFoldEvent{Card1Idx: player.Cards[0].Idx, Card2Idx: player.Cards[1].Idx}) + foldPlayer(p) newLogEvent(g, roomLogsTopic, fmt.Sprintf("%s auto fold", pUsername)) playerAlive-- @@ -573,17 +574,7 @@ OUTER: p.LastActionTS = time.Now() if evt.Fold { - p.Folded.Store(true) - - p.CardsMtx.RLock() - evt1 := PokerEvent{ID: "card" + itoa(p.Cards[0].Idx), Name: "", Idx: p.Cards[0].Idx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false} - evt2 := PokerEvent{ID: "card" + itoa(p.Cards[1].Idx), Name: "", Idx: p.Cards[1].Idx, Top: BurnStackY, Left: BurnStackX, Angle: "0deg", Reveal: false} - p.CardsMtx.RUnlock() - PokerPubSub.Pub(roomTopic, evt1) - PokerPubSub.Pub(roomTopic, evt2) - g.Ongoing.AddEvent(evt1, evt2) - - //PokerPubSub.Pub(roomTopic, PlayerFoldEvent{Card1Idx: player.Cards[0].Idx, Card2Idx: player.Cards[1].Idx}) + foldPlayer(p) newLogEvent(g, roomLogsTopic, fmt.Sprintf("%s fold", pUsername)) playerAlive--