Documentation ¶
Index ¶
- Constants
- Variables
- func FindDealerPlayerIndex(gameCount, prevDealerSeatIdx, minPlayingCount, maxSeatCount int, ...) int
- func FindGamePlayerIndexes(dealerSeatIdx int, seatMap []int, players []*TablePlayerState) []int
- func GetPlayerPositionMap(rule string, players []*TablePlayerState, gamePlayerIndexes []int) map[int][]string
- func IsBetweenDealerBB(seatIdx, currDealerTableSeatIdx, currBBTableSeatIdx, maxPlayerCount int, ...) bool
- func NewDefaultSeatMap(seatCount int) []int
- func NewGame(backend GameBackend, opts *pokerface.GameOptions) *game
- func RandomSeats(seatMap []int, count int) ([]int, error)
- type Game
- type GameBackend
- type JoinPlayer
- type Manager
- type NativeGameBackend
- func (ngb *NativeGameBackend) Allin(gs *pokerface.GameState) (*pokerface.GameState, error)
- func (ngb *NativeGameBackend) Bet(gs *pokerface.GameState, chips int64) (*pokerface.GameState, error)
- func (ngb *NativeGameBackend) Call(gs *pokerface.GameState) (*pokerface.GameState, error)
- func (ngb *NativeGameBackend) Check(gs *pokerface.GameState) (*pokerface.GameState, error)
- func (ngb *NativeGameBackend) CreateGame(opts *pokerface.GameOptions) (*pokerface.GameState, error)
- func (ngb *NativeGameBackend) Fold(gs *pokerface.GameState) (*pokerface.GameState, error)
- func (ngb *NativeGameBackend) Next(gs *pokerface.GameState) (*pokerface.GameState, error)
- func (ngb *NativeGameBackend) Pass(gs *pokerface.GameState) (*pokerface.GameState, error)
- func (ngb *NativeGameBackend) Pay(gs *pokerface.GameState, chips int64) (*pokerface.GameState, error)
- func (ngb *NativeGameBackend) PayAnte(gs *pokerface.GameState) (*pokerface.GameState, error)
- func (ngb *NativeGameBackend) PayBlinds(gs *pokerface.GameState) (*pokerface.GameState, error)
- func (ngb *NativeGameBackend) Raise(gs *pokerface.GameState, chipLevel int64) (*pokerface.GameState, error)
- func (ngb *NativeGameBackend) ReadyForAll(gs *pokerface.GameState) (*pokerface.GameState, error)
- type Table
- func (t Table) AlivePlayers() []*TablePlayerState
- func (t Table) Clone() (*Table, error)
- func (t Table) FindGamePlayerIdx(playerID string) int
- func (t Table) FindPlayerIdx(playerID string) int
- func (t Table) GamePlayerIndex(playerID string) int
- func (t Table) GetGameStateJSON() (string, error)
- func (t Table) GetJSON() (string, error)
- func (t Table) ParticipatedPlayers() []*TablePlayerState
- func (t Table) PlayerSeatMap() map[string]int
- func (t Table) ShouldPause() bool
- type TableBlindState
- type TableEngine
- type TableEngineCallbacks
- type TableEngineOpt
- type TableEngineOptions
- type TableMeta
- type TablePlayerGameAction
- type TablePlayerGameStatistics
- type TablePlayerState
- type TableSetting
- type TableState
- type TableStateStatus
Constants ¶
View Source
const ( // General UnsetValue = -1 // CompetitionMode CompetitionMode_Cash = "cash" // CompetitionRule CompetitionRule_Default = "default" CompetitionRule_ShortDeck = "short_deck" CompetitionRule_Omaha = "omaha" // Position Position_Unknown = "unknown" Position_Dealer = "dealer" Position_SB = "sb" Position_BB = "bb" Position_UG = "ug" Position_UG2 = "ug2" Position_UG3 = "ug3" Position_MP = "mp" Position_MP2 = "mp2" Position_HJ = "hj" Position_CO = "co" // Action Action_Ready = "ready" Action_Pay = "pay" // Wager Action WagerAction_Fold = "fold" WagerAction_Check = "check" WagerAction_Call = "call" WagerAction_AllIn = "allin" WagerAction_Bet = "bet" WagerAction_Raise = "raise" // Round GameRound_Preflop = "preflop" GameRound_Flop = "flop" GameRound_Turn = "turn" GameRound_River = "river" )
Variables ¶
View Source
var ( ErrTableNoEmptySeats = errors.New("table: no empty seats available") ErrTableInvalidCreateSetting = errors.New("table: invalid create table setting") ErrTablePlayerNotFound = errors.New("table: player not found") ErrTablePlayerInvalidGameAction = errors.New("table: player invalid game action") ErrTablePlayerInvalidAction = errors.New("table: player invalid action") ErrTableOpenGameFailed = errors.New("table: failed to open game") )
View Source
var ( ErrGamePlayerNotFound = errors.New("game: player not found") ErrGameInvalidAction = errors.New("game: invalid action") ErrGameUnknownEvent = errors.New("game: unknown event") ErrGameUnknownEventHandler = errors.New("game: unknown event handler") )
View Source
var (
ErrManagerTableNotFound = errors.New("manager: table not found")
)
Functions ¶
func FindDealerPlayerIndex ¶
func FindDealerPlayerIndex(gameCount, prevDealerSeatIdx, minPlayingCount, maxSeatCount int, players []*TablePlayerState, seatMap []int) int
func FindGamePlayerIndexes ¶
func FindGamePlayerIndexes(dealerSeatIdx int, seatMap []int, players []*TablePlayerState) []int
func GetPlayerPositionMap ¶
func GetPlayerPositionMap(rule string, players []*TablePlayerState, gamePlayerIndexes []int) map[int][]string
func IsBetweenDealerBB ¶
func NewDefaultSeatMap ¶
func NewGame ¶
func NewGame(backend GameBackend, opts *pokerface.GameOptions) *game
Types ¶
type Game ¶
type Game interface { // Events OnGameStateUpdated(func(*pokerface.GameState)) OnGameErrorUpdated(func(*pokerface.GameState, error)) // Others GetGameState() *pokerface.GameState Start() (*pokerface.GameState, error) Next() (*pokerface.GameState, error) // Group Actions ReadyForAll() (*pokerface.GameState, error) PayAnte() (*pokerface.GameState, error) PayBlinds() (*pokerface.GameState, error) // Single Actions Ready(playerIdx int) (*pokerface.GameState, error) Pay(playerIdx int, chips int64) (*pokerface.GameState, error) Pass(playerIdx int) (*pokerface.GameState, error) Fold(playerIdx int) (*pokerface.GameState, error) Check(playerIdx int) (*pokerface.GameState, error) Call(playerIdx int) (*pokerface.GameState, error) Allin(playerIdx int) (*pokerface.GameState, error) Bet(playerIdx int, chips int64) (*pokerface.GameState, error) Raise(playerIdx int, chipLevel int64) (*pokerface.GameState, error) }
type GameBackend ¶
type GameBackend interface { CreateGame(opts *pokerface.GameOptions) (*pokerface.GameState, error) ReadyForAll(gs *pokerface.GameState) (*pokerface.GameState, error) PayAnte(gs *pokerface.GameState) (*pokerface.GameState, error) PayBlinds(gs *pokerface.GameState) (*pokerface.GameState, error) Next(gs *pokerface.GameState) (*pokerface.GameState, error) Pay(gs *pokerface.GameState, chips int64) (*pokerface.GameState, error) Fold(gs *pokerface.GameState) (*pokerface.GameState, error) Check(gs *pokerface.GameState) (*pokerface.GameState, error) Call(gs *pokerface.GameState) (*pokerface.GameState, error) Allin(gs *pokerface.GameState) (*pokerface.GameState, error) Bet(gs *pokerface.GameState, chips int64) (*pokerface.GameState, error) Raise(gs *pokerface.GameState, chipLevel int64) (*pokerface.GameState, error) Pass(gs *pokerface.GameState) (*pokerface.GameState, error) }
type JoinPlayer ¶
type Manager ¶
type Manager interface { Reset() // Table Actions GetTableEngine(tableID string) (TableEngine, error) CreateTable(options *TableEngineOptions, callbacks *TableEngineCallbacks, setting TableSetting) (*Table, error) PauseTable(tableID string) error CloseTable(tableID string) error StartTableGame(tableID string) error TableGameOpen(tableID string) error UpdateBlind(tableID string, level int, ante, dealer, sb, bb int64) error // Player Table Actions PlayerReserve(tableID string, joinPlayer JoinPlayer) error PlayerJoin(tableID, playerID string) error PlayerRedeemChips(tableID string, joinPlayer JoinPlayer) error PlayersLeave(tableID string, playerIDs []string) error // Player Game Actions PlayerReady(tableID, playerID string) error PlayerPay(tableID, playerID string, chips int64) error PlayerBet(tableID, playerID string, chips int64) error PlayerRaise(tableID, playerID string, chipLevel int64) error PlayerCall(tableID, playerID string) error PlayerAllin(tableID, playerID string) error PlayerCheck(tableID, playerID string) error PlayerFold(tableID, playerID string) error PlayerPass(tableID, playerID string) error }
func NewManager ¶
func NewManager() Manager
type NativeGameBackend ¶
type NativeGameBackend struct {
// contains filtered or unexported fields
}
func NewNativeGameBackend ¶
func NewNativeGameBackend() *NativeGameBackend
func (*NativeGameBackend) CreateGame ¶
func (ngb *NativeGameBackend) CreateGame(opts *pokerface.GameOptions) (*pokerface.GameState, error)
func (*NativeGameBackend) ReadyForAll ¶
type Table ¶
type Table struct { UpdateSerial int64 `json:"update_serial"` ID string `json:"id"` Meta TableMeta `json:"meta"` State *TableState `json:"state"` UpdateAt int64 `json:"update_at"` }
func (Table) AlivePlayers ¶
func (t Table) AlivePlayers() []*TablePlayerState
func (Table) FindGamePlayerIdx ¶
func (Table) FindPlayerIdx ¶
func (Table) GamePlayerIndex ¶
func (Table) GetGameStateJSON ¶
func (Table) ParticipatedPlayers ¶
func (t Table) ParticipatedPlayers() []*TablePlayerState
func (Table) PlayerSeatMap ¶
func (Table) ShouldPause ¶
type TableBlindState ¶
type TableBlindState struct { Level int `json:"level"` Ante int64 `json:"ante"` Dealer int64 `json:"dealer"` SB int64 `json:"sb"` BB int64 `json:"bb"` }
func (TableBlindState) IsBreaking ¶
func (bs TableBlindState) IsBreaking() bool
func (TableBlindState) IsSet ¶
func (bs TableBlindState) IsSet() bool
type TableEngine ¶
type TableEngine interface { OnTableUpdated(fn func(table *Table)) OnTableErrorUpdated(fn func(table *Table, err error)) OnTableStateUpdated(fn func(string, *Table)) OnTablePlayerStateUpdated(fn func(string, string, *TablePlayerState)) OnTablePlayerReserved(fn func(competitionID, tableID string, playerState *TablePlayerState)) OnGamePlayerActionUpdated(fn func(TablePlayerGameAction)) GetTable() *Table GetGame() Game CreateTable(tableSetting TableSetting) (*Table, error) PauseTable() error CloseTable() error StartTableGame() error TableGameOpen() error UpdateBlind(level int, ante, dealer, sb, bb int64) PlayerReserve(joinPlayer JoinPlayer) error PlayerJoin(playerID string) error PlayerRedeemChips(joinPlayer JoinPlayer) error PlayersLeave(playerIDs []string) error PlayerReady(playerID string) error PlayerPay(playerID string, chips int64) error PlayerBet(playerID string, chips int64) error PlayerRaise(playerID string, chipLevel int64) error PlayerCall(playerID string) error PlayerAllin(playerID string) error PlayerCheck(playerID string) error PlayerFold(playerID string) error PlayerPass(playerID string) error }
func NewTableEngine ¶
func NewTableEngine(options *TableEngineOptions, opts ...TableEngineOpt) TableEngine
type TableEngineCallbacks ¶
type TableEngineCallbacks struct { OnTableUpdated func(t *Table) OnTableErrorUpdated func(t *Table, err error) OnTableStateUpdated func(string, *Table) OnTablePlayerStateUpdated func(string, string, *TablePlayerState) OnTablePlayerReserved func(string, string, *TablePlayerState) OnGamePlayerActionUpdated func(TablePlayerGameAction) }
func NewTableEngineCallbacks ¶
func NewTableEngineCallbacks() *TableEngineCallbacks
type TableEngineOpt ¶
type TableEngineOpt func(*tableEngine)
func WithGameBackend ¶
func WithGameBackend(gb GameBackend) TableEngineOpt
type TableEngineOptions ¶
type TableEngineOptions struct {
Interval int
}
func NewTableEngineOptions ¶
func NewTableEngineOptions() *TableEngineOptions
type TableMeta ¶
type TableMeta struct { CompetitionID string `json:"competition_id"` Rule string `json:"rule"` Mode string `json:"mode"` MaxDuration int `json:"max_duration"` TableMaxSeatCount int `json:"table_max_seat_count"` TableMinPlayerCount int `json:"table_min_player_count"` MinChipUnit int64 `json:"min_chip_unit"` ActionTime int `json:"action_time"` }
type TablePlayerGameAction ¶
type TablePlayerGameAction struct { CompetitionID string `json:"competition_id"` TableID string `json:"table_id"` GameID string `json:"game_id"` GameCount int `json:"game_count"` Round string `json:"round"` UpdateAt int64 `json:"update_at"` PlayerID string `json:"player_id"` Seat int `json:"seat"` Positions []string `json:"positions"` Action string `json:"action"` Chips int64 `json:"chips"` Bankroll int64 `json:"bankroll"` InitialStackSize int64 `json:"initial_stack_size"` StackSize int64 `json:"stack_size"` Pot int64 `json:"pot"` Wager int64 `json:"wager"` }
type TablePlayerState ¶
type TablePlayerState struct { PlayerID string `json:"player_id"` Seat int `json:"seat"` Positions []string `json:"positions"` IsParticipated bool `json:"is_participated"` IsBetweenDealerBB bool `json:"is_between_dealer_bb"` Bankroll int64 `json:"bankroll"` IsIn bool `json:"is_in"` GameStatistics TablePlayerGameStatistics `json:"game_statistics"` }
type TableSetting ¶
type TableSetting struct { TableID string `json:"table_id"` Meta TableMeta `json:"table_meta"` JoinPlayers []JoinPlayer `json:"join_players"` }
type TableState ¶
type TableState struct { Status TableStateStatus `json:"status"` StartAt int64 `json:"start_at"` SeatMap []int `json:"seat_map"` BlindState *TableBlindState `json:"blind_state"` CurrentDealerSeat int `json:"current_dealer_seat"` CurrentBBSeat int `json:"current_bb_seat"` PlayerStates []*TablePlayerState `json:"player_states"` GameCount int `json:"game_count"` GamePlayerIndexes []int `json:"game_player_indexes"` GameState *pokerface.GameState `json:"game_state"` }
type TableStateStatus ¶
type TableStateStatus string
const ( TableStateStatus_TableCreated TableStateStatus = "table_created" TableStateStatus_TablePausing TableStateStatus = "table_pausing" TableStateStatus_TableRestoring TableStateStatus = "table_restoring" TableStateStatus_TableBalancing TableStateStatus = "table_balancing" TableStateStatus_TableClosed TableStateStatus = "table_closed" TableStateStatus_TableGameOpened TableStateStatus = "table_game_opened" TableStateStatus_TableGamePlaying TableStateStatus = "table_game_playing" TableStateStatus_TableGameSettled TableStateStatus = "table_game_settled" TableStateStatus_TableGameStandby TableStateStatus = "table_game_standby" )
Source Files ¶
Click to show internal directories.
Click to hide internal directories.