Documentation ¶
Overview ¶
Client package provides connection to space tyckiting server
Index ¶
- func Run(ai Ai, name string) (err error)
- type Action
- type ActionsMessage
- type Ai
- type Bot
- type BotActionType
- type Client
- type ClientMessageType
- type ConnectedMessage
- type EndMessage
- type Event
- type EventType
- type EventsMessage
- type GameConfig
- type JoinMessage
- type Position
- type ServerMessage
- type ServerMessageType
- type StartMessage
- type Team
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action struct { Type BotActionType `json:"type"` BotId int `json:"botId"` Position Position `json:"pos"` }
type ActionsMessage ¶
type ActionsMessage struct { Type ClientMessageType `json:"type"` RoundId int `json:"roundId"` Actions []Action `json:"actions"` }
type Ai ¶
type Ai interface { Move() []Action OnStart(msg StartMessage) OnConnected(msg ConnectedMessage) OnEvents(msg EventsMessage) OnEnd(msg EndMessage) OnError(msg string) }
Ai is an interface that custom ai has to implement
type Bot ¶
type Bot struct { BotId int `json:"botId"` Name string `json:"name"` TeamId int `json:"teamId"` Hp int `json:"hp"` Alive bool `json:"alive"` Position Position `json:"pos"` }
func (*Bot) GetValidCannons ¶
Get valid positios where bot can use cannon
func (*Bot) GetValidMoves ¶
Get valid positios where bot can move
func (*Bot) GetValidRadars ¶
Get valid positios where bot can use rader
type BotActionType ¶
type BotActionType string
const ( BOT_MOVE BotActionType = "move" BOT_RADAR BotActionType = "radar" BOT_CANNON BotActionType = "cannon" )
type ClientMessageType ¶
type ClientMessageType string
const ( CLIENT_JOIN ClientMessageType = "join" CLIENT_ACTIONS ClientMessageType = "actions" )
type ConnectedMessage ¶
type ConnectedMessage struct { TeamId int `json:"teamId"` Config GameConfig `json:"config"` }
type EndMessage ¶
type EventType ¶
type EventType string
const ( EVENT_HIT EventType = "hit" EVENT_DIE EventType = "die" EVENT_RADAR_ECHO EventType = "radarEcho" EVENT_SEE EventType = "see" EVENT_DETECTED EventType = "detected" EVENT_DAMAGED EventType = "damaged" EVENT_MOVE EventType = "move" EVENT_NOACTION EventType = "noaction" EVENT_END EventType = "end" )
type EventsMessage ¶
type EventsMessage struct { RoundId int `json:"roundId"` You Team `json:"you"` Config GameConfig `json:"config"` OtherTeams []Team `json:"otherTeams"` Events []Event `json:"events"` }
type GameConfig ¶
type GameConfig struct { Bots int `json:"bots"` FieldRadius int `json:"fieldRadius"` Move int `json:"move"` StartHp int `json:"startHp"` Cannon int `json:"cannon"` Radar int `json:"radar"` See int `json:"see"` MaxCount int `json:"maxCount"` Asteroids int `json:"asteroids"` LoopTime int `json:"loopTime"` NoWait bool `json:"noWait"` }
type JoinMessage ¶
type JoinMessage struct { Type ClientMessageType `json:"type"` TeamName string `json:"teamName"` }
type ServerMessage ¶
type ServerMessage struct {
Type ServerMessageType `json:"type"`
}
type ServerMessageType ¶
type ServerMessageType string
const ( SERVER_CONNECTED ServerMessageType = "connected" SERVER_START ServerMessageType = "start" SERVER_END ServerMessageType = "end" SERVER_EVENTS ServerMessageType = "events" SERVER_ERROR ServerMessageType = "error" )
type StartMessage ¶
type StartMessage struct { You Team `json:"you"` Config GameConfig `json:"config"` OtherTeams []Team `json:"otherTeams"` }
Click to show internal directories.
Click to hide internal directories.