dkforest

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

commit 2a22d5afc7b5606a1db91fca6490bdfb918e0a0c
parent f67c0dfbe31b4ea6a62a42a6c277b8bd72cbe978
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon,  4 Dec 2023 02:32:03 -0500

fix dealing

Diffstat:
Mpkg/web/handlers/handlers.go | 31++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -795,6 +795,25 @@ func PokerHandler(c echo.Context) error { go func() { var card string idx := 0 + + // Burn + select { + case <-time.After(2 * time.Second): + case <-quit: + return + } + idx++ + card, deck = deck[0], deck[1:] + PokerPubSub.Pub(myTopic, PokerEvent{ + ID: "card" + strconv.Itoa(idx), + Name: "", + Idx: idx, + Top: 30, + Left: 400, + Burn: true, + }) + + // Flop (3 first cards) for i := 1; i <= 3; i++ { select { case <-time.After(2 * time.Second): @@ -804,7 +823,7 @@ func PokerHandler(c echo.Context) error { idx++ card, deck = deck[0], deck[1:] PokerPubSub.Pub(myTopic, PokerEvent{ - ID: "card" + strconv.Itoa(i), Name: card, + ID: "card" + strconv.Itoa(idx), Name: card, Idx: idx, Top: 150, Left: 100 + (i * 55), @@ -820,7 +839,7 @@ func PokerHandler(c echo.Context) error { idx++ card, deck = deck[0], deck[1:] PokerPubSub.Pub(myTopic, PokerEvent{ - ID: "card" + strconv.Itoa(4), + ID: "card" + strconv.Itoa(idx), Name: "", Idx: idx, Top: 30, @@ -828,6 +847,7 @@ func PokerHandler(c echo.Context) error { Burn: true, }) + // Turn (4th card) select { case <-time.After(2 * time.Second): case <-quit: @@ -836,7 +856,7 @@ func PokerHandler(c echo.Context) error { idx++ card, deck = deck[0], deck[1:] PokerPubSub.Pub(myTopic, PokerEvent{ - ID: "card" + strconv.Itoa(5), Name: card, + ID: "card" + strconv.Itoa(idx), Name: card, Idx: idx, Top: 150, Left: 100 + (4 * 55), @@ -851,7 +871,7 @@ func PokerHandler(c echo.Context) error { idx++ card, deck = deck[0], deck[1:] PokerPubSub.Pub(myTopic, PokerEvent{ - ID: "card" + strconv.Itoa(6), + ID: "card" + strconv.Itoa(idx), Name: "", Idx: idx, Top: 30, @@ -859,6 +879,7 @@ func PokerHandler(c echo.Context) error { Burn: true, }) + // River (5th card) select { case <-time.After(2 * time.Second): case <-quit: @@ -867,7 +888,7 @@ func PokerHandler(c echo.Context) error { idx++ card, deck = deck[0], deck[1:] PokerPubSub.Pub(myTopic, PokerEvent{ - ID: "card" + strconv.Itoa(7), Name: card, + ID: "card" + strconv.Itoa(idx), Name: card, Idx: idx, Top: 150, Left: 100 + (5 * 55),