player

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Communicator added in v0.7.0

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 FingerPoint added in v0.4.0

type FingerPoint struct {
	From *Player
	To   *Player
}

A FingerPoint represents one player "pointing" at another in a real-life game of Werewolf. It can be used for both votes and night actions.

func (*FingerPoint) String added in v0.6.0

func (fp *FingerPoint) String() string

type LogCommunicator added in v0.20.0

type LogCommunicator struct {
}

func NewLogCommunicator added in v0.20.0

func NewLogCommunicator() *LogCommunicator

func (*LogCommunicator) Close added in v0.20.0

func (mc *LogCommunicator) Close() error

func (*LogCommunicator) ReadMessage added in v0.20.0

func (mc *LogCommunicator) ReadMessage() (int, []byte, error)

func (*LogCommunicator) WriteMessage added in v0.20.0

func (mc *LogCommunicator) WriteMessage(messageType int, data []byte) error

type MockCommunicator added in v0.7.0

type MockCommunicator struct {
	mock.Mock
}

func NewMockCommunicator added in v0.7.0

func NewMockCommunicator() *MockCommunicator

func (*MockCommunicator) Close added in v0.7.0

func (mc *MockCommunicator) Close() error

func (*MockCommunicator) ReadMessage added in v0.7.0

func (mc *MockCommunicator) ReadMessage() (int, []byte, error)

func (*MockCommunicator) WriteMessage added in v0.7.0

func (mc *MockCommunicator) WriteMessage(messageType int, data []byte) error

type Player

type Player struct {
	ID    uuid.UUID  `json:"id"`
	Name  string     `json:"name"`
	Role  *role.Role `json:"-"`
	Views []*View    `json:"-"`
	// contains filtered or unexported fields
}

func NewPlayer added in v0.2.0

func NewPlayer(socket Communicator) *Player

func (*Player) AddView added in v0.5.0

func (p *Player) AddView(v *View)

func (*Player) Message added in v0.7.0

func (p *Player) Message(t server.MessageType, payload interface{}) error

Message handles sending a message to the client, wrapping it in error handling

func (*Player) Play added in v0.7.0

func (p *Player) Play()

func (*Player) Reconnect added in v0.9.0

func (p *Player) Reconnect(c Communicator)

func (*Player) Reveal

func (p *Player) Reveal() *server.RevealedPlayer

func (*Player) SetGameChannel added in v0.13.0

func (p *Player) SetGameChannel(gc gamechannel.GameChannel)

func (*Player) SetName

func (p *Player) SetName(name string)

func (*Player) SetRole

func (p *Player) SetRole(r *role.Role)

func (*Player) String added in v0.3.0

func (p *Player) String() string

type View added in v0.2.0

type View struct {
	Player    *Player
	Attribute role.Attribute
	Role      *role.Role
	Hit       bool
	GamePhase int
}

A View represents a player's knowledge of another's role. It can be both a nighttime viewing (such as a seer viewing for max evil) or a generic "this player now knows the roles of one or more other players" (such as the wolves at the start of the game). It may not be successful, as in the case of a seer viewing a non-max, and it may even be incorrect, if there are tinkers!

func NewAttributeView added in v0.5.0

func NewAttributeView(p *Player, a role.Attribute, hit bool, phase int) *View

func NewRoleView added in v0.5.0

func NewRoleView(p *Player, r *role.Role, phase int) *View

func (*View) For added in v0.5.0

func (v *View) For() string

Jump to

Keyboard shortcuts

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