game

package
v0.0.0-...-f7464b4 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2018 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	GameCreating = iota
	GamePlaying
	GameFinished
)

Variables

View Source
var ErrGameNotStarted = errors.New("game not started")
View Source
var ErrNotEnoughPlayers = errors.New("not enough players in game")

Functions

This section is empty.

Types

type Game

type Game struct {
	Status  int
	Board   *board.Board
	Dice    *dice.Dice
	Players []*player.Player
	// contains filtered or unexported fields
}

func NewGame

func NewGame() *Game

func (*Game) AddPlayer

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

func (*Game) BroadCastPlayerLeft

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

func (*Game) CheckStartGame

func (g *Game) CheckStartGame()

func (*Game) Disconnect

func (g *Game) Disconnect(conn *websocket.Conn)

func (*Game) FirstTurn

func (g *Game) FirstTurn() (err error)

func (*Game) GetPlayer

func (g *Game) GetPlayer(conn *websocket.Conn) (*player.Player, int)

func (*Game) NextPosition

func (g *Game) NextPosition(p *player.Player) int

func (*Game) NextTurn

func (g *Game) NextTurn()

func (*Game) RemovePlayerByIndex

func (g *Game) RemovePlayerByIndex(index int)

func (*Game) SendAllPlayersPositions

func (g *Game) SendAllPlayersPositions()

func (*Game) SendAllPlayersUpdate

func (g *Game) SendAllPlayersUpdate(messageType string, data interface{})

func (*Game) SendPlayerUpdate

func (g *Game) SendPlayerUpdate(p *player.Player, messageType string, data interface{})

func (*Game) StartGame

func (g *Game) StartGame() (err error)

func (*Game) Started

func (g *Game) Started() bool

func (*Game) ThrowDice

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

type PositionUpdate

type PositionUpdate struct {
	Name     string `json:"name"`
	Position int    `json:"position"`
	Ready    bool   `json:"ready"`
	HasTurn  bool   `json:"has_turn"`
}

type Update

type Update struct {
	Receiver *player.Player
	Message  *networking.Message
}

Jump to

Keyboard shortcuts

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