commit 2d2d9788a6791f2b32314a042941cfa2f1b1acd4
parent 81a8173045b5c4d563d4f815bca7b523874afeb8
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 4 Dec 2023 22:24:57 -0500
display your cards
Diffstat:
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/pkg/web/handlers/poker.go b/pkg/web/handlers/poker.go
@@ -197,6 +197,7 @@ func (g *PokerGame) Deal(roomID string) {
Burn: true,
}
PokerPubSub.Pub(myTopic, evt)
+ PokerPubSub.Pub(myTopic+"_"+p.Username, YourCardEvent{Idx: j, Name: card})
g.Ongoing.Events = append(g.Ongoing.Events, evt)
}
}
@@ -284,6 +285,11 @@ type PokerWaitTurnEvent struct {
Idx int
}
+type YourCardEvent struct {
+ Idx int
+ Name string
+}
+
type PokerSeatTakenEvent struct {
}
@@ -478,7 +484,7 @@ func PokerHandler(c echo.Context) error {
quit := hutils.CloseSignalChan(c)
roomTopic := "room_" + roomID
- roomUserTopic := "room_" + roomID + "_" + authUser.ID.String()
+ roomUserTopic := "room_" + roomID + "_" + authUser.Username.String()
sub := PokerPubSub.Subscribe([]string{roomTopic, roomUserTopic})
defer sub.Close()
@@ -621,9 +627,9 @@ body {
<iframe src="/poker/` + roomID + `/call" id="callBtn"></iframe>
<iframe src="/poker/` + roomID + `/check" id="checkBtn"></iframe>
<iframe src="/poker/` + roomID + `/fold" id="foldBtn"></iframe>
-
</div>`
send(turnAction)
+ send(`<div style="position: absolute; top: 500px; left: 200px;"><div id="yourCard1"></div><div id="yourCard2"></div></div>`)
actions := `<iframe src="/poker/` + roomID + `/deal" id="dealBtn"></iframe>`
actions += `<iframe src="/poker/` + roomID + `/unsit" id="unSitBtn"></iframe>`
send(actions)
@@ -658,6 +664,16 @@ Loop:
c.Response().Flush()
continue
+ } else if evt, ok := payload.(YourCardEvent); ok {
+ fmt.Println("YOUR CARD:", authUser.Username, evt.Idx, evt.Name)
+ if evt.Idx == 1 {
+ send(`<style>#yourCard1:before { content: "` + evt.Name + `"; }</style>`)
+ } else {
+ send(`<style>#yourCard2:before { content: "` + evt.Name + `"; }</style>`)
+ }
+ c.Response().Flush()
+ continue
+
} else if _, ok := payload.(PokerSeatTakenEvent); ok {
drawSeats()
c.Response().Flush()