From a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Wed, 27 Mar 2024 15:20:14 +0100 Subject: [node] finished the great typescript rewrite --- nodejs/automation/contracting.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'nodejs/automation/contracting.ts') diff --git a/nodejs/automation/contracting.ts b/nodejs/automation/contracting.ts index 2857778..aa4cd95 100644 --- a/nodejs/automation/contracting.ts +++ b/nodejs/automation/contracting.ts @@ -34,7 +34,7 @@ async function runProcurement(contract: Contract, ships: Array) { // TODO check if contract is fulfilled! const wantedCargo = contract.terms.deliver[0].tradeSymbol; const deliveryPoint = contract.terms.deliver[0].destinationSymbol; - const asteroids = await systems.type({symbol: ships[0].nav.systemSymbol, type: 'ENGINEERED_ASTEROID'}); + const asteroids = await systems.type(ships[0].nav.systemSymbol, 'ENGINEERED_ASTEROID'); const asteroidSymbol = asteroids[0].symbol; ships.forEach(async function(ship) { while (!contract.fulfilled) { @@ -46,12 +46,8 @@ async function runProcurement(contract: Contract, ships: Array) { // Then it depends on where we are switch (ship.nav.waypointSymbol) { case asteroidSymbol: - await mining.mineUntilFullOf({ - asteroidSymbol: asteroidSymbol, - good: wantedCargo, - symbol: ship.symbol - }); - await libShips.navigate(ship, deliveryPoint); + ship = await mining.mineUntilFullOf(wantedCargo, ship, asteroidSymbol); + ship = await libShips.navigate(ship, deliveryPoint); break; case deliveryPoint: if (goodCargo !== undefined) { // we could be here if a client restart happens right after selling before we navigate away @@ -59,12 +55,12 @@ async function runProcurement(contract: Contract, ships: Array) { contract = await contracts.deliver(contract, ship); if (contract.fulfilled) break; } - await libShips.navigate(ship, asteroidSymbol); + ship = await libShips.navigate(ship, asteroidSymbol); break; default: // we were either selling or started contracting - await selling.sell(ship, wantedCargo); - await libShips.navigate(ship, asteroidSymbol); + ship = await selling.sell(ship, wantedCargo); + ship = await libShips.navigate(ship, asteroidSymbol); } } // TODO repurpose the ship -- cgit v1.2.3