Documentation
ΒΆ
Overview ΒΆ
Space Traders is an API game where players explore the stars in order to exploit for it's riches.
More info available here: https://spacetraders.io/
This project provides a golang wrapper for the api.
Index ΒΆ
- type BaseURL
- type SpaceTrader
- func (st *SpaceTrader) Account() (models.Account, error)
- func (st *SpaceTrader) ApiStatus() (string, error)
- func (st *SpaceTrader) AvailableLoans() ([]models.Loan, error)
- func (st *SpaceTrader) AvailableShips(class string) ([]models.Ship, error)
- func (st *SpaceTrader) BuyGood(shipID string, good string, quantity int) (models.ShipOrder, error)
- func (st *SpaceTrader) BuyShip(location string, shipType string) (models.Account, error)
- func (st *SpaceTrader) CreateFlightPlan(shipID string, destination string) (models.FlightPlan, error)
- func (st *SpaceTrader) Distance(a models.Location, b models.Location) float64
- func (st *SpaceTrader) EventsChannel() chan events.Event
- func (st *SpaceTrader) GetAllFlightPlansWithinSystem(symbol string) ([]models.CommonFlightPlan, error)
- func (st *SpaceTrader) GetFlightPlan(flightPlanID string) (models.FlightPlan, error)
- func (st *SpaceTrader) GetLocation(symbol string) (models.Location, error)
- func (st *SpaceTrader) GetLocationsInSystem(symbol string) ([]models.Location, error)
- func (st *SpaceTrader) GetMarket(symbol string) (models.Market, error)
- func (st *SpaceTrader) GetSystems() ([]models.System, error)
- func (st *SpaceTrader) LastDate() (string, error)
- func (st *SpaceTrader) MyLoans() ([]models.Loan, error)
- func (st *SpaceTrader) NextReset() (string, error)
- func (st *SpaceTrader) PayLoan(loanID string) (models.Account, error)
- func (st *SpaceTrader) RegisterUser(username string) (string, error)
- func (st *SpaceTrader) ResetFreq() (string, error)
- func (st *SpaceTrader) SearchSystem(system string, type_ string) ([]models.Location, error)
- func (st *SpaceTrader) SellGood(shipID string, good string, quantity int) (models.ShipOrder, error)
- func (st *SpaceTrader) SwitchUser(token string, username string)
- func (st *SpaceTrader) TakeLoan(loanType string) (models.Account, error)
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
This section is empty.
Types ΒΆ
type SpaceTrader ΒΆ
type SpaceTrader struct {
// contains filtered or unexported fields
}
SpaceTrader is a struct representing the API wrapper and provides functionality for consuming the API.
func New ΒΆ
func New(token string, username string) *SpaceTrader
Creates a new SpaceTrader instance.
func (*SpaceTrader) Account ΒΆ
func (st *SpaceTrader) Account() (models.Account, error)
Retrieves the user's account info.
func (*SpaceTrader) ApiStatus ΒΆ
func (st *SpaceTrader) ApiStatus() (string, error)
Retrieves the status of the API
func (*SpaceTrader) AvailableLoans ΒΆ
func (st *SpaceTrader) AvailableLoans() ([]models.Loan, error)
Retrieves the available loans.
func (*SpaceTrader) AvailableShips ΒΆ
func (st *SpaceTrader) AvailableShips(class string) ([]models.Ship, error)
Retrieves the available ships.
Ships can be filtered by specifying class.
If the class is specified as "" (empty) then no filter is applied.
func (*SpaceTrader) BuyGood ΒΆ
Buys the specified good at the specified quantity for the specified ship. Returns ShipOrder
func (*SpaceTrader) CreateFlightPlan ΒΆ
func (st *SpaceTrader) CreateFlightPlan(shipID string, destination string) (models.FlightPlan, error)
Creates a flight plan for the ship to the destination. Remember to calculate your estimated fuel usage!
Returns FlightPlan
func (*SpaceTrader) EventsChannel ΒΆ
func (st *SpaceTrader) EventsChannel() chan events.Event
func (*SpaceTrader) GetAllFlightPlansWithinSystem ΒΆ
func (st *SpaceTrader) GetAllFlightPlansWithinSystem(symbol string) ([]models.CommonFlightPlan, error)
Retrieves all flight plans within a system Note you must have an active ship in that system
func (*SpaceTrader) GetFlightPlan ΒΆ
func (st *SpaceTrader) GetFlightPlan(flightPlanID string) (models.FlightPlan, error)
Retrieves a FlightPlan by the given ID.
func (*SpaceTrader) GetLocation ΒΆ
func (st *SpaceTrader) GetLocation(symbol string) (models.Location, error)
Get info for the specified location. Location is specified by it's symbol.
func (*SpaceTrader) GetLocationsInSystem ΒΆ
func (st *SpaceTrader) GetLocationsInSystem(symbol string) ([]models.Location, error)
Get all locations in the specified system. System is specified by it's symbol.
func (*SpaceTrader) GetMarket ΒΆ
func (st *SpaceTrader) GetMarket(symbol string) (models.Market, error)
Gets the location's marketplace info. Location is specified by it's symbol.
func (*SpaceTrader) GetSystems ΒΆ
func (st *SpaceTrader) GetSystems() ([]models.System, error)
Gets all the systems info.
func (*SpaceTrader) LastDate ΒΆ
func (st *SpaceTrader) LastDate() (string, error)
func (*SpaceTrader) MyLoans ΒΆ
func (st *SpaceTrader) MyLoans() ([]models.Loan, error)
Retrieves the user's loans.
func (*SpaceTrader) NextReset ΒΆ
func (st *SpaceTrader) NextReset() (string, error)
func (*SpaceTrader) PayLoan ΒΆ
func (st *SpaceTrader) PayLoan(loanID string) (models.Account, error)
Pays the specified loan. Returns the updated Account info.
func (*SpaceTrader) RegisterUser ΒΆ
func (st *SpaceTrader) RegisterUser(username string) (string, error)
Registers a new user and returns the new user's token.
func (*SpaceTrader) ResetFreq ΒΆ
func (st *SpaceTrader) ResetFreq() (string, error)
func (*SpaceTrader) SearchSystem ΒΆ
Searches the system for the given type. Returns an array of locations.
func (*SpaceTrader) SellGood ΒΆ
Sells the specified good at the specified quantity for the specified ship. Returns ShipOrder
func (*SpaceTrader) SwitchUser ΒΆ
func (st *SpaceTrader) SwitchUser(token string, username string)
Changes this instance of SpaceTrader to be the specified user.
Source Files
ΒΆ
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
Assert provides useful utilities for writing unit tests.
|
Assert provides useful utilities for writing unit tests. |
|
Provides a caching mechanism to reduce the amount of API calls.
|
Provides a caching mechanism to reduce the amount of API calls. |
|
Provides implementation of errors for this project.
|
Provides implementation of errors for this project. |
|
Simple Event System
|
Simple Event System |
|
This package provides marshal-able models for all data objects in the API.
|
This package provides marshal-able models for all data objects in the API. |