fantasim-pub: github.com/andreas-jonsson/fantasim-pub/api Index | Files

package api

import "github.com/andreas-jonsson/fantasim-pub/api"

Index

Package Files

api.go readview.go

Constants

const InvalidID uint64 = 0
const VersionString = "0.0.1"

func DecodeRequest Uses

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

func DecodeResponse Uses

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

func EncodeRequest Uses

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

func EncodeResponse Uses

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

func Register Uses

func Register(req, resp interface{})

func RegisterHandler Uses

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

type Allegiance Uses

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

type Any Uses

type Any map[interface{}]interface{}

type AttackUnitsRequest Uses

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

type AttackUnitsResponse Uses

type AttackUnitsResponse Empty

type BuildRequest Uses

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

type BuildResponse Uses

type BuildResponse Empty

type BuildingType Uses

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

func (BuildingType) String Uses

func (b BuildingType) String() string

type CloseRequest Uses

type CloseRequest Empty

type CollectItemsRequest Uses

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

type CollectItemsResponse Uses

type CollectItemsResponse Empty

type CreateViewRequest Uses

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

type CreateViewResponse Uses

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

type CutTreesRequest Uses

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

type CutTreesResponse Uses

type CutTreesResponse Empty

type DebugCommandRequest Uses

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

type DebugCommandResponse Uses

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

type Decoder Uses

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

type DesignateRequest Uses

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

type DesignateResponse Uses

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

type DestroyViewRequest Uses

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

type DestroyViewResponse Uses

type DestroyViewResponse Empty

type Empty Uses

type Empty struct{}

type Encoder Uses

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

type ExploreLocationRequest Uses

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

type ExploreLocationResponse Uses

type ExploreLocationResponse Empty

type GameType Uses

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

type GatherSeedsRequest Uses

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

type GatherSeedsResponse Uses

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

type HighlightRequest Uses

type HighlightRequest Empty

type HighlightResponse Uses

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

type ItemClass Uses

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 Uses

func (c ItemClass) String() string

type ItemViewData Uses

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

type JobQueueRequest Uses

type JobQueueRequest Empty

type JobQueueResponse Uses

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

type MineLocationRequest Uses

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

type MineLocationResponse Uses

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

type Point Uses

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

type ReadViewBase Uses

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 Uses

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

type ReadViewRequest Uses

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

type ReadViewResponse Uses

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

func (*ReadViewResponse) MarshalBinary Uses

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

func (*ReadViewResponse) UnmarshalBinary Uses

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

func (*ReadViewResponse) UnmarshalJSON Uses

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

type Rect Uses

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

type SeedFarmRequest Uses

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

type SeedFarmResponse Uses

type SeedFarmResponse Empty

type StructureType Uses

type StructureType uint8
const (
    NoStructure StructureType = iota
    WallStructure
)

func (StructureType) String Uses

func (s StructureType) String() string

type TileFlag Uses

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

func (TileFlag) Is Uses

func (flags TileFlag) Is(f TileFlag) bool

type UnitClass Uses

type UnitClass uint8
const (
    UnknownUnitClass UnitClass = iota
)

type UnitRace Uses

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

    // Wildlife
    Dear
    Boar
    Wolf
)

func (UnitRace) String Uses

func (r UnitRace) String() string

type UnitStatsRequest Uses

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

type UnitStatsResponse Uses

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 Uses

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

type UpdateViewRequest Uses

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

type UpdateViewResponse Uses

type UpdateViewResponse Empty

type UserFlag Uses

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

type ViewHomeRequest Uses

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

type ViewHomeResponse Uses

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

Package api imports 6 packages (graph). Updated 2018-04-29. Refresh now. Tools for package owners.