screepsapi

package module
v0.0.0-...-ed1cdfe Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2017 License: MIT Imports: 11 Imported by: 0

README

screepsapi

Golang client for https://screeps.com/ API

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultHTTPTimeout = 10 * time.Second
)

Functions

This section is empty.

Types

type APIClient

type APIClient interface {
	// Auth
	Me(shard string) (MeResponse, error)
	SignIn(email, password string) error

	// Code
	Branches() (BranchesResponse, error)
	Console(shard, expression string) (InsertResponse, error)
	PullCode(branch string) (PullCodeResponse, error)
	PushCode(branch string, modules map[string]string) (PushCodeResponse, error)
	SetActiveBranch(branch string, activeName screepstype.ActiveName) (Response, error)

	// Game
	AddObjectIntent(addObjectIntentReq AddObjectIntentRequest) (UpsertResponse, error)
	CheckUniqueObjectName(shard, name string, uniqueObjectNameType screepstype.UniqueObjectName) (Response, error)
	CreateConstruction(createConstructionReq CreateConstructionRequest) (UpsertResponse, error)
	CreateFlag(createFlagReq CreateFlagRequest) (UpsertResponse, error)
	DestroyStructure(shard, room, user string, ids []string) (UpsertResponse, error)
	GenUniqueObjectName(shard string, uniqueObjectNameType screepstype.UniqueObjectName) (GenUniqueObjectNameResponse, error)
	PlaceSpawn(placeSpawnReq PlaceSpawnRequest) (PlaceSpawnResponse, error)
	RemoveFlag(shard, room, name string) (UpsertResponse, error)
	RemoveObject(shard, room, id string) (UpsertResponse, error)
	Respawn() (RespawnResponse, error)
	RespawnProhibitedRooms() (RespawnProhibitedRoomsResponse, error)
	SuicideCreep(shard, room, id string) (UpsertResponse, error)
	Time(shard string) (TimeResponse, error)
	UnclaimController(shard, room, id string) (UpsertResponse, error)

	// Leaderboard
	LeaderboardFind(mode, username, season string) (LeaderboardFindResponse, error)
	LeaderboardList(mode, season string, limit, offset int) (LeaderboardListResponse, error)
	LeaderboardSeasons() (LeaderboardSeasonsResponse, error)

	// Map
	MapStats(shard string, rooms []string, statName screepstype.StatName, statsPeriod screepstype.StatsPeriod) (MapStatsResponse, error)

	// Market
	MoneyHistory() (MoneyHistoryResponse, error)
	Orders(shard, resourceType string) (OrdersResponse, error)
	OrdersIndex(shard string) (OrdersIndexResponse, error)
	MyOrders() (OrdersResponse, error)

	// Memory
	Memory(shard, path string) (MemoryResponse, error)
	UpdateMemory(shard, path, value string) (InsertResponse, error)
	DeleteMemory(shard, path string) (InsertResponse, error)

	// Messages
	MessagesIndex() (MessagesIndexResponse, error)
	MessagesList(respondent string) (MessagesListResponse, error)
	MessagesSend(respondent, text string) (Response, error)
	MessagesUnreadCount() (MessagesUnreadCountResponse, error)

	// Room
	RoomOverview(shard, room string, statsPeriod screepstype.StatsPeriod) (RoomOverviewResponse, error)
	RoomStatus(shard, room string) (RoomStatusResponse, error)
	RoomTerrain(shard, room string, encoded bool) (RoomTerrainResponse, error)

	// User
	UserFind(id, username string) (UserFindResponse, error)
	UserOverview(statName screepstype.StatName, statsPeriod screepstype.StatsPeriod) (UserOverviewResponse, error)
	UserRooms(id string) (UserRoomsResponse, error)
	UserStats(id string, statsPeriod screepstype.StatsPeriod) (UserStatsResponse, error)

	// Version
	Version() (VersionResponse, error)

	// World
	WorldStartRoom() (WorldStartRoomResponse, error)
	WorldStatus() (WorldStatusResponse, error)

	// Xsolla
	XsollaUser(shard string) (XsollaUserResponse, error)
}

