client/botserv.go

132 lines
4.0 KiB
Go

package main
import (
"bitbucket.org/hackerbots/vector"
)
type ClientConfig struct {
ID string `json:"id"`
Stats map[string]StatsRequest `json:"stats"`
}
type BoardSize struct {
Width float32 `json:"width"`
Height float32 `json:"height"`
}
type GameParam struct {
BoardSize BoardSize `json:"boardsize"`
name string
Type string `json:"type"`
}
type StatsRequest struct {
Hp int `json:"hp"`
Speed int `json:"speed"`
Acceleration int `json:"acceleration"`
WeaponRadius int `json:"weapon_radius"`
ScannerRadius int `json:"scanner_radius"`
TurnSpeed int `json:"turn_speed"`
FireRate int `json:"fire_rate"`
WeaponDamage int `json:"weapon_damage"`
WeaponSpeed int `json:"weapon_speed"`
}
type Scanner struct {
Position govector.Point2d `json:"position"`
Stats StatsRequest `json:"stats"`
}
type Robot struct {
Id string `json:"id"`
Name string `json:"name"`
Message string `json:"-"`
Stats Stats `json:"-"`
TargetSpeed float32 `json:"-"`
Speed float32 `json:"speed"`
Health int `json:"health"`
RepairCounter float32 `json:"repair"`
ScanCounter float32 `json:"scan_bonus"`
ActiveScan bool `json:"-"`
Position govector.Point2d `json:"position"`
Heading govector.Vector2d `json:"heading"`
MoveTo *govector.Point2d `json:"-"`
FireAt *govector.Point2d `json:"-"`
Scanners []Scanner `json:"scanners"`
LastFired int `json:"-"`
Collision bool `json:"collision"`
Hit bool `json:"hit"`
Probe *govector.Point2d `json:"probe"`
ProbeResult *govector.Point2d `json:"probe_result"`
}
type Stats struct {
Hp int `json:"-"`
Speed float32 `json:"-"`
Acceleration float32 `json:"-"`
WeaponRadius int `json:"-"`
ScannerRadius int `json:"-"`
TurnSpeed int `json:"-"`
FireRate int `json:"-"`
WeaponDamage int `json:"-"`
WeaponSpeed float32 `json:"-"`
}
type Projectile struct {
Id string `json:"id"`
Position govector.Point2d `json:"position"`
MoveTo govector.Point2d `json:"move_to"`
Radius int `json:"radius"`
Speed float32 `json:"speed"`
Damage int `json:"damage"`
}
type Splosion struct {
Id string `json:"id"`
Position govector.Point2d `json:"position"`
Radius int `json:"radius"`
MaxDamage int `json:"damage"`
MinDamage int `json:"damage"`
Lifespan int `json:"lifespan"`
}
type Instruction struct {
Message *string `json:"message,omitempty"`
MoveTo *govector.Point2d `json:"move_to,omitempty"`
FireAt *govector.Point2d `json:"fire_at,omitempty"`
Probe *govector.Point2d `json:"probe,omitempty"`
TargetSpeed *float32 `json:"target_speed,omitempty"`
Repair *bool `json:"repair,omitempty"`
Scan *bool `json:"scan,omitempty"`
}
type Boardstate struct {
MyRobots []Robot `json:"my_robots"`
OtherRobots []OtherRobot `json:"robots"`
Projectiles []Projectile `json:"projectiles"`
Splosions []Splosion `json:"splosions"`
Obstacles []Obstacle `json:"obj"`
Reset bool `json:"reset"`
Type string `json:"type"`
Turn int `json:"turn"`
AllBots []BotHealth `json:"all_bots"`
Messages []string `json:"messages"`
}
type OtherRobot struct {
Id string `json:"id"`
Name string `json:"name"`
Position govector.Point2d `json:"position"`
Heading govector.Vector2d `json:"heading"`
Health int `json:"health"`
}
type Obstacle struct {
Bounds govector.Rect2d `json:"bounds"`
}
type BotHealth struct {
RobotId string `json:"robot_id"`
Health int `json:"health"`
}