commit 611216b4aa7a298918e158835746969b8933d30d
parent 733dd63cb09866f4354aa1d3d9a3f178a57dd1a0
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 5 Dec 2023 17:28:21 -0500
error msg
Diffstat:
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/pkg/web/handlers/poker.go b/pkg/web/handlers/poker.go
@@ -203,7 +203,10 @@ func (g *PokerGame) Deal(roomID string) {
}
} else if evt.Check {
if g.Ongoing.Players[i].Bet < minBet {
- fmt.Println("NEED TO BET", minBet-g.Ongoing.Players[i].Bet)
+ msg := fmt.Sprintf("Need to bet %d", minBet-g.Ongoing.Players[i].Bet)
+ roomUserTopic := "room_" + roomID + "_" + g.Ongoing.Players[i].Username
+ PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: msg})
+ fmt.Println(msg)
continue
}
} else if evt.Call {
@@ -498,6 +501,10 @@ type PlayerBetEvent struct {
Cash int
}
+type ErrorMsgEvent struct {
+ Message string
+}
+
type PlayerFoldEvent struct {
Card1Idx, Card2Idx int
}
@@ -851,6 +858,7 @@ body {
#mainPot { position: absolute; top: 240px; left: 250px; }
#yourCard1 { font-size: 22px; display: inline-block; margin-right: 15px; }
#yourCard2 { font-size: 22px; display: inline-block; }
+#errorMsg { position: absolute; top: 500px; left: 150px; display: block; color: darkred; }
.timer {
@@ -975,6 +983,7 @@ body {
actions += `<iframe src="/poker/` + roomID + `/unsit" id="unSitBtn"></iframe>`
send(actions)
deckHash := deckMd5
+ send(`<div id="errorMsg"></div>`)
send(`<div id="seat1Pot">BET: 0</div>`)
send(buildMainPotHtml(g))
send(`<div id="countdown1" class="timer" style="--duration: ` + strconv.Itoa(MaxUserCountdown) + `;--size: 30;"><div class="mask"></div></div>`)
@@ -1046,6 +1055,12 @@ Loop:
c.Response().Flush()
continue
+ } else if evt, ok := payload.(ErrorMsgEvent); ok {
+ html := `<style>#errorMsg:before { content: "` + evt.Message + `"; display: block; }</style>`
+ send(html)
+ c.Response().Flush()
+ continue
+
} else if evt, ok := payload.(PlayerFoldEvent); ok {
transition := `transition: 1s ease-in-out; transform: translateX(` + strconv.Itoa(BurnStackX) + `px) translateY(` + strconv.Itoa(BurnStackY) + `px) rotateY(` + BackfacingDeg + `);`
html := `<style>#card` + strconv.Itoa(evt.Card1Idx) + ` { ` + transition + ` }