dkforest

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

commit 51b8e13905e37536add31aa75e2e5519843d1b09
parent f061244c73cf12d3bd37449df2090e3b12286ad7
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu, 14 Dec 2023 19:50:55 -0500

annoying sounds, but better than no sound

Diffstat:
Mpkg/web/handlers/poker/events.go | 3+++
Mpkg/web/handlers/poker/poker.go | 19+++++++++++++++----
Apkg/web/public/mp3/sound7.mp3 | 0
3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/pkg/web/handlers/poker/events.go b/pkg/web/handlers/poker/events.go @@ -58,3 +58,6 @@ type PokerSeatTakenEvent struct { type PokerSeatLeftEvent struct { } + +type PokerYourTurnEvent struct { +} diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -517,6 +517,8 @@ OUTER: for { // Repeat until all players have played playerToPlayIdx = (playerToPlayIdx + 1) % len(g.Ongoing.Players) p := g.Ongoing.Players[playerToPlayIdx] + roomUserTopic := "room_" + roomID + "_" + p.Username.String() + if playerToPlayIdx == lastRaisePlayerIdx { break } @@ -530,14 +532,14 @@ OUTER: setWaitTurn(g, roomTopic, p.SeatIdx) + PokerPubSub.Pub(roomUserTopic, PokerYourTurnEvent{}) + // Maximum time allowed for the player to send his action waitCh := time.After(MaxUserCountdown * time.Second) LOOP: for { // Repeat until we get an event from the player we're interested in var evt PlayerEvent - roomUserTopic := "room_" + roomID + "_" + p.Username.String() - select { case evt = <-g.PlayersEventCh: case <-waitCh: @@ -1389,6 +1391,8 @@ func buildPayloadHtml(g *PokerGame, authUser *database.User, payload any) (html html += drawSeatsStyle(authUser, g) case PokerWaitTurnEvent: html += drawCountDownStyle(evt) + case PokerYourTurnEvent: + html += drawYourTurnHtml() case PokerEvent: html += getPokerEventHtml(evt, "1s") case PokerMainPotUpdatedEvent: @@ -1616,9 +1620,11 @@ func drawPlayerBetEvent(evt PlayerBetEvent) (html string) { return } -func drawGameStartedEvent(evt GameStartedEvent) string { +func drawGameStartedEvent(evt GameStartedEvent) (html string) { pos := dealerTokenPos[evt.DealerSeatIdx] - return `<style>#dealerToken { top: ` + itoa(pos[0]) + `px; left: ` + itoa(pos[1]) + `px; }</style>` + html += `<style>#dealerToken { top: ` + itoa(pos[0]) + `px; left: ` + itoa(pos[1]) + `px; }</style>` + html += `<audio src="/public/sounds/chess/GenericNotify.ogg" autoplay></audio>` + return } func drawGameIsDoneHtml(g *PokerGame, evt GameIsDoneEvent) (html string) { @@ -1655,6 +1661,11 @@ func drawResetCardsEvent() (html string) { return } +func drawYourTurnHtml() (html string) { + html += `<audio src="/public/mp3/sound7.mp3" autoplay></audio>` + return +} + func drawCountDownStyle(evt PokerWaitTurnEvent) string { html := "<style>" html += `#countdown1, #countdown2, #countdown3, #countdown4, #countdown5, #countdown6 { display: none; }` diff --git a/pkg/web/public/mp3/sound7.mp3 b/pkg/web/public/mp3/sound7.mp3 Binary files differ.