player

package
v0.0.0-...-d92090f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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()
}

type Revealed

type Revealed struct {
	UUID     uuid.UUID `json:"uuid"`
	Name     string    `json:"name,omitempty"`
	RoleName string    `json:"role"`
	Alive    bool      `json:"alive"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL