Skip to content

Commit

Permalink
fix: known issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
ainilili committed Apr 10, 2024
1 parent 0342592 commit b4d9ebc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions database/texas.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Texas struct {
MaxBetPlayer *TexasPlayer `json:"maxBetPlayer"`
Round string `json:"round"`
Folded int `json:"folded"`
AllIn int `json:"allIn"`
}

func (g *Texas) delete() {
Expand Down
9 changes: 6 additions & 3 deletions state/game/texas/bet.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import (

func bet(player *database.Player, game *database.Texas) error {
texasPlayer := game.Player(player.ID)
if game.AllIn == len(game.Players) ||
(game.MaxBetPlayer != nil && game.MaxBetPlayer.ID == player.ID) {
return nextRound(game)
}
if texasPlayer.Folded || texasPlayer.AllIn {
return nextPlayer(player, game, stateBet)
}
if game.MaxBetPlayer != nil && game.MaxBetPlayer.ID == player.ID {
return nextRound(game)
}

database.Broadcast(player.RoomID, fmt.Sprintf("Next it's %s's turn to bet\n", player.Name), player.ID)

Expand Down Expand Up @@ -114,6 +115,7 @@ func bet(player *database.Player, game *database.Texas) error {
texasPlayer.Amount = 0
texasPlayer.Bets += betAmount
game.Pot += betAmount
game.AllIn++
if game.MaxBetPlayer == nil {
game.MaxBetPlayer = texasPlayer
}
Expand All @@ -124,6 +126,7 @@ func bet(player *database.Player, game *database.Texas) error {
database.Broadcast(player.RoomID, fmt.Sprintf("%s all in, bet %d\n", player.Name, betAmount))
default:
database.BroadcastChat(player, fmt.Sprintf("%s say: %s\n", player.Name, ans))
continue
}
break
}
Expand Down

0 comments on commit b4d9ebc

Please sign in to comment.