model

package
v0.0.0-...-07b2db6 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TableS TODO is this needed for anything?
	TableS = SignalType(iota)
	// BetS TODO is this needed for anything?
	BetS = SignalType(iota)
	// MessageS TODO is this needed for anything?
	MessageS = SignalType(iota)

	// SitS TODO is this needed for anything?
	SitS = TableSignal(iota)
	// StandS TODO is this needed for anything?
	StandS = TableSignal(iota)
)
View Source
const (
	// DefaultMinBet default minimum bet controlling big blinds
	DefaultMinBet = 200
	// MinPlayersToPlay below which the hand cannot start
	MinPlayersToPlay = 2
	// MaxTableSize once reached no more players can sit
	MaxTableSize = 10
	// MaxStandersSize once reached no more players can stand TODO what happens when standers is full and someone stands up?
	MaxStandersSize = 10
	// AllIn takes the player all in
	AllIn = ActionType(iota)
	// Raise the current bet
	Raise = ActionType(iota)
	// Call the current bet
	Call = ActionType(iota)
	// Fold your hand
	Fold = ActionType(iota)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionType

type ActionType int

ActionType an action a player can take during their turn in a round

type Hand

type Hand struct {
	// TableConfig defines nuances of play
	TableConfig TableConfig
	// Deck of cards
	Deck poker.Deck
	// Board shared cards
	Board []poker.Card
	// Round is the current round of betting
	Round *Round
	// Players in the hand
	Players *ring.Ring
	// Pot of winnings
	Pot Pot
	// FirstToBet bets first
	FirstToBet *ring.Ring
	// If dealing is still needed but no more betting
	BettingDone bool
	// If no more dealing is needed for the hand
	HandDone bool
}

Hand can be played and winners will be identified

func (*Hand) BetterCount

func (hand *Hand) BetterCount() int

BetterCount determines the number of betters

func (*Hand) BigBlind

func (hand *Hand) BigBlind() *Player

BigBlind is the big blind of the hand

func (*Hand) Deal

func (hand *Hand) Deal() error

Deal adds shared cards on the board

func (*Hand) Dealer

func (hand *Hand) Dealer() *Player

Dealer is the dealer of the hand

func (*Hand) FinishHand

func (hand *Hand) FinishHand() error

FinishHand is called when all betting is complete and the pot should be distributed.

func (*Hand) ListenForPlayerActions

func (hand *Hand) ListenForPlayerActions()

ListenForPlayerActions get each player's action for the round of bets

func (*Hand) PlayerAction

func (hand *Hand) PlayerAction(
	player *Player, action RoundAction) error

PlayerAction handles a player action

func (*Hand) SmallBlind

func (hand *Hand) SmallBlind() *Player

SmallBlind is the small blind of the hand

func (*Hand) StartHand

func (hand *Hand) StartHand() error

StartHand start a hand

func (*Hand) String

func (hand *Hand) String() string

String the hand's string

type Player

type Player struct {
	Name          string
	Standing      bool
	WantToStandUp bool
	Playing       bool
	AllIn         bool
	Hole          []poker.Card
	Funds         int
	BetAmount     int
	HandRank      int32
	ActionChan    chan RoundAction
	SignalChan    chan Signal
	// contains filtered or unexported fields
}

Player a player's state at a Table

func NewPlayer

func NewPlayer(name string) *Player

NewPlayer create a new player

func NewPlayerWithFunds

func NewPlayerWithFunds(name string, funds int) *Player

NewPlayerWithFunds create a new player with funds

func (*Player) GetTable

func (player *Player) GetTable() *Table

GetTable get the player's table

func (*Player) StandUp

func (player *Player) StandUp()

StandUp - TODO this should likely be moved to async actions

func (Player) String

func (player Player) String() string

String player's string

type PlayerBet

type PlayerBet struct {
	Player *Player
	Bet    int
}

PlayerBet a bet that is made in a round

type Pot

type Pot struct {
	MainPot  SubPot
	SidePots []SubPot
}

Pot is the money in the Hand that is yet to be distributed

type Round

type Round struct {
	// BetTurn is betting next
	BetTurn *ring.Ring
	// CurrentBet is the amount to call
	CurrentBet int
	// If the round of betting is done
	RoundDone bool
}

Round is a cycle of betting, there are 4 in a hand: pre-flop, flop, turn, river

type RoundAction

type RoundAction struct {
	// contains filtered or unexported fields
}

RoundAction how a player (another goroutine) can interact with the table during their turn in a round

type Signal

type Signal struct {
	PlayerName string
	SignalType SignalType
	Action     RoundAction
	Amount     int
	Message    string
}

Signal TODO is this needed for anything?

type SignalType

type SignalType int

SignalType TODO is this needed for anything?

type SubPot

type SubPot struct {
	Players map[*Player]struct{}
	Pot     int
}

SubPot is one of potentially multiple pots and identifies the players in the running to win it

type Table

type Table struct {
	TableConfig TableConfig
	Players     [MaxTableSize]*Player
	DealerIndex int

	Standers [MaxStandersSize]*Player
	Hand     *Hand
	// contains filtered or unexported fields
}

Table the group of players playing hands or standing and watching

func NewTable

func NewTable() *Table

NewTable create a new table

func NewTableWithConfig

func NewTableWithConfig(tableConfig TableConfig) *Table

NewTableWithConfig create a new table with custom config

func (*Table) NewHand

func (table *Table) NewHand() *Hand

NewHand create a hand

func (*Table) Play

func (table *Table) Play() error

Play rounds at the table

func (*Table) SitDown

func (table *Table) SitDown(player *Player, seat int) error

SitDown sit down the player at the table and seat TODO this should probably be an async action

func (*Table) String

func (table *Table) String() string

String table's string

type TableConfig

type TableConfig struct {
	// contains filtered or unexported fields
}

TableConfig define nuances of the game played at a Table

type TableSignal

type TableSignal int

TableSignal TODO is this needed for anything?

Jump to

Keyboard shortcuts

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