game

package
v0.0.0-...-427eadb Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: AGPL-3.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector interface {
	Start(*Server) error
}

Connector represent an entry point to all the connections to a server

type Parameters

type Parameters struct {
	GameID  string          `json:"gameId"`
	Players []PlayerProfile `json:"profiles"`
}

Parameters contains all the parameters of the game

func LoadGameParametersFromFile

func LoadGameParametersFromFile(filepath string) Parameters

LoadGameParametersFromFile load the parameters of a game from a local JSON file (TEST THIS?)

type Player

type Player struct {
	// contains filtered or unexported fields
}

Player : connected player's informations

func NewPlayer

func NewPlayer(profile PlayerProfile, conn PlayerConn) (player *Player)

NewPlayer returns a new player

func (*Player) Close

func (p *Player) Close() error

Close disconnect the player properly

func (*Player) Listen

func (p *Player) Listen(input chan world.PlayerInput, exit chan *Player) (err error)

Listen starts the loop of the player

func (*Player) Write

func (p *Player) Write(message []byte) (n int, err error)

Write

type PlayerConn

type PlayerConn interface {
	Receive() ([]byte, error)
	Send([]byte) error
	Close() error
}

PlayerConn represent an connection to a player

type PlayerProfile

type PlayerProfile struct {
	Name  string           `json:"username"`
	UUID  string           `json:"accessKey"`
	UID   uint8            `json:"uid"`
	Model world.PlaneModel `json:"planeModel"`
}

PlayerProfile ...

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server ...

func NewServer

func NewServer(params Parameters) *Server

NewServer return a arena with default settings (TEST THIS!)

func (*Server) Connect

func (s *Server) Connect(conn PlayerConn, profile PlayerProfile)

Connect add a player to the server

func (*Server) Run

func (s *Server) Run(world *world.World, connectors ...Connector)

Run start the server

func (*Server) Verify

func (s *Server) Verify(uuid string) (PlayerProfile, error)

Verify that a UUID is assiciated with a player. If it's the case, return this player's profil. Otherwise, an error is returned

Jump to

Keyboard shortcuts

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