bank

package
v0.0.0-...-d26b62e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bank

type Bank struct {
	PlayerWallet map[string]*money.Money
	PlayerBets   map[string]*money.Money
	Pot          *money.Money
	MaxBet       *money.Money

	LobbyId string
	// contains filtered or unexported fields
}

Bank handles the bets and wallets of players.

func NewBank

func NewBank(eventBus *rabbit.RabbitMessageBroker) *Bank

NewBank creates a new bank to handle the bets and wallets of players.

func (*Bank) AddPlayer

func (b *Bank) AddPlayer(player *models.Player)

AddPlayer adds a given player to the bank

func (*Bank) ConcludeRound

func (b *Bank) ConcludeRound(winners []showdown.WinnerInfo, publicPlayers []models.PublicPlayer) []*money.Money

ConcludeRound resets the current round and adds the fair share of the to the winners wallets.

func (*Bank) GetMaxBet

func (b *Bank) GetMaxBet() *money.Money

GetMaxBet returns the highest bet in the current round

func (*Bank) GetPlayerBet

func (b *Bank) GetPlayerBet(id string) *money.Money

GetPlayerBet gets the bet of a given player

func (*Bank) GetPlayerWallet

func (b *Bank) GetPlayerWallet(id string) *money.Money

GetPlayerWallet gets the current wallet for the given player

func (*Bank) GetPot

func (b *Bank) GetPot() *money.Money

GetPot returns the current pot value.

func (*Bank) HasZeroWallet

func (b *Bank) HasZeroWallet(id string) bool

HasZeroWallet returns true if the player has zero money left in his wallet or no bank wallet could be found with this id.

func (*Bank) IsAllIn

func (b *Bank) IsAllIn(id string) bool

IsAllIn determines whether a given player has already placed all his wallet. He can be excluded from the blocking list

func (*Bank) MustAllIn

func (b *Bank) MustAllIn(id string) (bool, error)

MustAllIn determines whether a player has to bet everything in because the maximum bet is already past his wallet amount

func (*Bank) PerformAllIn

func (b *Bank) PerformAllIn(id string) (bool, error)

PerformAllIn

func (*Bank) PerformBet

func (b *Bank) PerformBet(id string) error

PerformBet performs a check action. This equals the players bet to the current maximum bet.

func (*Bank) PerformBlind

func (b *Bank) PerformBlind(id string, blind *money.Money) error

PerformBlind is a wrapper around the core bet() function

func (*Bank) PerformRaise

func (b *Bank) PerformRaise(id string, amount *money.Money) (int, error)

PerformRaise checks if it

func (*Bank) RegisterLobby

func (b *Bank) RegisterLobby(lobbyId string)

func (*Bank) RemovePlayer

func (b *Bank) RemovePlayer(id string) error

RemovePlayer removes the given player from the bank

func (*Bank) UpdatePublicPlayerBuyIn

func (b *Bank) UpdatePublicPlayerBuyIn(p []models.PublicPlayer)

UpdatePublicPlayerBuyIn updates the buyIns of the public player arrays according to the current state.

type Interface

type Interface interface {
	RegisterLobby(string)
	GetMaxBet() *money.Money
	GetPlayerBet(id string) *money.Money
	GetPlayerWallet(id string) *money.Money
	GetPot() *money.Money
	HasZeroWallet(id string) bool
	PerformBet(id string) error
	PerformRaise(id string, amount *money.Money) (int, error)
	PerformAllIn(id string) (bool, error)
	PerformBlind(id string, amount *money.Money) error
	MustAllIn(id string) (bool, error)
	IsAllIn(id string) bool
	AddPlayer(player *models.Player)
	RemovePlayer(id string) error
	UpdatePublicPlayerBuyIn(p []models.PublicPlayer)
	ConcludeRound(winners []showdown.WinnerInfo, publicPlayers []models.PublicPlayer) []*money.Money
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL