Documentation ¶
Index ¶
- type Communicator
- type GamePlayer
- func (p *GamePlayer) ID() string
- func (p *GamePlayer) Identifier() string
- func (p *GamePlayer) InGame() bool
- func (p *GamePlayer) LeaveGame()
- func (p *GamePlayer) Message(title string, payload interface{}) error
- func (p *GamePlayer) NightAction(to string)
- func (p *GamePlayer) Play()
- func (p *GamePlayer) Quit()
- func (p *GamePlayer) Reconnect(c Communicator)
- func (p *GamePlayer) Reveal() *Revealed
- func (p *GamePlayer) Role() *role.Role
- func (p *GamePlayer) SetChan(c chan *chanmsg.Activity)
- func (p *GamePlayer) SetLeader()
- func (p *GamePlayer) SetName(name string)
- func (p *GamePlayer) SetRole(r *role.Role)
- func (p *GamePlayer) Vote(to string)
- type Player
- type Revealed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Communicator ¶
type Communicator interface { ReadMessage() (messageType int, p []byte, err error) WriteMessage(messageType int, data []byte) error Close() error }
A Communicator is an interface that is satisfied by github.com/gorilla/websocket and can be implemented by mocked/stubbed structs for testing and web-independent purposes.
type GamePlayer ¶
type GamePlayer struct { UUID uuid.UUID `json:"uuid"` Leader bool `json:"leader"` Name string `json:"name,omitempty"` // contains filtered or unexported fields }
func New ¶
func New(socket Communicator, joinChan chan Player) *GamePlayer
func (*GamePlayer) ID ¶
func (p *GamePlayer) ID() string
func (*GamePlayer) Identifier ¶
func (p *GamePlayer) Identifier() string
func (*GamePlayer) InGame ¶
func (p *GamePlayer) InGame() bool
func (*GamePlayer) LeaveGame ¶
func (p *GamePlayer) LeaveGame()
func (*GamePlayer) Message ¶
func (p *GamePlayer) Message(title string, payload interface{}) error
Message wraps the error checking around encoding a message.Message, and sends it on the websocket.
func (*GamePlayer) NightAction ¶
func (p *GamePlayer) NightAction(to string)
func (*GamePlayer) Play ¶
func (p *GamePlayer) Play()
Play is the loop that runs for a websocket to communicate between the client and server. If websockets are not being used, this will not trigger.
func (*GamePlayer) Quit ¶
func (p *GamePlayer) Quit()
func (*GamePlayer) Reconnect ¶
func (p *GamePlayer) Reconnect(c Communicator)
func (*GamePlayer) Reveal ¶
func (p *GamePlayer) Reveal() *Revealed
func (*GamePlayer) Role ¶
func (p *GamePlayer) Role() *role.Role
func (*GamePlayer) SetChan ¶
func (p *GamePlayer) SetChan(c chan *chanmsg.Activity)
func (*GamePlayer) SetLeader ¶
func (p *GamePlayer) SetLeader()
func (*GamePlayer) SetName ¶
func (p *GamePlayer) SetName(name string)
func (*GamePlayer) SetRole ¶
func (p *GamePlayer) SetRole(r *role.Role)
func (*GamePlayer) Vote ¶
func (p *GamePlayer) Vote(to string)
type Player ¶
type Player interface { ID() string Identifier() string Reveal() *Revealed Message(title string, payload interface{}) error SetChan(c chan *chanmsg.Activity) Vote(to string) NightAction(to string) Play() InGame() bool LeaveGame() SetLeader() SetName(name string) SetRole(r *role.Role) Reconnect(c Communicator) Role() *role.Role Quit() }
Click to show internal directories.
Click to hide internal directories.