dkforest

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

commit ed3d5e1081f9af08f1722355ddc71c939e17c7ef
parent c8a1db560006b37b3598993b5404073eceeca285
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed,  6 Dec 2023 03:42:00 -0500

ui

Diffstat:
Mpkg/web/handlers/poker/events.go | 7+++++--
Mpkg/web/handlers/poker/poker.go | 20+++++++++++++++-----
2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/pkg/web/handlers/poker/events.go b/pkg/web/handlers/poker/events.go @@ -43,11 +43,14 @@ type PlayerFoldEvent struct { Card1Idx, Card2Idx int } -type PokerWaitTurnEvent struct { - Idx int +type PokerMainPotUpdatedEvent struct { MainPot int } +type PokerWaitTurnEvent struct { + Idx int +} + type YourCardEvent struct { Idx int Name string diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -303,6 +303,10 @@ OUTER: } } + evt := PokerWaitTurnEvent{Idx: -1} + PokerPubSub.Pub(roomTopic, evt) + g.Ongoing.WaitTurnEvent = evt + time.Sleep(time.Second) // Transfer players bets into the main pot @@ -313,9 +317,7 @@ OUTER: } } - evt := PokerWaitTurnEvent{Idx: -1, MainPot: g.Ongoing.MainPot} - PokerPubSub.Pub(roomTopic, evt) - g.Ongoing.WaitTurnEvent = evt + PokerPubSub.Pub(roomTopic, PokerMainPotUpdatedEvent{MainPot: g.Ongoing.MainPot}) return playerAlive == 1 } @@ -907,8 +909,6 @@ func drawCountDownStyle(evt PokerWaitTurnEvent) string { html := "<style>" html += `#countdown1, #countdown2, #countdown3, #countdown4, #countdown5, #countdown6 { display: none; }` if evt.Idx == -1 { - html += `#seat1Pot:before, #seat2Pot:before, #seat3Pot:before, #seat4Pot:before, #seat5Pot:before, #seat6Pot:before { content: ""; }` - html += `#mainPot:before { content: "Pot: ` + itoa(evt.MainPot) + `"; }` } else if evt.Idx == 0 { html += `#countdown1 { top: 50px; left: 600px; display: block; animation: time calc(var(--duration) * 1s) steps(1000, start) forwards; }` } else if evt.Idx == 1 { @@ -926,6 +926,14 @@ func drawCountDownStyle(evt PokerWaitTurnEvent) string { return html } +func drawMainPotHtml(evt PokerMainPotUpdatedEvent) (html string) { + html += `<style>` + html += `#seat1Pot:before, #seat2Pot:before, #seat3Pot:before, #seat4Pot:before, #seat5Pot:before, #seat6Pot:before { content: ""; }` + html += `#mainPot:before { content: "Pot: ` + itoa(evt.MainPot) + `"; }` + html += `</style>` + return +} + func getPokerEventHtml(payload PokerEvent, animationTime string) string { transform := `transform: translate(` + itoa(payload.Left) + `px, ` + itoa(payload.Top) + `px)` if payload.Angle != "" { @@ -1289,6 +1297,8 @@ Loop: send(drawCountDownStyle(evt)) case PokerEvent: send(getPokerEventHtml(evt, "1s")) + case PokerMainPotUpdatedEvent: + send(drawMainPotHtml(evt)) } c.Response().Flush() continue