game

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: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

type Game struct {
	ID           uuid.UUID
	Leader       *player.Player
	VotingMethod VotingMethod
	AlivePlayers map[uuid.UUID]*player.Player
	Players      map[uuid.UUID]*player.Player

	Roleset *roleset.Roleset

	Phase int
	Tally *tally.Tally

	Winner role.PlayerType

	Password string
	// contains filtered or unexported fields
}

func NewGame added in v0.2.0

func NewGame(p *player.Player) *Game

func (*Game) AddPlayer

func (g *Game) AddPlayer(p *player.Player)

func (*Game) AliveMaxEvils

func (g *Game) AliveMaxEvils() []*player.Player

func (*Game) AlivePlayersByType added in v0.3.0

func (g *Game) AlivePlayersByType() (maxes []*player.Player, nonmaxes []*player.Player)

func (*Game) Broadcast added in v0.5.0

func (g *Game) Broadcast(t server.MessageType, payload interface{})

func (*Game) BroadcastPlayerList added in v0.13.0

func (g *Game) BroadcastPlayerList()

func (*Game) BroadcastView added in v0.11.0

func (g *Game) BroadcastView(v *player.View)

BroadcastView sends a view to every player, alive and dead. It is primarily used for revealing the roles of dead players.

func (*Game) ChooseRoleset added in v0.2.0

func (g *Game) ChooseRoleset(slug string) error

func (*Game) EndGame added in v0.3.0

func (g *Game) EndGame(winner role.PlayerType)

func (*Game) IsDay added in v0.3.0

func (g *Game) IsDay() bool

func (*Game) IsNight added in v0.3.0

func (g *Game) IsNight() bool

func (*Game) KillPlayer added in v0.3.0

func (g *Game) KillPlayer(p *player.Player)

func (*Game) ListenToGameChannel added in v0.13.0

func (g *Game) ListenToGameChannel()

func (*Game) Parity

func (g *Game) Parity() int

func (*Game) RevealPlayer added in v0.4.0

func (g *Game) RevealPlayer(p *player.Player)

func (*Game) SendLeaderMessages added in v0.21.0

func (g *Game) SendLeaderMessages()

func (*Game) SetLeader added in v0.13.0

func (g *Game) SetLeader(p *player.Player)

func (*Game) SetNightAction added in v0.4.0

func (g *Game) SetNightAction(fp *player.FingerPoint) error

func (*Game) Start

func (g *Game) Start() error

func (*Game) State

func (g *Game) State() GameState

func (*Game) ToGameOverMessage added in v0.30.0

func (g *Game) ToGameOverMessage() *server.GameOverMessage

func (*Game) Vote

func (g *Game) Vote(fp *player.FingerPoint) error

type GameState added in v0.2.0

type GameState int
const (
	Setup GameState = iota
	Running
	Finished
)

type PhaseError added in v0.3.0

type PhaseError struct {
	GamePhase int
}

func (*PhaseError) Error added in v0.3.0

func (e *PhaseError) Error() string

type PlayerCountError added in v0.2.0

type PlayerCountError struct {
	Roleset     *roleset.Roleset
	PlayerCount int
}

func (*PlayerCountError) Error added in v0.2.0

func (e *PlayerCountError) Error() string

type StateError added in v0.2.0

type StateError struct {
	NeedState GameState
	InState   GameState
}

func (*StateError) Error added in v0.2.0

func (e *StateError) Error() string

type VotingMethod added in v0.3.0

type VotingMethod int
const (
	// InstaKill means that as soon as one player has 51% of the vote they are killed and the day ends.
	InstaKill VotingMethod = iota
	// InstaKillWithDelay is the same as InstaKill, but with a delay to allow for claiming and changing of votes. It is not currently supported.
	InstaKillWithDelay
	// Timed will end the day after a set number of minutes, killing whoever is in the lead (breaking ties with Longest Held Last Vote). It is not currently supported.
	Timed
)

Jump to

Keyboard shortcuts

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