diff options
author | Julien Dessaux | 2024-03-27 15:20:14 +0100 |
---|---|---|
committer | Julien Dessaux | 2024-03-27 15:21:37 +0100 |
commit | a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9 (patch) | |
tree | 1566c60bf1155e62821d9561ba1cc998b04b8ea5 /nodejs/automation/contracting.ts | |
parent | [all] fixed erroneous contracts index (diff) | |
download | spacetraders-a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9.tar.gz spacetraders-a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9.tar.bz2 spacetraders-a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9.zip |
[node] finished the great typescript rewrite
Diffstat (limited to 'nodejs/automation/contracting.ts')
-rw-r--r-- | nodejs/automation/contracting.ts | 16 |
1 files changed, 6 insertions, 10 deletions
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<Ship>) { // 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<Ship>) { // 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<Ship>) { 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 |