Documentation

Index

Constants

View Source
const InvalidID uint64 = 0
View Source
const VersionString = "0.0.1"

Variables

This section is empty.

Functions

func DecodeRequest

func DecodeRequest(dec Decoder) (interface{}, int, error)

func DecodeResponse

func DecodeResponse(dec Decoder) (interface{}, int, error)

func EncodeRequest

func EncodeRequest(enc Encoder, obj interface{}, id int) error

func EncodeResponse

func EncodeResponse(enc Encoder, obj interface{}, id int) error

func Register

func Register(req, resp interface{})

func RegisterHandler

func RegisterHandler(reqName string, req interface{}, respName string, resp interface{})

Types

type Allegiance

type Allegiance uint8
const (
	Friendly Allegiance = iota
	Neutral
	Hostile
)

type Any

type Any map[interface{}]interface{}

type AttackUnitsRequest

type AttackUnitsRequest struct {
	Units []uint64 `json:"units"`
}

type AttackUnitsResponse

type AttackUnitsResponse Empty

type BuildRequest

type BuildRequest struct {
	Structure StructureType `json:"structure"`
	Material  ItemClass     `json:"material"`
	Location  Rect          `json:"location"`
}

type BuildResponse

type BuildResponse Empty

type BuildingType

type BuildingType uint8
const (
	NoBuilding BuildingType = iota
	StockpileBuilding
	SawmillBuilding
	ButcherShoppBuilding
	FarmBuilding
)

func (BuildingType) String

func (b BuildingType) String() string

type CloseRequest

type CloseRequest Empty

type CollectItemsRequest

type CollectItemsRequest struct {
	Items []Point `json:"items"`
}

type CollectItemsResponse

type CollectItemsResponse Empty

type CreateViewRequest

type CreateViewRequest struct {
	X int `json:"x"`
	Y int `json:"y"`
	W int `json:"w"`
	H int `json:"h"`
}

type CreateViewResponse

type CreateViewResponse struct {
	ViewID int `json:"view_id"`
}

type CutTreesRequest

type CutTreesRequest struct {
	Trees []Point `json:"trees"`
}

type CutTreesResponse

type CutTreesResponse Empty

type DebugCommandRequest

type DebugCommandRequest struct {
	Command string `json:"command"`
}

type DebugCommandResponse

type DebugCommandResponse struct {
	Error string `json:"error"`
}

type Decoder

type Decoder interface {
	Decode(interface{}) error
}

type DesignateRequest

type DesignateRequest struct {
	Building BuildingType `json:"building"`
	Location Rect         `json:"location"`
}

type DesignateResponse

type DesignateResponse struct {
	Error string `json:"error"`
}

type DestroyViewRequest

type DestroyViewRequest struct {
	ViewID int `json:"view_id"`
}

type DestroyViewResponse

type DestroyViewResponse Empty

type Empty

type Empty struct{}

type Encoder

type Encoder interface {
	Encode(interface{}) error
}

type ExploreLocationRequest

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

type ExploreLocationResponse

type ExploreLocationResponse Empty

type GameType

type GameType uint8
const (
	Civilisation GameType = iota
	Adventurer
	Observer
)

type GatherSeedsRequest

type GatherSeedsRequest struct {
	Seeds []Point `json:"seeds"`
}

type GatherSeedsResponse

type GatherSeedsResponse Empty
type Header struct {
	Type string `json:"type"`
	Id   int    `json:"id"`
}

type HighlightRequest

type HighlightRequest Empty

type HighlightResponse

type HighlightResponse struct {
	Highlight []Point `json:"highlight"`
}

type ItemClass

type ItemClass uint8
const (
	NoItem ItemClass = iota
	PartialItem
	LogItem
	FirewoodItem
	PlankItem
	StoneItem
	MeatItem
	BonesItem
	SeedsItem
	CropItem

	// Corpses
	HumanCorpseItem
	DwarfCorpseItem
	GoblinCorpseItem
	OrcCorpseItem
	TrollCorpseItem
	ElvenCorpseItem
	DeamonCorpseItem

	DearCorpseItem
	BoarCorpseItem
	WolfCorpseItem
)

func (ItemClass) String

