diff options
Diffstat (limited to '')
-rw-r--r-- | nodejs/lib/utils.ts | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/nodejs/lib/utils.ts b/nodejs/lib/utils.ts index 9491583..a5bb142 100644 --- a/nodejs/lib/utils.ts +++ b/nodejs/lib/utils.ts @@ -3,7 +3,7 @@ import { } from './api.ts'; import { PriorityQueue } from './priority_queue.ts'; import { getShips } from './ships.ts'; -import { market } from './systems.ts'; +import { market, trait } from './systems.ts'; import { Cargo, CargoManifest, @@ -25,6 +25,19 @@ type Price = { price: number; }; +export async function are_we_done_visiting_all_markets(): Promise<boolean> { + const marketplaceWaypoints = await trait(getShips()[0].nav.systemSymbol, 'MARKETPLACE'); + let done = true; + for (const w of marketplaceWaypoints) { + const marketplaceData = await market(w); + if (marketplaceData.tradeGoods !== undefined) continue; + if (is_there_a_ship_at_this_waypoint(w)) continue; + done = false; + break; + } + return done; +} + // cargo is a ship.cargo object, want is an optional symbol export function categorizeCargo(cargo: Cargo, want?: string): CategorizedCargo { const wanted = cargo.inventory.filter(i => i.symbol === want || i.symbol === 'ANTIMATTER'); |