dkforest

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

commit 58466175df3258a5d3a0163222526880d925f9d2
parent cffc6eaa652390e59069449717e5f38e309935ff
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue,  5 Dec 2023 21:35:36 -0500

cleanup

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

diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -322,21 +322,24 @@ func dealerThread(g *PokerGame, roomID string) { var card string idx := 0 - burnCard := func(pos int) { + burnIdx := 0 + burnCard := func() { card = g.Ongoing.Deck[idx] idx++ evt := PokerEvent{ ID: "card" + itoa(idx), Name: "", Idx: idx, - Top: BurnStackY + (pos * 2), - Left: BurnStackX + (pos * 4), + Top: BurnStackY + (burnIdx * 2), + Left: BurnStackX + (burnIdx * 4), } PokerPubSub.Pub(roomTopic, evt) g.Ongoing.Events = append(g.Ongoing.Events, evt) + burnIdx++ } - dealCard := func(pos int) { + dealCardIdx := 0 + dealCard := func() { card = g.Ongoing.Deck[idx] idx++ evt := PokerEvent{ @@ -344,11 +347,12 @@ func dealerThread(g *PokerGame, roomID string) { Name: card, Idx: idx, Top: 150, - Left: 100 + (pos * 55), + Left: 155 + (dealCardIdx * 55), Reveal: true, } PokerPubSub.Pub(roomTopic, evt) g.Ongoing.Events = append(g.Ongoing.Events, evt) + dealCardIdx++ } deckHash := utils.MD5([]byte(strings.Join(g.Ongoing.Deck, ""))) @@ -400,12 +404,12 @@ func dealerThread(g *PokerGame, roomID string) { // Burn time.Sleep(time.Second) - burnCard(0) + burnCard() // Flop (3 first cards) for i := 1; i <= 3; i++ { time.Sleep(time.Second) - dealCard(i) + dealCard() } // Wait for players to bet/call/check/fold... @@ -416,11 +420,11 @@ func dealerThread(g *PokerGame, roomID string) { // Burn time.Sleep(time.Second) - burnCard(1) + burnCard() // Turn (4th card) time.Sleep(time.Second) - dealCard(4) + dealCard() // Wait for players to bet/call/check/fold... time.Sleep(time.Second) @@ -430,11 +434,11 @@ func dealerThread(g *PokerGame, roomID string) { // Burn time.Sleep(time.Second) - burnCard(2) + burnCard() // River (5th card) time.Sleep(time.Second) - dealCard(5) + dealCard() // Wait for players to bet/call/check/fold... time.Sleep(time.Second)