commit 83085f48a8e513f54c242d0f73c9e7ab7b79a0e3
parent d8d3d00f278b1c1f8d4f02921f2561d9e812107c
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 8 Dec 2023 15:45:57 -0500
button all-in
Diffstat:
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -73,6 +73,7 @@ type PlayerEvent struct {
Call bool
Check bool
Fold bool
+ AllIn bool
Bet int
}
@@ -512,6 +513,16 @@ OUTER:
}
newLogEvent(g, roomLogsTopic, logMsg)
+ } else if evt.AllIn {
+ bet := p.Cash
+ p.doBet(bet)
+ PokerPubSub.Pub(roomTopic, PlayerBetEvent{PlayerIdx: p.SeatIdx, Player: p.Username, Bet: bet, TotalBet: p.Bet, Cash: p.Cash})
+ logMsg := fmt.Sprintf("%s all-in (%d)", p.Username, bet)
+ if p.Cash == 0 {
+ newlyAllInPlayers = append(newlyAllInPlayers, p)
+ }
+ newLogEvent(g, roomLogsTopic, logMsg)
+
} else if evt.Bet > 0 {
bet := evt.Bet
if (p.Bet + bet) < minBet {
@@ -968,16 +979,23 @@ func PokerBetHandler(c echo.Context) error {
if c.Request().Method == http.MethodPost {
bet, _ = strconv.Atoi(c.Request().PostFormValue("betValue"))
betBtn := c.Request().PostFormValue("bet")
- if betBtn == "bet50" {
- bet = 50
- } else if betBtn == "bet100" {
- bet = 100
- } else if betBtn == "bet200" {
- bet = 200
- }
- select {
- case g.PlayersEventCh <- PlayerEvent{Player: authUser.Username.String(), Bet: bet}:
- default:
+ if betBtn == "betAllIn" {
+ select {
+ case g.PlayersEventCh <- PlayerEvent{Player: authUser.Username.String(), AllIn: true}:
+ default:
+ }
+ } else {
+ if betBtn == "bet50" {
+ bet = 50
+ } else if betBtn == "bet100" {
+ bet = 100
+ } else if betBtn == "bet200" {
+ bet = 200
+ }
+ select {
+ case g.PlayersEventCh <- PlayerEvent{Player: authUser.Username.String(), Bet: bet}:
+ default:
+ }
}
}
html := cssReset + `
@@ -986,6 +1004,7 @@ func PokerBetHandler(c echo.Context) error {
<button type="submit" name="bet" value="bet50">50</button>
<button type="submit" name="bet" value="bet100">100</button>
<button type="submit" name="bet" value="bet200">200</button>
+ <button type="submit" name="bet" value="betAllIn">All-in</button>
</form>`
return c.HTML(http.StatusOK, html)
}
@@ -1464,7 +1483,7 @@ body {
#checkBtn { width: 60px; height: 30px; }
#foldBtn { width: 50px; height: 30px; }
#callBtn { width: 50px; height: 30px; }
-#betBtn { width: 145px; height: 60px; }
+#betBtn { width: 145px; height: 70px; }
#countdown1 { position: absolute; display: none; z-index: 100; }
#countdown2 { position: absolute; display: none; z-index: 100; }
#countdown3 { position: absolute; display: none; z-index: 100; }