dkforest

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

commit bf10f717b1a12467561d176e56805dd0aff3bb45
parent 6054bc82d2d11ae873e3b3dd37c1eb073b1e83a9
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue,  5 Dec 2023 16:57:55 -0500

show cards

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

diff --git a/pkg/web/handlers/poker.go b/pkg/web/handlers/poker.go @@ -407,6 +407,12 @@ func (g *PokerGame) Deal(roomID string) { } // TODO: Show cards + for _, p := range g.Ongoing.Players { + if p != nil && !p.Folded { + fmt.Println(p.Username, p.Cards) + PokerPubSub.Pub(roomTopic, ShowCardsEvent{Cards: p.Cards}) + } + } END: @@ -502,6 +508,10 @@ type YourCardEvent struct { Name string } +type ShowCardsEvent struct { + Cards []PlayerCard +} + type PokerSeatTakenEvent struct { } @@ -1040,6 +1050,18 @@ Loop: c.Response().Flush() continue + } else if evt, ok := payload.(ShowCardsEvent); ok { + // TODO: Proper showing cards + html := `<style>` + html += `#card` + strconv.Itoa(evt.Cards[0].Idx) + ` { transition: 1s ease-in-out; transform: rotateY(0); }` + html += `#card` + strconv.Itoa(evt.Cards[1].Idx) + ` { transition: 1s ease-in-out; transform: rotateY(0); }` + html += `#card` + strconv.Itoa(evt.Cards[0].Idx) + `:before { content: "` + evt.Cards[0].Name + `"; color: ` + colorForCard(evt.Cards[0].Name) + `; }` + html += `#card` + strconv.Itoa(evt.Cards[1].Idx) + `:before { content: "` + evt.Cards[1].Name + `"; color: ` + colorForCard(evt.Cards[1].Name) + `; }` + html += `</style>` + send(html) + c.Response().Flush() + continue + } else if _, ok := payload.(ResetCardsEvent); ok { html := `<style>` for i := 1; i <= 52; i++ {