Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoardServer ¶
type BoardServer struct {
// contains filtered or unexported fields
}
A minimal server capable of handling the requests from a single browser client running the board viewer.
func NewBoardServer ¶
func NewBoardServer(game Game) *BoardServer
func (*BoardServer) Listen ¶
func (server *BoardServer) Listen() (string, error)
func (*BoardServer) SendEvent ¶
func (server *BoardServer) SendEvent(event GameEvent)
func (*BoardServer) Shutdown ¶
func (server *BoardServer) Shutdown()
type Game ¶
type Game struct {
ID string `json:"ID"`
Status string `json:"Status"`
Width int `json:"Width"`
Height int `json:"Height"`
Ruleset map[string]string `json:"Ruleset"`
SnakeTimeout int `json:"SnakeTimeout"`
Source string `json:"Source"`
RulesetName string `json:"RulesetName"`
RulesStages []string `json:"RulesStages"`
Map string `json:"Map"`
}
JSON structure returned by the game status endpoint.
type GameEvent ¶
type GameEvent struct {
EventType GameEventType `json:"Type"`
Data interface{} `json:"Data"`
}
Top-level JSON structure sent in each websocket frame.
type GameEventType ¶
type GameEventType string
The websocket stream has support for returning different types of events, along with a "type" attribute.
const ( EVENT_TYPE_FRAME GameEventType = "frame" EVENT_TYPE_GAME_END GameEventType = "game_end" )
type GameFrame ¶
type GameFrame struct {
Turn int `json:"Turn"`
Snakes []Snake `json:"Snakes"`
Food []rules.Point `json:"Food"`
Hazards []rules.Point `json:"Hazards"`
}
Represents a single turn in the game.
type Snake ¶
type Snake struct {
ID string `json:"ID"`
Name string `json:"Name"`
Body []rules.Point `json:"Body"`
Health int `json:"Health"`
Death *Death `json:"Death"`
Color string `json:"Color"`
HeadType string `json:"HeadType"`
TailType string `json:"TailType"`
Latency string `json:"Latency"`
Shout string `json:"Shout"`
Squad string `json:"Squad"`
Author string `json:"Author"`
StatusCode int `json:"StatusCode"`
Error string `json:"Error"`
IsBot bool `json:"IsBot"`
IsEnvironment bool `json:"IsEnvironment"`
}
Click to show internal directories.
Click to hide internal directories.