func (c ItemClass) String() string

type ItemViewData

type ItemViewData struct {
	ID    uint64    `json:"item_id"`
	Class ItemClass `json:"class"`
}

type JobQueueRequest

type JobQueueRequest Empty

type JobQueueResponse

type JobQueueResponse struct {
	Jobs []string `json:"jobs"`
}

type MineLocationRequest

type MineLocationRequest struct {
	Location Point `json:"location"`
}

type MineLocationResponse

type MineLocationResponse struct {
	Error string `json:"error"`
}

type Point

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

type ReadViewBase

type ReadViewBase struct {
	Flags             TileFlag      `json:"flags"`
	UserFlags         UserFlag      `json:"usrflags"`
	Height            uint8         `json:"height"`
	BuildingType      BuildingType  `json:"building_type"`
	StructureType     StructureType `json:"structure_type"`
	StructureMaterial ItemClass     `json:"structure_material"`
	Building          uint64        `json:"building"`
}

type ReadViewData

type ReadViewData struct {
	ReadViewBase
	Units []UnitViewData `json:"units"`
	Items []ItemViewData `json:"items"`
	RLE   uint8          `json:"rle"`
}

type ReadViewRequest

type ReadViewRequest struct {
	ViewID int  `json:"view_id"`
	RLE    bool `json:"rle"`
}

type ReadViewResponse

type ReadViewResponse struct {
	W       uint16         `json:"w"`
	H       uint16         `json:"h"`
	RLESize uint32         `json:"rle_size"`
	Data    []ReadViewData `json:"data"`
}

func (*ReadViewResponse) MarshalBinary

func (rvr *ReadViewResponse) MarshalBinary() ([]byte, error)

func (*ReadViewResponse) UnmarshalBinary

func (rvr *ReadViewResponse) UnmarshalBinary(data []byte) error

func (*ReadViewResponse) UnmarshalJSON

func (rvr *ReadViewResponse) UnmarshalJSON(data []byte) error

type Rect

type Rect struct {
	Min Point `json:"min"`
	Max Point `json:"max"`
}

type SeedFarmRequest

type SeedFarmRequest struct {
	BuildingID uint64 `json:"building_id"`
}

type SeedFarmResponse

type SeedFarmResponse Empty

type StructureType

type StructureType uint8
const (
	NoStructure StructureType = iota
	WallStructure
)

func (StructureType) String

func (s StructureType) String() string

type TileFlag

type TileFlag uint8
const (
	Water TileFlag = 1 << iota
	Brook
	Sand
	Snow
	Tree
	Bush
	Plant
	Stone
)

func (TileFlag) Is

func (flags TileFlag) Is(f TileFlag) bool

type UnitClass

type UnitClass uint8
const (
	UnknownUnitClass UnitClass = iota
)

type UnitRace

type UnitRace uint8
const (
	Human UnitRace = iota
	Dwarf
	Goblin
	Orc
	Troll
	Elven
	Deamon

	// Wildlife
	Dear
	Boar
	Wolf
)

func (UnitRace) String

func (r UnitRace) String() string

type UnitStatsRequest

type UnitStatsRequest struct {
	UnitID int `json:"unit_id"`
}

type UnitStatsResponse

type UnitStatsResponse struct {
	Name   string   `json:"name"`
	Health float32  `json:"health"`
	Thirst float32  `json:"thirst"`
	Hunger float32  `json:"hunger"`
	Debug  []string `json:"debug"`
}

type UnitViewData

type UnitViewData struct {
	ID         uint64     `json:"unit_id"`
	Allegiance Allegiance `json:"allegiance"`
	Race       UnitRace   `json:"race"`
	Class      UnitClass  `json:"class"`
}

type UpdateViewRequest

type UpdateViewRequest struct {
	ViewID int `json:"view_id"`
	X      int `json:"x"`
	Y      int `json:"y"`
}

type UpdateViewResponse

type UpdateViewResponse Empty

type UserFlag

type UserFlag uint8
const (
	Territory UserFlag = 1 << iota
)

type ViewHomeRequest

type ViewHomeRequest struct {
	ViewID int `json:"view_id"`
}

type ViewHomeResponse

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

Source Files