games

package
v0.0.0-...-b0d4320 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

type Game struct {
	// ID is the id of the game
	ID string
	// Name is the name of the game given by the initiator
	Name string
	// Initiator is the connection of the player who started the game
	Initiator *connection.Conn
	// Player2 is the connection of player 2
	Player2 *connection.Conn
	// InitTime is the time the game object was initiated
	InitTime time.Time
	// Ready is true if both players are in the game
	Ready bool
	// USD is the connection to the Unix domain socket
	UDS net.Conn
	// UDSPath is the filesystem path to the unix domain socket
	UDSPath string

	// FinChan is the channel that will send a message when the game can be deleted
	FinChan chan bool
	// contains filtered or unexported fields
}

Game is a structure which handles a game

func NewGame

func NewGame(initiator *connection.Conn, name string) *Game

NewGame returns a pointer to a game instance given two connections

func (*Game) Bytes

func (g *Game) Bytes() []byte

Bytes returns an API friendly binary representation of the game object which can be sent to clients.

func (*Game) Identification

func (g *Game) Identification() string

Identification returns a human readable way of differenciating between games

func (*Game) Kill

func (g *Game) Kill()

Kill destroys all game related gorutines

func (*Game) Start

func (g *Game) Start(player2 *connection.Conn)

Start will start the game

type GameListMessage

type GameListMessage struct {
	MessageType uint8
	NumGames    uint16
	GameList    []byte
}

GameListMessage is a structure representing a Game List message

func NewGameListMessage

func NewGameListMessage(allgames map[string]*Game) GameListMessage

NewGameListMessage returns an instance of GameListMessage based on params

func (*GameListMessage) Bytes

func (ms *GameListMessage) Bytes() []byte

Bytes returns a slice of bytes representing a GameListMessage which can be sent through a connection

Jump to

Keyboard shortcuts

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