summaryrefslogtreecommitdiff
path: root/golang/pkg/agent
diff options
context:
space:
mode:
Diffstat (limited to 'golang/pkg/agent')
-rw-r--r--golang/pkg/agent/contracting.go8
-rw-r--r--golang/pkg/agent/trading.go20
-rw-r--r--golang/pkg/agent/utils.go8
-rw-r--r--golang/pkg/agent/visit.go10
4 files changed, 23 insertions, 23 deletions
diff --git a/golang/pkg/agent/contracting.go b/golang/pkg/agent/contracting.go
index ecd896a..4e476a6 100644
--- a/golang/pkg/agent/contracting.go
+++ b/golang/pkg/agent/contracting.go
@@ -41,7 +41,7 @@ func (a *agent) autoContracting(ship *model.Ship) {
}
func (a *agent) runContract(contract *model.Contract, ship *model.Ship) error {
- if err := a.client.Accept(contract, a.db); err != nil {
+ if err := a.client.Accept(contract); err != nil {
return fmt.Errorf("failed to accept contract: %w", err)
}
//slog.Info("running contract", "contract", contract, "ship", ship.Symbol)
@@ -72,15 +72,15 @@ func (a *agent) runProcurement(contract *model.Contract, ship *model.Ship) error
}
}
// deliver the goods
- if err := a.client.Navigate(ship, deliver.DestinationSymbol, a.db); err != nil {
+ if err := a.client.Navigate(ship, deliver.DestinationSymbol); err != nil {
return fmt.Errorf("failed to navigate to %s: %w", deliver.DestinationSymbol, err)
}
- if err := a.client.Deliver(contract, ship, a.db); err != nil {
+ if err := a.client.Deliver(contract, ship); err != nil {
return fmt.Errorf("failed to deliver: %w", err)
}
deliver = contract.Terms.Deliver[0]
if deliver.UnitsRequired == deliver.UnitsFulfilled {
- if err := a.client.Fulfill(contract, a.db); err != nil {
+ if err := a.client.Fulfill(contract); err != nil {
return fmt.Errorf("failed to fulfill: %w", err)
}
return nil
diff --git a/golang/pkg/agent/trading.go b/golang/pkg/agent/trading.go
index e84cef4..b900f7a 100644
--- a/golang/pkg/agent/trading.go
+++ b/golang/pkg/agent/trading.go
@@ -34,13 +34,13 @@ func (a *agent) buyTradeGood(ship *model.Ship, tradeGoodToBuy string) error {
return &TradeGoodNotFoundError{}
}
// find the closest place to buy TODO
- waypoint, err := a.client.GetWaypoint(ship.Nav.WaypointSymbol, a.db)
+ waypoint, err := a.client.GetWaypoint(ship.Nav.WaypointSymbol)
if err != nil {
return fmt.Errorf("failed to get nav waypoint %s: %w", ship.Nav.WaypointSymbol, err)
}
waypoints := make([]model.Waypoint, 0)
for i := range markets {
- waypoint, err := a.client.GetWaypoint(markets[i].Symbol, a.db)
+ waypoint, err := a.client.GetWaypoint(markets[i].Symbol)
if err != nil {
return fmt.Errorf("failed to get waypoint %s: %w", markets[i].Symbol, err)
}
@@ -48,10 +48,10 @@ func (a *agent) buyTradeGood(ship *model.Ship, tradeGoodToBuy string) error {
}
sortByDistanceFrom(waypoint, waypoints)
// Go there and refresh our market data
- if err := a.client.Navigate(ship, waypoints[0].Symbol, a.db); err != nil {
+ if err := a.client.Navigate(ship, waypoints[0].Symbol); err != nil {
return fmt.Errorf("failed to navigate to %s: %w", waypoints[0].Symbol, err)
}
- market, err := a.client.GetMarket(waypoints[0].Symbol, a.db)
+ market, err := a.client.GetMarket(waypoints[0].Symbol)
if err != nil {
return fmt.Errorf("failed to get market %s: %w", waypoints[0].Symbol, err)
}
@@ -60,7 +60,7 @@ func (a *agent) buyTradeGood(ship *model.Ship, tradeGoodToBuy string) error {
if tradeGood.Type == "EXPORT" && tradeGood.Symbol == tradeGoodToBuy {
for ship.Cargo.Units < ship.Cargo.Capacity {
increment := min(ship.Cargo.Capacity-ship.Cargo.Units, tradeGood.TradeVolume)
- if err := a.client.Purchase(ship, tradeGoodToBuy, increment, a.db); err != nil {
+ if err := a.client.Purchase(ship, tradeGoodToBuy, increment); err != nil {
return fmt.Errorf("failed to purchase %d units of %s: %w", increment, tradeGoodToBuy, err)
}
}
@@ -98,13 +98,13 @@ func (a *agent) sellEverythingExcept(ship *model.Ship, keep string) error {
return nil
}
// find the closest place to sell something TODO
- waypoint, err := a.client.GetWaypoint(ship.Nav.WaypointSymbol, a.db)
+ waypoint, err := a.client.GetWaypoint(ship.Nav.WaypointSymbol)
if err != nil {
return fmt.Errorf("failed to get nav waypoint %s: %w", ship.Nav.WaypointSymbol, err)
}
waypoints := make([]model.Waypoint, 0)
for i := range markets {
- waypoint, err := a.client.GetWaypoint(markets[i].Symbol, a.db)
+ waypoint, err := a.client.GetWaypoint(markets[i].Symbol)
if err != nil {
return fmt.Errorf("failed to get waypoint %s: %w", markets[i].Symbol, err)
}
@@ -112,10 +112,10 @@ func (a *agent) sellEverythingExcept(ship *model.Ship, keep string) error {
}
sortByDistanceFrom(waypoint, waypoints)
// Go there and refresh our market data
- if err := a.client.Navigate(ship, waypoints[0].Symbol, a.db); err != nil {
+ if err := a.client.Navigate(ship, waypoints[0].Symbol); err != nil {
return fmt.Errorf("failed to navigate to %s: %w", waypoints[0].Symbol, err)
}
- market, err := a.client.GetMarket(waypoints[0].Symbol, a.db)
+ market, err := a.client.GetMarket(waypoints[0].Symbol)
if err != nil {
return fmt.Errorf("failed to get market %s: %w", waypoints[0].Symbol, err)
}
@@ -126,7 +126,7 @@ func (a *agent) sellEverythingExcept(ship *model.Ship, keep string) error {
if tradeGood.Type == "IMPORT" && tradeGood.Symbol == cargoItem.Symbol {
for units > 0 {
increment := min(units, tradeGood.TradeVolume)
- if err := a.client.Sell(ship, cargoItem.Symbol, increment, a.db); err != nil {
+ if err := a.client.Sell(ship, cargoItem.Symbol, increment); err != nil {
return fmt.Errorf("failed to sell %d units of %s: %w", units, cargoItem.Symbol, err)
}
units = units - increment
diff --git a/golang/pkg/agent/utils.go b/golang/pkg/agent/utils.go
index b274f43..7aa9c7b 100644
--- a/golang/pkg/agent/utils.go
+++ b/golang/pkg/agent/utils.go
@@ -25,7 +25,7 @@ func (a *agent) isThereAShipAtWaypoint(waypointSymbol string) bool {
}
func (a *agent) listWaypointsInSystemWithTrait(systemSymbol string, trait string) ([]model.Waypoint, error) {
- waypoints, err := a.client.ListWaypointsInSystem(systemSymbol, a.db)
+ waypoints, err := a.client.ListWaypointsInSystem(systemSymbol)
if err != nil {
return nil, fmt.Errorf("failed to list waypoints: %w", err)
}
@@ -47,7 +47,7 @@ func (a *agent) listMarketsInSystem(systemSymbol string) ([]model.Market, error)
}
var markets []model.Market
for i := range waypoints {
- market, err := a.client.GetMarket(waypoints[i].Symbol, a.db)
+ market, err := a.client.GetMarket(waypoints[i].Symbol)
if err != nil {
return nil, fmt.Errorf("failed to get market %s: %w", waypoints[i].Symbol, err)
}
@@ -63,7 +63,7 @@ func (a *agent) listShipyardsInSystem(systemSymbol string) ([]model.Shipyard, er
}
var shipyards []model.Shipyard
for i := range waypoints {
- shipyard, err := a.client.GetShipyard(waypoints[i].Symbol, a.db)
+ shipyard, err := a.client.GetShipyard(waypoints[i].Symbol)
if err != nil {
return nil, fmt.Errorf("failed to get shipyard %s: %w", waypoints[i].Symbol, err)
}
@@ -104,7 +104,7 @@ func (a *agent) sendShipToShipyardThatSells(ship *model.Ship, shipType string) e
}
return cmp.Compare(aPrice, bPrice)
})
- if err := a.client.Navigate(ship, shipyards[0].Symbol, a.db); err != nil {
+ if err := a.client.Navigate(ship, shipyards[0].Symbol); err != nil {
return fmt.Errorf("failed to navigate to %s: %w", shipyards[0].Symbol, err)
}
return nil
diff --git a/golang/pkg/agent/visit.go b/golang/pkg/agent/visit.go
index 3004553..e420186 100644
--- a/golang/pkg/agent/visit.go
+++ b/golang/pkg/agent/visit.go
@@ -23,29 +23,29 @@ func (a *agent) visitAllShipyards(ship *model.Ship) error {
if len(shipyards) == 0 {
return nil
}
- waypoint, err := a.client.GetWaypoint(ship.Nav.WaypointSymbol, a.db)
+ waypoint, err := a.client.GetWaypoint(ship.Nav.WaypointSymbol)
if err != nil {
return fmt.Errorf("failed to get nav waypoint %s: %w", ship.Nav.WaypointSymbol, err)
}
waypoints := make([]model.Waypoint, 0)
for i := range shipyards {
- waypoint, err := a.client.GetWaypoint(shipyards[i].Symbol, a.db)
+ waypoint, err := a.client.GetWaypoint(shipyards[i].Symbol)
if err != nil {
return fmt.Errorf("failed to get waypoint %s: %w", shipyards[i].Symbol, err)
}
waypoints = append(waypoints, *waypoint)
}
sortByDistanceFrom(waypoint, waypoints)
- if err := a.client.Navigate(ship, waypoints[0].Symbol, a.db); err != nil {
+ if err := a.client.Navigate(ship, waypoints[0].Symbol); err != nil {
return fmt.Errorf("failed to navigate to %s: %w", waypoints[0].Symbol, err)
}
- if _, err := a.client.GetShipyard(waypoints[0].Symbol, a.db); err != nil {
+ if _, err := a.client.GetShipyard(waypoints[0].Symbol); err != nil {
return fmt.Errorf("failed to get shipyard %s: %w", waypoints[0].Symbol, err)
}
// If this waypoint is also a marketplace, get its data
for _, trait := range waypoints[0].Traits {
if trait.Symbol == "MARKETPLACE" {
- if _, err := a.client.GetMarket(waypoints[0].Symbol, a.db); err != nil {
+ if _, err := a.client.GetMarket(waypoints[0].Symbol); err != nil {
return fmt.Errorf("failed to get market %s: %w", waypoints[0].Symbol, err)
}
break