type APIResponse

type APIResponse interface {
	IsOk() bool
}

type AddObjectIntentRequest

type AddObjectIntentRequest struct {
	Shard  string                   `json:"shard"`
	Room   string                   `json:"room"`
	ID     string                   `json:"_id"`
	Name   screepstype.ObjectIntent `json:"name"`
	Intent interface{}              `json:"intent"`
}

type BranchesResponse

type BranchesResponse struct {
	Response
	Branches []screepstype.Branch `json:"list"`
}

type CheckUniqueObjectNameRequest

type CheckUniqueObjectNameRequest struct {
	Shard string                       `json:"shard"`
	Type  screepstype.UniqueObjectName `json:"type"`
	Name  string                       `json:"name"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(credentials Credentials) (*Client, error)

func (*Client) AddObjectIntent

func (c *Client) AddObjectIntent(addObjectIntentReq AddObjectIntentRequest) (UpsertResponse, error)

func (*Client) Branches

func (c *Client) Branches() (BranchesResponse, error)

func (*Client) CheckUniqueObjectName

func (c *Client) CheckUniqueObjectName(shard, name string, uniqueObjectNameType screepstype.UniqueObjectName) (Response, error)

func (*Client) Console

func (c *Client) Console(shard, expression string) (InsertResponse, error)

func (*Client) CreateConstruction

func (c *Client) CreateConstruction(createConstructionReq CreateConstructionRequest) (UpsertResponse, error)

func (*Client) CreateFlag

func (c *Client) CreateFlag(createFlagReq CreateFlagRequest) (UpsertResponse, error)

func (*Client) DeleteMemory

func (c *Client) DeleteMemory(shard, path string) (InsertResponse, error)

func (*Client) DestroyStructure

func (c *Client) DestroyStructure(shard, room, user string, ids []string) (UpsertResponse, error)

func (*Client) GenUniqueObjectName

func (c *Client) GenUniqueObjectName(shard string, uniqueObjectNameType screepstype.UniqueObjectName) (GenUniqueObjectNameResponse, error)

func (*Client) LeaderboardFind

func (c *Client) LeaderboardFind(mode, username, season string) (LeaderboardFindResponse, error)

func (*Client) LeaderboardList

func (c *Client) LeaderboardList(mode, season string, limit, offset int) (LeaderboardListResponse, error)

func (*Client) LeaderboardSeasons

func (c *Client) LeaderboardSeasons() (LeaderboardSeasonsResponse, error)

func (*Client) MapStats

func (c *Client) MapStats(shard string, rooms []string, statName screepstype.StatName, statsPeriod screepstype.StatsPeriod) (MapStatsResponse, error)

func (*Client) Me

func (c *Client) Me(shard string) (MeResponse, error)

func (*Client) Memory

func (c *Client) Memory(shard, path string) (MemoryResponse, error)

func (*Client) MemorySegment

func (c *Client) MemorySegment(shard string, segment int) (MemorySegmentResponse, error)

func (*Client) MessagesIndex

func (c *Client) MessagesIndex() (MessagesIndexResponse, error)

func (*Client) MessagesList

func (c *Client) MessagesList(respondent string) (MessagesListResponse, error)

func (*Client) MessagesSend

func (c *Client) MessagesSend(respondent, text string) (Response, error)

func (*Client) MessagesUnreadCount

func (c *Client) MessagesUnreadCount() (MessagesUnreadCountResponse, error)

func (*Client) MoneyHistory

func (c *Client) MoneyHistory() (MoneyHistoryResponse, error)

func (*Client) MyOrders

func (c *Client) MyOrders() (OrdersResponse, error)

func (*Client) Orders

func (c *Client) Orders(shard, resourceType string) (OrdersResponse, error)

func (*Client) OrdersIndex

func (c *Client) OrdersIndex(shard string) (OrdersIndexResponse, error)

func (*Client) PlaceSpawn

func (c *Client) PlaceSpawn(placeSpawnReq PlaceSpawnRequest) (PlaceSpawnResponse, error)

func (*Client) PullCode

func (c *Client) PullCode(branch string) (PullCodeResponse, error)

func (*Client) PushCode

func (c *Client) PushCode(branch string, modules map[string]string) (PushCodeResponse, error)

func (*Client) RemoveFlag

func (c *Client) RemoveFlag(shard, room, name string) (UpsertResponse, error)

func (*Client) RemoveObject

func (c *Client) RemoveObject(shard, room, id string) (UpsertResponse, error)

func (*Client) Respawn

func (c *Client) Respawn() (RespawnResponse, error)

func (*Client) RespawnProhibitedRooms

func (c *Client) RespawnProhibitedRooms() (RespawnProhibitedRoomsResponse, error)

func (*Client) RoomOverview

func (c *Client) RoomOverview(shard, room string, statsPeriod screepstype.StatsPeriod) (RoomOverviewResponse, error)

func (*Client) RoomStatus

func (c *Client) RoomStatus(shard, room string) (RoomStatusResponse, error)

func (*Client) RoomTerrain

func (c *Client) RoomTerrain(shard, room string, encoded bool) (RoomTerrainResponse, error)

func (*Client) SetActiveBranch

func (c *Client) SetActiveBranch(branch string, activeName screepstype.ActiveName) (Response, error)

func (*Client) SignIn

func (c *Client) SignIn(email, password string) error

func (*Client) SuicideCreep

func (c *Client) SuicideCreep(shard, room, id string) (UpsertResponse, error)

func (*Client) Time

func (c *Client) Time(shard string) (TimeResponse, error)

func (*Client) Token

func (c *Client) Token() string

func (*Client) UnclaimController

func (c *Client) UnclaimController(shard, room, id string) (UpsertResponse, error)

func (*Client) UpdateMemory

func (c *Client) UpdateMemory(shard, path, value string) (InsertResponse, error)

func (*Client) UpdateMemorySegment

func (c *Client) UpdateMemorySegment(shard, data string, segment int) (Response, error)

func (*Client) UserFind

func (c *Client) UserFind(id, username string) (UserFindResponse, error)

func (*Client) UserOverview

func (c *Client) UserOverview(statName screepstype.StatName, statsPeriod screepstype.StatsPeriod) (UserOverviewResponse, error)

func (*Client) UserRooms

func (c *Client) UserRooms(id string) (UserRoomsResponse, error)

func (*Client) UserStats

func (c *Client) UserStats(id string, statsPeriod screepstype.StatsPeriod) (UserStatsResponse, error)

func (*Client) Version

func (c *Client) Version() (VersionResponse, error)

func (*Client) WorldStartRoom

func (c *Client) WorldStartRoom() (WorldStartRoomResponse, error)

func (*Client) WorldStatus

func (c *Client) WorldStatus() (WorldStatusResponse, error)

func (*Client) XsollaUser

func (c *Client) XsollaUser(shard string) (XsollaUserResponse, error)

type ConsoleRequest

type ConsoleRequest struct {
	Expression string `json:"expression"`
}

type CreateConstructionRequest

type CreateConstructionRequest struct {
	Shard     string                `json:"shard"`
	Room      string                `json:"room"`
	X         int                   `json:"x"`
	Y         int                   `json:"y"`
	Structure screepstype.Structure `json:"type"`
}

type CreateFlagRequest

type CreateFlagRequest struct {
	Shard          string            `json:"shard"`
	Room           string            `json:"room"`
	X              int               `json:"x"`
	Y              int               `json:"y"`
	Name           string            `json:"name"`
	Color          screepstype.Color `json:"color"`
	SecondaryColor screepstype.Color `json:"secondaryColor"`
}

type Credentials

type Credentials struct {
	Email     string `json:"email"`
	Password  string `json:"password"`
	ServerURL string `json:"serverURL"`
}

type DestroyStructureIntentRequest

type DestroyStructureIntentRequest struct {
	ID       string `json:"id"`
	RoomName string `json:"roomName"`
	User     string `json:"user"`
}

type GenUniqueObjectNameRequest

type GenUniqueObjectNameRequest struct {
	Shard string                       `json:"shard"`
	Type  screepstype.UniqueObjectName `json:"type"`
}

type GenUniqueObjectNameResponse

type GenUniqueObjectNameResponse struct {
	Response
	Name string `json:"name"`
}

type InsertResponse

type InsertResponse struct {
	Response
	Result        screepstype.InsertResult `json:"result"`
	Ops           []screepstype.InsertOps  `json:"ops"`
	InsertedCount int                      `json:"insertedCount"`
	InsertedIDs   []string                 `json:"insertedIDs"`
}

type LeaderboardFindResponse

type LeaderboardFindResponse struct {
	Response
	screepstype.LeaderboardPosition
	Positions []screepstype.LeaderboardPosition `json:"list"`
}

type LeaderboardListResponse

type LeaderboardListResponse struct {
	Response
	Positions []screepstype.LeaderboardPosition `json:"list"`
	Count     int                               `json:"count"`
	Users     map[string]screepstype.User       `json:"users"`
}

type LeaderboardSeasonsResponse

type LeaderboardSeasonsResponse struct {
	Response
	Seasons []screepstype.Season `json:"seasons"`
}

type MapStatsRequest

type MapStatsRequest struct {
	Shard    string               `json:"shard"`
	Rooms    []string             `json:"rooms"`
	StatName screepstype.StatName `json:"statName"`
}

type MapStatsResponse

type MapStatsResponse struct {
	Response
	GameTime int                                 `json:"gameTime"`
	Stats    map[string]screepstype.MapRoomStats `json:"stats"`
	Users    map[string]screepstype.User         `json:"users"`
}

type MeResponse

type MeResponse struct {
	Response
	ID                 string             `json:"_id"`
	Email              string             `json:"email"`
	Username           string             `json:"username"`
	CPU                int                `json:"cpu"`
	Badge              screepstype.Badge  `json:"badge"`
	Password           bool               `json:"password"`
	Credits            int                `json:"credits"`
	LastRespawnDate    int                `json:"lastRespawnDate"`
	PromoPeriodUntil   int                `json:"promoPeriodUntil"`
	Money              int                `json:"money"`
	SubscriptionTokens int                `json:"subscriptionTokens"`
	GitHub             screepstype.GitHub `json:"github"`
	Steam              screepstype.Steam  `json:"steam"`
}

type MemoryRequest

type MemoryRequest struct {
	Shard string  `json:"shard"`
	Path  string  `json:"path"`
	Value *string `json:"value,omitempty"`
}

type MemoryResponse

type MemoryResponse struct {
	Response
	Data interface{} `json:"data"`
}

func (*MemoryResponse) UnmarshalJSON

func (m *MemoryResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the data string, which is of the form `gz:` followed by base64-encoded gzipped JSON encoding of the requested memory path, into a more functional map[string]interface{}.

type MemorySegmentResponse

type MemorySegmentResponse struct {
	Response
	Data string `json:"data"`
}

type MessagesIndexResponse

type MessagesIndexResponse struct {
	Response
	Messages []screepstype.MessageWithRecipients `json:"messages"`
	Users    map[string]screepstype.User         `json:"users"`
}

type MessagesListResponse

type MessagesListResponse struct {
	Response
	Messages []screepstype.Message `json:"messages"`
}

type MessagesSendRequest

type MessagesSendRequest struct {
	Respondent string `json:"respondent"`
	Text       string `json:"text"`
}

type MessagesUnreadCountResponse

type MessagesUnreadCountResponse struct {
	Response
	Count int `json:"count"`
}

type MoneyHistoryResponse

type MoneyHistoryResponse struct {
	Response
	Page     int                        `json:"page"`
	HasMore  bool                       `json:"hasMore"`
	Messages []screepstype.MoneyMessage `json:"messages"`
}

type MyOrdersResponse

type MyOrdersResponse struct {
	Response
	Orders []screepstype.MarketOrder `json:"list"`
}

type OrdersIndexResponse

type OrdersIndexResponse struct {
	Response
	ResourceCounts []screepstype.ResourceCount `json:"list"`
}

type OrdersResponse

type OrdersResponse struct {
	Response
	Orders []screepstype.MarketOrder `json:"list"`
}

type PlaceSpawnRequest

type PlaceSpawnRequest struct {
	Shard string `json:"shard"`
	Room  string `json:"room"`
	X     int    `json:"x"`
	Y     int    `json:"y"`
	Name  string `json:"name"`
}

type PlaceSpawnResponse

type PlaceSpawnResponse struct {
	Response
	Newbie bool `json:"newbie"`
}

type PullCodeResponse

type PullCodeResponse struct {
	Response
	Branch  string            `json:"branch"`
	Modules map[string]string `json:"modules"`
}

type PushCodeRequest

type PushCodeRequest struct {
	Branch  string            `json:"branch,omitempty"`
	Modules map[string]string `json:"modules"`
}

type PushCodeResponse

type PushCodeResponse struct {
	Response
	Timestamp int `json:"timestamp"`
	Hash      int `json:"_hash"`
}

type RawMemoryResponse

type RawMemoryResponse struct {
	Response
	Data string `json:"data"`
}

type RemoveFlagRequest

type RemoveFlagRequest struct {
	Shard string `json:"shard"`
	Room  string `json:"room"`
	Name  string `json:"name"`
}

type RespawnProhibitedRoomsResponse

type RespawnProhibitedRoomsResponse struct {
	Response
	Rooms []string `json:"rooms"`
}

type RespawnResponse

type RespawnResponse struct {
	Response
	First  screepstype.Document `json:"0"`
	Second screepstype.Document `json:"1"`
}

type Response

type Response struct {
	Ok    int               `json:"ok"`
	Error screepstype.Error `json:"error"`
}

func (*Response) IsOk

func (r *Response) IsOk() bool

type RoomOverviewResponse

type RoomOverviewResponse struct {
	Response
	Owner screepstype.RoomOwner `json:"owner"`
	Stats screepstype.RoomStats `json:"stats"`
}

type RoomStatusResponse

type RoomStatusResponse struct {
	Response
	Room screepstype.Room `json:"room"`
}

type RoomTerrainResponse

type RoomTerrainResponse struct {
	Response
	Terrain []screepstype.RoomTerrain `json:"terrain"`
}

type SetActiveBranchRequest

type SetActiveBranchRequest struct {
	ActiveName screepstype.ActiveName `json:"activeName"`
	Branch     string                 `json:"branch"`
}

type SignInRequest

type SignInRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type SignInResponse

type SignInResponse struct {
	Response
	Token string `json:"token"`
}

type TimeResponse

type TimeResponse struct {
	Response
	Time int `json:"time"`
}

type UpdateMemoryRequest

type UpdateMemoryRequest struct {
	Shard   string `json:"shard"`
	Data    string `json:"data"`
	Segment int    `json:"segment"`
}

type UpsertResponse

type UpsertResponse struct {
	Response
	Result     screepstype.Document      `json:"result"`
	Connection screepstype.Connection    `json:"connection"`
	Message    screepstype.UpsertMessage `json:"message"`
}

type UserFindResponse

type UserFindResponse struct {
	Response
	User screepstype.User `json:"user"`
}

type UserOverviewResponse

type UserOverviewResponse struct {
	Response
	Shards map[string]screepstype.Shard   `json:"shards"`
	Totals screepstype.StatsWithIntervals `json:"totals"`
}

type UserRoomsResponse

type UserRoomsResponse struct {
	Response
	Shards map[string][]string `json:"shards"`
}

type UserStatsResponse

type UserStatsResponse struct {
	Response
	Stats screepstype.StatsWithIntervals `json:"stats"`
}

type VersionResponse

type VersionResponse struct {
	Response
	Package    int                    `json:"package"`
	Protocol   int                    `json:"protocol"`
	ServerData screepstype.ServerData `json:"serverData"`
}

type WorldStartRoomResponse

type WorldStartRoomResponse struct {
	Response
	Rooms []string `json:"room"`
}

type WorldStatusResponse

type WorldStatusResponse struct {
	Response
	Status screepstype.WorldStatus `json:"status"`
}

type XsollaUserResponse

type XsollaUserResponse struct {
	Response
	Active int `json:"active"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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