commit d1e30350ff5f6752a8bf623bb8a82eb84162761a
parent 65e40db5828793a529fb29ed9dddeee9f2066871
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 5 Dec 2023 15:56:39 -0500
bet call rise and stuff
Diffstat:
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/pkg/web/handlers/poker.go b/pkg/web/handlers/poker.go
@@ -142,12 +142,17 @@ func (g *PokerGame) Deal(roomID string) {
go func() {
waitPlayersActionFn := func() {
+ lastRisePlayerIdx := -1
+ minBet := 0
+ OUTER:
for {
- minBet := 0
for i, p := range g.Ongoing.Players {
if p == nil {
continue
}
+ if i == lastRisePlayerIdx {
+ break OUTER
+ }
player := g.Ongoing.GetPlayer(p.Username)
if player.Folded {
continue
@@ -164,6 +169,9 @@ func (g *PokerGame) Deal(roomID string) {
case evt = <-g.PlayersEventCh:
case <-waitCh:
fmt.Println("WAIT TOO LONG, either auto check, or fold")
+ if p.Cash == 0 { // all-in
+ break LOOP
+ }
if p.Bet < minBet {
player.Folded = true
PokerPubSub.Pub(roomTopic, PlayerFoldEvent{Card1Idx: player.Cards[0].Idx, Card2Idx: player.Cards[1].Idx})
@@ -179,8 +187,8 @@ func (g *PokerGame) Deal(roomID string) {
PokerPubSub.Pub(roomTopic, PlayerFoldEvent{Card1Idx: player.Cards[0].Idx, Card2Idx: player.Cards[1].Idx})
} else if evt.Check {
} else if evt.Call {
- bet := minBet
- if g.Ongoing.Players[i].Cash < g.Ongoing.Players[i].Bet {
+ bet := minBet - g.Ongoing.Players[i].Bet
+ if g.Ongoing.Players[i].Cash < bet {
bet = g.Ongoing.Players[i].Cash
g.Ongoing.Players[i].Bet += bet
g.Ongoing.Players[i].Cash = 0
@@ -195,6 +203,9 @@ func (g *PokerGame) Deal(roomID string) {
fmt.Println("BET TOO LOW", evt.Bet, minBet)
continue
}
+ if evt.Bet > minBet {
+ lastRisePlayerIdx = i
+ }
minBet = evt.Bet
g.Ongoing.Players[i].Bet += evt.Bet
g.Ongoing.Players[i].Cash -= evt.Bet
@@ -212,6 +223,9 @@ func (g *PokerGame) Deal(roomID string) {
if p.Folded {
continue
}
+ if p.Cash == 0 { // all in
+ continue
+ }
if b == -1 {
b = p.Bet
} else {