Documentation
¶
Index ¶
- func JSON(w http.ResponseWriter, status int, v any) error
- type APIServer
- type AtomicInt
- type BroadcastTo
- type GameState
- func (g *GameState) AddPlayer(from string)
- func (g *GameState) InitiateShuffleAndDeal()
- func (g *GameState) SetPlayerReady(addr string)
- func (g *GameState) SetReady()
- func (g *GameState) SetStatus(s GameStatus)
- func (g *GameState) ShuffleAndEncrypt(from string, deck [][]byte) error
- func (g *GameState) TakeAction(action PlayerAction, value int) error
- type GameStatus
- type GameVariant
- type Handshake
- type Message
- type MessageEncDeck
- type MessagePeerList
- type MessagePlayerAction
- type MessagePreFlop
- type MessageReady
- type MyError
- type NetAddr
- type Peer
- type Player
- type PlayerAction
- type PlayersList
- type Server
- type ServerConfig
- type State
- type TCPTransport
- type Table
- func (t *Table) AddPlayer(addr string) error
- func (t *Table) AddPlayerOnPosition(addr string, pos int) error
- func (t *Table) GetPlayer(addr string) (*Player, error)
- func (t *Table) GetPlayerAfter(addr string) (*Player, error)
- func (t *Table) GetPlayerBefore(addr string) (*Player, error)
- func (t *Table) LenPlayers() int
- func (t *Table) Players() []*Player
- func (t *Table) RemovePlayerByAddr(addr string) error
- func (t *Table) SetPlayerStatus(addr string, s GameStatus)
- func (t *Table) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIServer ¶
type APIServer struct {
// contains filtered or unexported fields
}
func NewAPIServer ¶
type AtomicInt ¶
type AtomicInt struct {
// contains filtered or unexported fields
}
func NewAtomicInt ¶
type BroadcastTo ¶
type GameState ¶
type GameState struct {
// contains filtered or unexported fields
}
func NewGame ¶
func NewGame(addr string, bc chan BroadcastTo) *GameState
func (*GameState) InitiateShuffleAndDeal ¶
func (g *GameState) InitiateShuffleAndDeal()
func (*GameState) SetPlayerReady ¶
SetPlayerReady is getting called when we receive a ready message from a player in the network taking a seat on the table.
func (*GameState) SetReady ¶
func (g *GameState) SetReady()
SetReady is being called when we set ourselfs as ready.
func (*GameState) SetStatus ¶
func (g *GameState) SetStatus(s GameStatus)
func (*GameState) ShuffleAndEncrypt ¶
func (*GameState) TakeAction ¶
func (g *GameState) TakeAction(action PlayerAction, value int) error
type GameStatus ¶
type GameStatus int32
const ( GameStatusConnected GameStatus = iota GameStatusPlayerReady GameStatusDealing GameStatusPreFlop GameStatusFlop GameStatusTurn GameStatusRiver )
func (GameStatus) String ¶
func (g GameStatus) String() string
type GameVariant ¶
type GameVariant uint8
const ( TexasHoldem GameVariant = iota Other )
func (GameVariant) String ¶
func (gv GameVariant) String() string
type Handshake ¶
type Handshake struct { Version string GameVariant GameVariant GameStatus GameStatus ListenAddr string }
type Message ¶
func NewMessage ¶
type MessageEncDeck ¶
type MessageEncDeck struct {
Deck [][]byte
}
type MessagePeerList ¶
type MessagePeerList struct {
Peers []string
}
type MessagePlayerAction ¶
type MessagePlayerAction struct { // CurrentGameStatus is the current status of the sending player his game. // this needs to the exact same as ours. CurrentGameStatus GameStatus // Action is the action that the player is willin to take. Action PlayerAction // The value of the bet if any Value int }
type MessagePreFlop ¶
type MessagePreFlop struct{}
func (MessagePreFlop) String ¶
func (msg MessagePreFlop) String() string
type MessageReady ¶
type MessageReady struct{}
func (MessageReady) String ¶
func (msg MessageReady) String() string
type PlayerAction ¶
type PlayerAction byte
const ( PlayerActionNone PlayerAction = iota PlayerActionFold PlayerActionCheck PlayerActionBet )
func (PlayerAction) String ¶
func (pa PlayerAction) String() string
type PlayersList ¶
type PlayersList struct {
// contains filtered or unexported fields
}
func NewPlayersList ¶
func NewPlayersList() *PlayersList
func (*PlayersList) Len ¶
func (p *PlayersList) Len() int
func (*PlayersList) Less ¶
func (p *PlayersList) Less(i, j int) bool
func (*PlayersList) List ¶
func (p *PlayersList) List() []string
func (*PlayersList) Swap ¶
func (p *PlayersList) Swap(i, j int)
type Server ¶
type Server struct { ServerConfig // contains filtered or unexported fields }
func NewServer ¶
func NewServer(cfg ServerConfig) *Server
func (*Server) Broadcast ¶
func (s *Server) Broadcast(broadcastMsg BroadcastTo) error
func (*Server) Connect ¶
TODO(@anthdm): Right now we have some redundent code in registering new peers to the game network. maybe construct a new peer and handshake protocol after registering a plain connection?
func (*Server) SendHandshake ¶
type ServerConfig ¶
type ServerConfig struct { Version string ListenAddr string APIListenAddr string GameVariant GameVariant MaxPlayers int }
type TCPTransport ¶
type TCPTransport struct { AddPeer chan *Peer DelPeer chan *Peer // contains filtered or unexported fields }
func NewTCPTransport ¶
func NewTCPTransport(addr string) *TCPTransport
func (*TCPTransport) ListenAndAccept ¶
func (t *TCPTransport) ListenAndAccept() error
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (*Table) LenPlayers ¶
func (*Table) RemovePlayerByAddr ¶
func (*Table) SetPlayerStatus ¶
func (t *Table) SetPlayerStatus(addr string, s GameStatus)
Click to show internal directories.
Click to hide internal directories.