dkforest

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

commit 7896720e7532752ed679ff50b15886d02a38abd5
parent f278919bdbb899aec82af35ba4147c593490a05c
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon,  4 Dec 2023 23:33:09 -0500

show deck at end of game

Diffstat:
Mpkg/web/handlers/poker.go | 19++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/pkg/web/handlers/poker.go b/pkg/web/handlers/poker.go @@ -73,6 +73,7 @@ type PokerGame struct { Players []string Ongoing *Ongoing DealerIdx int + IsGameDone bool IsGameOver bool } @@ -260,6 +261,10 @@ func (g *PokerGame) Deal(roomID string) { time.Sleep(time.Second) waitPlayersActionFn() + // TODO: evaluate hands, and crown winner + g.IsGameDone = true + PokerPubSub.Pub(myTopic, GameIsDoneEvent{DeckStr: strings.Join(g.Ongoing.Deck, "")}) + // Wait a minimum of X seconds before allowing a new game time.Sleep(MinTimeAfterGame * time.Second) g.IsGameOver = true @@ -299,6 +304,10 @@ type PokerEvent struct { Angle string } +type GameIsDoneEvent struct { + DeckStr string +} + type ResetCardsEvent struct { } @@ -693,7 +702,10 @@ body { if g.Ongoing != nil { drawCountDownStyle(g.Ongoing.WaitTurnEvent) } - send(`<div>` + deckStr + `</div>`) + send(`<div id="deckStr"></div>`) + if g.IsGameDone { + send(`<style>#deckStr:before { content: "` + deckStr + `"; }</style>`) + } send(`<div>` + deckHash + `</div>`) if g.Ongoing != nil { for _, payload := range g.Ongoing.Events { @@ -722,6 +734,11 @@ Loop: c.Response().Flush() continue + } else if evt, ok := payload.(GameIsDoneEvent); ok { + send(`<style>#deckStr:before { content: "` + evt.DeckStr + `"; }</style>`) + c.Response().Flush() + continue + } else if evt, ok := payload.(YourCardEvent); ok { if evt.Idx == 1 { send(`<style>#yourCard1:before { content: "` + evt.Name + `"; }</style>`)