r2d2

package module
v0.0.0-...-77f7e77 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

README

Cover Image

🚀 Space Trader API 🛠️ [WIP]

Build Status codecov Go Report Card

Space Traders is an API game where players explore the stars in order to exploit for it's riches.

More info available here.

This project provides a golang wrapper for the api.

🛠️ Work In Progress

Notice this package is in it's alpha stage and is subject to api changes.

🔧 Documentation

💾 Models

Most of the objects have been modelled and can be accessed through the model package.

The methods in this wrapper return the relevant model.

📔 Examples

💻 Contribution

This project is open to contributions.

To contribute follow the standard go style as much as possible and try to achieve an 80% code coverage or higher, with unit tests for the code submitted / changed.

Contributors will be acknowledge in this readme.

❤️ Contributors

  • HOWZ1T - Project Author & Maintainer
  • Trescenzi - Added Functionality & Fixed Documentation Typo
  • njfox - Various fixes & tweaks

⚖️ License

This project is licensed under GNU General Public License v3.0.

📝 TODO

  • More Examples
    • Quick Start
  • Continuous Integration
  • Unit Tests (Reach at least 80% coverage)
  • Documentation
  • Event System
  • Events:
    • Low Fuel
    • Out Of Fuel
    • Low Cargo Space
    • Cargo Full
    • Low Credits
    • Out Of Credits
    • Loan Due

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

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

func (st *SpaceTrader) BuyGood(shipID string, good string, quantity int) (models.ShipOrder, error)

Buys the specified good at the specified quantity for the specified ship. Returns ShipOrder

func (*SpaceTrader) BuyShip

func (st *SpaceTrader) BuyShip(location string, shipType string) (models.Account, error)

Buys the specified ship. Returns the updated Account info.

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) Distance

func (st *SpaceTrader) Distance(a models.Location, b models.Location) float64

Calculates the distance between two locations.

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) MyLoans

func (st *SpaceTrader) MyLoans() ([]models.Loan, error)

Retrieves the user's loans.

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) SearchSystem

func (st *SpaceTrader) SearchSystem(system string, type_ string) ([]models.Location, error)

Searches the system for the given type. Returns an array of locations.

func (*SpaceTrader) SellGood

func (st *SpaceTrader) SellGood(shipID string, good string, quantity int) (models.ShipOrder, error)

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.

func (*SpaceTrader) TakeLoan

func (st *SpaceTrader) TakeLoan(loanType string) (models.Account, error)

Takes (purchases) a loan. Returns the updated Account info.

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.

Jump to

Keyboard shortcuts

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