Documentation ¶
Index ¶
- Constants
- Variables
- type DispatchRequest
- type Dispatcher
- type Match
- type MatchOpt
- type MatchStatus
- type NativeQueueManager
- type NativeRunner
- type NativeTableBackend
- func (tb *NativeTableBackend) Activate(tableID string) error
- func (tb *NativeTableBackend) Allocate(maxSeats int) (*Table, error)
- func (tb *NativeTableBackend) GetTable(tableID string) (*Table, error)
- func (tb *NativeTableBackend) OnTableUpdated(fn func(tableID string, sc *SeatChanges))
- func (tb *NativeTableBackend) Release(tableID string) error
- func (tb *NativeTableBackend) Reserve(tableID string, seatID int, playerID string) error
- func (tb *NativeTableBackend) UpdateTable(tableID string, sc *SeatChanges) error
- type Options
- type Queue
- type QueueManager
- type Runner
- type SeatChanges
- type Stack
- type Table
- func (t *Table) ApplySeatChanges(sc *SeatChanges) error
- func (t *Table) GetAvailableSeatCount() int
- func (t *Table) GetPlayerCount() int
- func (t *Table) GetPlayers() ([]string, error)
- func (t *Table) GetSeatCount() int
- func (t *Table) GetStatus() TableStatus
- func (t *Table) ID() string
- func (t *Table) Join(seatID int, playerID string) error
- func (t *Table) OnPlayerDrained(fn func(string, int))
- func (t *Table) OnPlayerJoined(fn func(string, int))
- func (t *Table) OnPlayerLeft(fn func(string, int))
- func (t *Table) PrintState()
- func (t *Table) Release() error
- func (t *Table) SeatManager() *seat_manager.SeatManager
- func (t *Table) SetID(id string)
- func (t *Table) SetStatus(status TableStatus) error
- type TableBackend
- type TableCondition
- type TableMap
- type TableStatus
- type WaitingRoom
Constants ¶
View Source
const ( MatchStatus_Normal = iota MatchStatus_AfterRegDeadline )
Variables ¶
View Source
var ( ErrNotFoundTable = errors.New("match: not found table") ErrNotFoundAvailableTable = errors.New("match: not found available table") ErrAfterRegDealline = errors.New("match: the final registration time has passed") ErrMaxPlayersReached = errors.New("match: the current number of players has reached the maximum limit") )
Functions ¶
This section is empty.
Types ¶
type DispatchRequest ¶ added in v0.0.2
type Dispatcher ¶
type Dispatcher interface { Start() error Close() error GetPendingCount() int64 Dispatch(playerID string, highestNumberOfPlayers bool) error OnFailure(func(err error, playerID string)) }
func NewDispatcher ¶
func NewDispatcher(m Match) Dispatcher
type Match ¶
type Match interface { Options() *Options Dispatcher() Dispatcher WaitingRoom() WaitingRoom QueueManager() QueueManager TableBackend() TableBackend Runner() Runner TableMap() TableMap Close() error GetStatus() MatchStatus DisableRegistration() IsLastTableStage() bool Register(playerID string) error BreakTable(tableID string) error ApplySeatChanges(tableID string, sc *SeatChanges) error GetPlayerCount() int64 PrintTables() AllocateTableWithPlayers(players []string) error OnPlayerJoined(fn func(Match, *Table, int, string)) OnTableBroken(fn func(Match, *Table)) }
type MatchOpt ¶
type MatchOpt func(*match)
func WithQueueManager ¶
func WithQueueManager(qm QueueManager) MatchOpt
func WithRunner ¶
func WithTableBackend ¶
func WithTableBackend(tb TableBackend) MatchOpt
func WithTableBrokenCallback ¶
type MatchStatus ¶
type MatchStatus int
type NativeQueueManager ¶
type NativeQueueManager struct {
// contains filtered or unexported fields
}
func (*NativeQueueManager) AssertQueue ¶
func (nqm *NativeQueueManager) AssertQueue(queueName string, subject string) (Queue, error)
func (*NativeQueueManager) Close ¶
func (nqm *NativeQueueManager) Close() error
func (*NativeQueueManager) Conn ¶
func (nqm *NativeQueueManager) Conn() *nats.Conn
func (*NativeQueueManager) Connect ¶
func (nqm *NativeQueueManager) Connect() error
type NativeRunner ¶
type NativeRunner struct { }
func NewNativeRunner ¶
func NewNativeRunner() *NativeRunner
func (*NativeRunner) DismissTable ¶
func (nr *NativeRunner) DismissTable(m Match, table *Table) error
func (*NativeRunner) DrainWaitingRoomPlayers ¶
func (nr *NativeRunner) DrainWaitingRoomPlayers(m Match, players []string) error
func (*NativeRunner) ShouldBeSplit ¶
func (nr *NativeRunner) ShouldBeSplit(m Match, table *Table) bool
type NativeTableBackend ¶
type NativeTableBackend struct {
// contains filtered or unexported fields
}
func NewDummyTableBackend ¶
func NewDummyTableBackend() *NativeTableBackend
func (*NativeTableBackend) Activate ¶
func (tb *NativeTableBackend) Activate(tableID string) error
func (*NativeTableBackend) Allocate ¶
func (tb *NativeTableBackend) Allocate(maxSeats int) (*Table, error)
func (*NativeTableBackend) GetTable ¶
func (tb *NativeTableBackend) GetTable(tableID string) (*Table, error)
func (*NativeTableBackend) OnTableUpdated ¶
func (tb *NativeTableBackend) OnTableUpdated(fn func(tableID string, sc *SeatChanges))
func (*NativeTableBackend) Release ¶
func (tb *NativeTableBackend) Release(tableID string) error
func (*NativeTableBackend) Reserve ¶
func (tb *NativeTableBackend) Reserve(tableID string, seatID int, playerID string) error
func (*NativeTableBackend) UpdateTable ¶
func (tb *NativeTableBackend) UpdateTable(tableID string, sc *SeatChanges) error
type Options ¶
type Options struct { ID string `json:"id"` WaitingPeriod int `json:"waiting_period"` MinInitialPlayers int `json:"min_initial_player"` MaxSeats int `json:"max_seats"` MaxTables int `json:"max_tables"` Joinable bool `json:"joinable"` BreakThreshold int `json:"break_threshold"` }
func NewOptions ¶
type Queue ¶
type QueueManager ¶
type QueueManager interface { Connect() error Close() error Conn() *nats.Conn AssertQueue(queueName string, subject string) (Queue, error) }
func NewNativeQueueManager ¶
func NewNativeQueueManager() QueueManager
type SeatChanges ¶
type SeatChanges struct { Dealer int `json:"dealer"` // The seat number of the dealer SB int `json:"sb"` // The seat number of small blind BB int `json:"bb"` // The seat number of big blind Seats map[int]string `json:"seats"` // Seat states (eg: left) }
func NewSeatChanges ¶
func NewSeatChanges() *SeatChanges
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (*Table) ApplySeatChanges ¶
func (t *Table) ApplySeatChanges(sc *SeatChanges) error
func (*Table) GetAvailableSeatCount ¶
func (*Table) GetPlayerCount ¶
func (*Table) GetPlayers ¶
func (*Table) GetSeatCount ¶
func (*Table) GetStatus ¶
func (t *Table) GetStatus() TableStatus
func (*Table) OnPlayerDrained ¶
func (*Table) OnPlayerJoined ¶
func (*Table) OnPlayerLeft ¶
func (*Table) PrintState ¶
func (t *Table) PrintState()
func (*Table) SeatManager ¶
func (t *Table) SeatManager() *seat_manager.SeatManager
func (*Table) SetStatus ¶
func (t *Table) SetStatus(status TableStatus) error
type TableBackend ¶
type TableBackend interface { Allocate(maxSeats int) (*Table, error) Release(tableID string) error Activate(tableID string) error Reserve(tableID string, seatID int, playerID string) error GetTable(tableID string) (*Table, error) UpdateTable(tableID string, sc *SeatChanges) error OnTableUpdated(func(tableID string, sc *SeatChanges)) }
type TableCondition ¶
type TableMap ¶
type TableMap interface { GetTables() (map[string]*Table, error) CreateTable(players []string) (*Table, error) BreakTable(tableID string) error GetTable(tableID string) (*Table, error) ApplySeatChanges(tableID string, sc *SeatChanges) error FindAvailableTable(condition *TableCondition) (*Table, error) DispatchPlayer(condition *TableCondition, playerID string) error Count() int64 OnTableBroken(func(*Table)) OnPlayerLeft(func(table *Table, seatID int, playerID string)) OnPlayerJoined(func(table *Table, seatID int, playerID string)) }
func NewTableMap ¶
type TableStatus ¶
type TableStatus int
const ( TableStatus_Preparing TableStatus = iota TableStatus_Ready TableStatus_Busy TableStatus_Broken TableStatus_Suspend )
type WaitingRoom ¶
type WaitingRoom interface { Count() (int, error) Enter(playerID string) error Leave(playerID string) error Drain() error Match() error Flush() error }
func NewWaitingRoom ¶
func NewWaitingRoom(m Match) WaitingRoom
Click to show internal directories.
Click to hide internal directories.