Documentation ¶
Index ¶
- Constants
- type Error
- type FlightPlan
- type FlightPlanDetails
- type Marketplace
- type Product
- type Route
- type RouteStop
- type Ship
- func (s *Ship) Buy(ctx context.Context, good string, quantity int) (*Trade, error)
- func (s *Ship) BuyAll(ctx context.Context, buy map[string]int, marketplace map[string]Product) error
- func (s *Ship) DoCommerce(ctx context.Context, sell, buy map[string]int) error
- func (s *Ship) Fly(ctx context.Context, destination string) error
- func (s *Ship) ForceBuyFuel(ctx context.Context, fuel int) error
- func (s *Ship) GetDetails(ctx context.Context) error
- func (s *Ship) GetFlightPlan(ctx context.Context) (*FlightPlan, error)
- func (s *Ship) GetMarketplaceProducts(ctx context.Context) (*Marketplace, *map[string]Product, error)
- func (s *Ship) NewFlightPlan(ctx context.Context, destination string) (*FlightPlan, error)
- func (s *Ship) Sell(ctx context.Context, good string, quantity int) (*Trade, error)
- func (s *Ship) SellAll(ctx context.Context, sell map[string]int, marketplace map[string]Product) error
- type ShipCargo
- type ShipDetails
- type Trade
- type TradeOrder
Constants ¶
const (
InsufficientFuelRegex = "Ship has insufficient fuel for flight plan. You require ([0-9]+) more FUEL"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FlightPlan ¶
type FlightPlan struct { Details FlightPlanDetails `yaml:"flightPlan"` Error Error `yaml:"error"` }
type FlightPlanDetails ¶
type FlightPlanDetails struct { ArrivesAt string `yaml:"arrivesAt"` CreatedAt string `yaml:"createdAt"` Departure string `yaml:"departure"` Destination string `yaml:"destination"` Distance int `yaml:"distance"` FuelConsumed int `yaml:"fuelConsumed"` FuelRemaining int `yaml:"fuelRemaining"` Id string `yaml:"id"` ShipId string `yaml:"shipId"` TerminatedAt string `yaml:"terminatedAt"` TimeRemainingInSeconds int `yaml:"timeRemainingInSeconds"` }
type Marketplace ¶
Marketplace contains the list of products that can be traded.
type Product ¶
type Product struct { PricePerUnit int `yaml:"pricePerUnit"` PurchasePricePerUnit int `yaml:"purchasePricePerUnit"` QuantityAvailable int `yaml:"quantityAvailable"` SellPricePerUnit int `yaml:"sellPricePerUnit"` Spread int `yaml:"spread"` Symbol string `yaml:"symbol"` VolumePerUnit int `yaml:"volumePerUnit"` }
Product contains the details about a tradeable product.
type Route ¶
Route is the representation of the route file.
func ReadRouteDescription ¶
ReadRouteDescription will generate the component.Route instance from the data read from YAML file.
func ReadRouteFile ¶
ReadRouteFile will read the YAML file with the route definition.
type RouteStop ¶
type RouteStop struct { Station string `yaml:"station"` Buy map[string]int `yaml:"buy"` Sell map[string]int `yaml:"sell"` }
RouteStop is the representation of each stop, its location, what to buy and what to sell.
type Ship ¶
type Ship struct { Details ShipDetails `yaml:"ship"` Error Error `yaml:"error"` // contains filtered or unexported fields }
Ship contains the essential information to authenticate in the game, but also to map the response from ship details.
func NewShip ¶
func NewShip( ctx context.Context, tracer trace.Tracer, id, connectionType, connectionString, topicRead string, partitionRead int, topicWrite string, partitionWrite int) (*Ship, error)
NewShip creates a new instance of component.Ship. func NewShip(ctx context.Context, tracer trace.Tracer, id, token string) (*Ship, error) {
func NewShipCustomProxy ¶
func NewShipCustomProxy(ctx context.Context, tracer trace.Tracer, proxy kafka.Proxy, id string) (*Ship, error)
NewShipCustomProxy creates a new instance of component.Ship, using a provided custom web.WebProxy. func NewShipCustomProxy(ctx context.Context, tracer trace.Tracer, proxy web.Proxy, id, token string) (*Ship, error) {
func (*Ship) BuyAll ¶
func (s *Ship) BuyAll(ctx context.Context, buy map[string]int, marketplace map[string]Product) error
BuyAll is wrapper to buy the products in the provided list.
func (*Ship) DoCommerce ¶
DoCommerce places the buy and sell orders to the game.
func (*Ship) Fly ¶
Fly will set the FlightPlan to a new destination, and wait until the flight is finished before returning from the method.
func (*Ship) ForceBuyFuel ¶
ForceBuyFuel will prioritize the purchase of fuel, selling goods if necessary.
func (*Ship) GetDetails ¶
GetDetails will get the ship details from the game.
func (*Ship) GetFlightPlan ¶
func (s *Ship) GetFlightPlan(ctx context.Context) (*FlightPlan, error)
GetFlightPlan retrieves current flight plan, if any.
func (*Ship) GetMarketplaceProducts ¶
func (s *Ship) GetMarketplaceProducts(ctx context.Context) (*Marketplace, *map[string]Product, error)
GetMarketplaceProducts will fetch the products that are available to be traded in the current marketplace.
func (*Ship) NewFlightPlan ¶
NewFlightPlan sets a new destination for the ship to fly to.
type ShipCargo ¶
type ShipCargo struct { Good string `yaml:"good"` Quantity int `yaml:"quantity"` TotalVolume int `yaml:"totalVolume"` }
ShipCargo contains the details about the products stored in the ship cargo.
type ShipDetails ¶
type ShipDetails struct { Id string `yaml:"id"` FlightPlanId string `yaml:"flightPlanId"` Location string `yaml:"location"` X int `yaml:"x"` Y int `yaml:"y"` Cargo []ShipCargo `yaml:"cargo"` SpaceAvailable int `yaml:"spaceAvailable"` Type string `yaml:"type"` Class string `yaml:"class"` MaxCargo int `yaml:"maxCargo"` LoadingSpeed int `yaml:"loadingSpeed"` Speed int `yaml:"speed"` Manufacturer string `yaml:"manufacturer"` Plating int `yaml:"plating"` Weapons int `yaml:"weapons"` }
ShipDetails is the response from the Ship Detail API.