Documentation
¶
Index ¶
- Variables
- func NewGame(opts *GameOptions) *game
- func NewGameFromState(gs *GameState) *game
- func NewShortDeckCards() []string
- func NewStandardDeckCards() []string
- func ShuffleCards(cards []string) []string
- type Action
- type BlindSetting
- type CardSuit
- type CombinationInfo
- type Game
- type GameEvent
- type GameOptions
- type GameState
- type Meta
- type Player
- type PlayerSetting
- type PlayerState
- type PokerFace
- type RankInfo
- type Status
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoDeck = errors.New("game: no deck") ErrNotEnoughBackroll = errors.New("game: backroll is not enough") ErrNoDealer = errors.New("game: no dealer") ErrInsufficientNumberOfPlayers = errors.New("game: insufficient number of players") ErrUnknownRound = errors.New("game: unknown round") ErrNotFoundDealer = errors.New("game: not found dealer") ErrUnknownTask = errors.New("game: unknown task") ErrNotClosedRound = errors.New("game: round is not closed") )
View Source
var ( ErrInvalidAction = errors.New("player: invalid action") ErrIllegalRaise = errors.New("player: illegal raise") )
View Source
var CardPoints = []string{
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"T",
"J",
"Q",
"K",
"A",
}
View Source
var CardSuits = []string{
"S",
"H",
"D",
"C",
}
View Source
var GameEventBySymbol = map[string]GameEvent{ "Started": GameEvent_Started, "Initialized": GameEvent_Initialized, "Prepared": GameEvent_Prepared, "AnteRequested": GameEvent_AnteRequested, "AntePaid": GameEvent_AntePaid, "BlindsRequested": GameEvent_BlindsRequested, "BlindsPaid": GameEvent_BlindsPaid, "ReadyRequested": GameEvent_ReadyRequested, "Readiness": GameEvent_Readiness, "PreflopRoundEntered": GameEvent_PreflopRoundEntered, "FlopRoundEntered": GameEvent_FlopRoundEntered, "TurnRoundEntered": GameEvent_TurnRoundEntered, "RiverRoundEntered": GameEvent_RiverRoundEntered, "RoundInitialized": GameEvent_RoundInitialized, "RoundPrepared": GameEvent_RoundPrepared, "RoundStarted": GameEvent_RoundStarted, "RoundClosed": GameEvent_RoundClosed, "GameCompleted": GameEvent_GameCompleted, "SettlementRequested": GameEvent_SettlementRequested, "SettlementCompleted": GameEvent_SettlementCompleted, "GameClosed": GameEvent_GameClosed, }
View Source
var GameEventSymbols = map[GameEvent]string{ GameEvent_Started: "Started", GameEvent_Initialized: "Initialized", GameEvent_Prepared: "Prepared", GameEvent_AnteRequested: "AnteRequested", GameEvent_AntePaid: "AntePaid", GameEvent_BlindsRequested: "BlindsRequested", GameEvent_BlindsPaid: "BlindsPaid", GameEvent_ReadyRequested: "ReadyRequested", GameEvent_Readiness: "Readiness", GameEvent_PreflopRoundEntered: "PreflopRoundEntered", GameEvent_FlopRoundEntered: "FlopRoundEntered", GameEvent_TurnRoundEntered: "TurnRoundEntered", GameEvent_RiverRoundEntered: "RiverRoundEntered", GameEvent_RoundInitialized: "RoundInitialized", GameEvent_RoundPrepared: "RoundPrepared", GameEvent_RoundStarted: "RoundStarted", GameEvent_RoundClosed: "RoundClosed", GameEvent_GameCompleted: "GameCompleted", GameEvent_SettlementRequested: "SettlementRequested", GameEvent_SettlementCompleted: "SettlementCompleted", GameEvent_GameClosed: "GameClosed", }
Functions ¶
func NewGame ¶
func NewGame(opts *GameOptions) *game
func NewGameFromState ¶
func NewGameFromState(gs *GameState) *game
func NewShortDeckCards ¶
func NewShortDeckCards() []string
func NewStandardDeckCards ¶
func NewStandardDeckCards() []string
func ShuffleCards ¶
Types ¶
type BlindSetting ¶
type CombinationInfo ¶
type Game ¶
type Game interface {
ApplyOptions(opts *GameOptions) error
Start() error
Resume() error
GetEvent() string
GetState() *GameState
GetStateJSON() ([]byte, error)
LoadState(gs *GameState) error
Player(idx int) Player
Dealer() Player
SmallBlind() Player
BigBlind() Player
Deal(count int) []string
Burn(count int) error
BecomeRaiser(Player) error
ResetActedPlayers() error
ResetAllPlayerStatus() error
StartAtDealer() (Player, error)
GetPlayerCount() int
GetPlayers() []Player
SetCurrentPlayer(Player) error
GetCurrentPlayer() Player
GetAllowedActions(Player) []string
GetAvailableActions(Player) []string
GetAlivePlayerCount() int
GetMovablePlayerCount() int
UpdateLastAction(source int, ptype string, value int64) error
EmitEvent(event GameEvent) error
PrintState() error
PrintPots()
// Operations
Next() error
ReadyForAll() error
PayAnte() error
PayBlinds() error
// Actions
Pass() error
Pay(chips int64) error
Fold() error
Check() error
Call() error
Allin() error
Bet(chips int64) error
Raise(chipLevel int64) error
}
type GameEvent ¶
type GameEvent int32
const ( // Initialization GameEvent_Started GameEvent = iota GameEvent_Initialized GameEvent_Prepared GameEvent_AnteRequested GameEvent_AntePaid GameEvent_BlindsRequested GameEvent_BlindsPaid GameEvent_ReadyRequested GameEvent_Readiness // Rounds GameEvent_PreflopRoundEntered GameEvent_FlopRoundEntered GameEvent_TurnRoundEntered GameEvent_RiverRoundEntered GameEvent_RoundInitialized GameEvent_RoundPrepared GameEvent_RoundStarted GameEvent_RoundClosed // Result GameEvent_GameCompleted GameEvent_SettlementRequested GameEvent_SettlementCompleted GameEvent_GameClosed )
type GameOptions ¶
type GameOptions struct {
Ante int64 `json:"ante"`
Blind BlindSetting `json:"blind"`
Limit string `json:"limit"`
HoleCardsCount int `json:"hole_cards_count"`
RequiredHoleCardsCount int `json:"required_hole_cards_count"`
CombinationPowers []combination.Combination `json:"combination_powers"`
Deck []string `json:"deck"`
BurnCount int `json:"burn_count"`
Players []*PlayerSetting `json:"players"`
}
func NewShortDeckGameOptions ¶
func NewShortDeckGameOptions() *GameOptions
func NewStardardGameOptions ¶
func NewStardardGameOptions() *GameOptions
type GameState ¶
type GameState struct {
GameID string `json:"game_id"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
Meta Meta `json:"meta"`
Status Status `json:"status"`
Players []*PlayerState `json:"players"`
Result *settlement.Result `json:"result,omitempty"`
}
func (*GameState) AsObserver ¶
func (gs *GameState) AsObserver()
func (*GameState) GetPlayer ¶
func (gs *GameState) GetPlayer(idx int) *PlayerState
type Meta ¶
type Meta struct {
Ante int64 `json:"ante"`
Blind BlindSetting `json:"blind"`
Limit string `json:"limit"`
HoleCardsCount int `json:"hole_cards_count"`
RequiredHoleCardsCount int `json:"required_hole_cards_count"`
CombinationPowers combination.PowerRankings `json:"combination_powers"`
Deck []string `json:"deck"`
BurnCount int `json:"burn_count"`
}
type Player ¶
type Player interface {
State() *PlayerState
SeatIndex() int
CheckAction(action string) bool
CheckPosition(pos string) bool
AllowActions(actions []string) error
ResetAllowedActions() error
Reset() error
Pass() error
Pay(chips int64) error
PayAnte() error
PayBlinds() error
Fold() error
Check() error
Call() error
Allin() error
Bet(chips int64) error
Raise(chipLevel int64) error
}
type PlayerSetting ¶
type PlayerState ¶
type PlayerState struct {
Idx int `json:"idx"`
Positions []string `json:"positions"`
// Status
Acted bool `json:"acted"`
DidAction string `json:"did_action,omitempty"`
Fold bool `json:"fold"`
VPIP bool `json:"vpip"` // Voluntarily Put In Pot
AllowedActions []string `json:"allowed_actions,omitempty"`
// Stack and wager
Bankroll int64 `json:"bankroll"`
InitialStackSize int64 `json:"initial_stack_size"` // bankroll - pot
StackSize int64 `json:"stack_size"` // initial_stack_size - wager
Pot int64 `json:"pot"`
Wager int64 `json:"wager"`
// Hole cards information
HoleCards []string `json:"hole_cards,omitempty"`
Combination *CombinationInfo `json:"combination,omitempty"`
}
func (*PlayerState) AllowAction ¶
func (ps *PlayerState) AllowAction(action string)
type PokerFace ¶
type PokerFace interface {
NewGame(opts *GameOptions) Game
NewGameFromState(gs *GameState) Game
}
func NewPokerFace ¶
func NewPokerFace() PokerFace
type RankInfo ¶
type RankInfo struct {
Player *PlayerState
Power *combination.PowerState
}
type Status ¶
type Status struct {
MiniBet int64 `json:"mini_bet"`
MaxWager int64 `json:"max_wager"`
Pots []*pot.Pot `json:"pots"`
Round string `json:"round,omitempty"`
Burned []string `json:"burned,omitempty"`
Board []string `json:"board,omitempty"`
PreviousRaiseSize int64 `json:"previous_raise_size"`
CurrentDeckPosition int `json:"current_deck_position"`
CurrentRoundPot int64 `json:"current_round_pot"`
CurrentWager int64 `json:"current_wager"`
CurrentRaiser int `json:"current_raiser"`
CurrentPlayer int `json:"current_player"`
CurrentEvent string `json:"current_event"`
LastAction *Action `json:"last_action,omitempty"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.