client

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: AGPL-3.0 Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Board

type Board struct {
	Height  int     `json:"height"`
	Width   int     `json:"width"`
	Snakes  []Snake `json:"snakes"`
	Food    []Coord `json:"food"`
	Hazards []Coord `json:"hazards"`
}

Board provides information about the game board

type Coord

type Coord struct {
	X int `json:"x"`
	Y int `json:"y"`
}

Coord represents a point on the board

func CoordFromPoint

func CoordFromPoint(pt rules.Point) Coord

func CoordFromPointArray

func CoordFromPointArray(ptArray []rules.Point) []Coord

type Customizations

type Customizations struct {
	Color string `json:"color"`
	Head  string `json:"head"`
	Tail  string `json:"tail"`
}

type Game

type Game struct {
	ID      string  `json:"id"`
	Ruleset Ruleset `json:"ruleset"`
	Map     string  `json:"map"`
	Timeout int     `json:"timeout"`
	Source  string  `json:"source"`
}

Game represents the current game state

type MoveResponse

type MoveResponse struct {
	Move  string `json:"move"`
	Shout string `json:"shout"`
}

The expected format of the response body from a /move request

type RoyaleSettings

type RoyaleSettings struct {
	ShrinkEveryNTurns int `json:"shrinkEveryNTurns"`
}

RoyaleSettings contains settings that are specific to the "royale" game mode

type Ruleset

type Ruleset struct {
	Name     string          `json:"name"`
	Version  string          `json:"version"`
	Settings RulesetSettings `json:"settings"`
}

type RulesetSettings

type RulesetSettings struct {
	FoodSpawnChance     int            `json:"foodSpawnChance"`
	MinimumFood         int            `json:"minimumFood"`
	HazardDamagePerTurn int            `json:"hazardDamagePerTurn"`
	HazardMap           string         `json:"hazardMap"`       // Deprecated, replaced by Game.Map
	HazardMapAuthor     string         `json:"hazardMapAuthor"` // Deprecated, no planned replacement
	RoyaleSettings      RoyaleSettings `json:"royale"`
	SquadSettings       SquadSettings  `json:"squad"` // Deprecated, provided with default fields for API compatibility
}

RulesetSettings contains a static collection of a few settings that are exposed through the API.

func ConvertRulesetSettings added in v1.2.0

func ConvertRulesetSettings(settings rules.Settings) RulesetSettings

Converts a rules.Settings (which can contain arbitrary settings) into the static RulesetSettings used in the client API.

type Snake

type Snake struct {
	ID             string         `json:"id"`
	Name           string         `json:"name"`
	Latency        string         `json:"latency"`
	Health         int            `json:"health"`
	Body           []Coord        `json:"body"`
	Head           Coord          `json:"head"`
	Length         int            `json:"length"`
	Shout          string         `json:"shout"`
	Squad          string         `json:"squad"`
	Customizations Customizations `json:"customizations"`
}

Snake represents information about a snake in the game

type SnakeMetadataResponse

type SnakeMetadataResponse struct {
	APIVersion string `json:"apiversion,omitempty"`
	Author     string `json:"author,omitempty"`
	Color      string `json:"color,omitempty"`
	Head       string `json:"head,omitempty"`
	Tail       string `json:"tail,omitempty"`
	Version    string `json:"version,omitempty"`
}

The expected format of the response body from a GET request to a Battlesnake's index URL

type SnakeRequest

type SnakeRequest struct {
	Game  Game  `json:"game"`
	Turn  int   `json:"turn"`
	Board Board `json:"board"`
	You   Snake `json:"you"`
}

The top-level message sent in /start, /move, and /end requests

type SquadSettings

type SquadSettings struct {
	AllowBodyCollisions bool `json:"allowBodyCollisions"`
	SharedElimination   bool `json:"sharedElimination"`
	SharedHealth        bool `json:"sharedHealth"`
	SharedLength        bool `json:"sharedLength"`
}

SquadSettings contains settings that are specific to the "squad" game mode

Jump to

Keyboard shortcuts

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