component

package
v0.0.0-...-6796979 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

Error is the encapsulation of an error message sent by the API.

type Leaderboard

type Leaderboard struct {
	NetWorth     []UserRank `yaml:"netWorth"`
	UserNetWorth UserRank   `yaml:"userNetWorth"`
}

Leaderboard is the response from the API.

type Ship

type Ship struct {
	// Cargo []ShipCargo `yaml:"cargo"`
	Class          string `yaml:"class"`
	FlightPlanId   string `yaml:"flightPlanId"`
	Id             string `yaml:"id"`
	Location       string `yaml:"location"`
	Manufacturer   string `yaml:"manufacturer"`
	MaxCargo       int    `yaml:"maxCargo"`
	Plating        int    `yaml:"plating"`
	SpaceAvailable int    `yaml:"spaceAvailable"`
	Speed          int    `yaml:"speed"`
	Type           string `yaml:"type"`
	Weapons        int    `yaml:"weapons"`
	X              int    `yaml:"x"`
	Y              int    `yaml:"y"`
}

Ship is the response from the API about ships.

type ShipList

type ShipList struct {
	Ships []Ship `yaml:"ships"`
}

ShipList is the list of ships returned by the game.

type User

type User struct {
	Details UserDetails `yaml:"user"`
	Error   Error       `yaml:"error"`
	// contains filtered or unexported fields
}

User contains the essential information to authenticate in the game, but also to map the response from user details.

func NewUser

func NewUser(ctx context.Context, tracer trace.Tracer, token string) (*User, error)

NewUser creates a new instance of component.User.

func NewUserCustomProxy

func NewUserCustomProxy(ctx context.Context, tracer trace.Tracer, proxy web.Proxy, token string) (*User, error)

NewUserCustomProxy creates a new instance of component.User, using a provided custom web.WebProxy.

func (*User) GetDetails

func (u *User) GetDetails(ctx context.Context) error

GetDetails will get the user details from the game.

func (*User) GetLeaderboard

func (u *User) GetLeaderboard(ctx context.Context) (*Leaderboard, error)

GetLeaderboard will get the leaderboard and the user rank.

func (*User) GetShips

func (u *User) GetShips(ctx context.Context) (*ShipList, error)

GetShips will get information about all ships the user owns.

func (*User) GetStatus

func (u *User) GetStatus(ctx context.Context) (int, error)

GetStatus will get the game status (i.e., if it is running and available).

type UserDetails

type UserDetails struct {
	Credits        int64  `yaml:"credits"`
	JoinedAt       string `yaml:"joinedAt"`
	ShipCount      int64  `yaml:"shipCount"`
	StructureCount int64  `yaml:"structureCount"`
	Username       string `yaml:"username"`
}

UserDetails is the response from the User Detail API.

type UserRank

type UserRank struct {
	Username string `yaml:"username"`
	NetWorth int64  `yaml:"netWorth"`
	Rank     int64  `yaml:"rank"`
}

UserRank is detail about a user in the leaderboard response from the API.

Jump to

Keyboard shortcuts

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