summaryrefslogtreecommitdiff
path: root/nodejs/automation
diff options
context:
space:
mode:
authorJulien Dessaux2024-03-15 22:17:10 +0100
committerJulien Dessaux2024-03-15 22:17:10 +0100
commit01e3f05ea0d4360cb85de67928c7b5bd9ed48742 (patch)
tree1f104f229010a59800a9e7e72243e1ad3418fd50 /nodejs/automation
parent[javascript] updated dependencies (diff)
downloadspacetraders-01e3f05ea0d4360cb85de67928c7b5bd9ed48742.tar.gz
spacetraders-01e3f05ea0d4360cb85de67928c7b5bd9ed48742.tar.bz2
spacetraders-01e3f05ea0d4360cb85de67928c7b5bd9ed48742.zip
[javascript] Rework the contracting loop following the asteroids changes
Diffstat (limited to 'nodejs/automation')
-rw-r--r--nodejs/automation/contracting.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/nodejs/automation/contracting.js b/nodejs/automation/contracting.js
index a02c1c6..220b21b 100644
--- a/nodejs/automation/contracting.js
+++ b/nodejs/automation/contracting.js
@@ -31,8 +31,8 @@ async function runProcurement(contract, ships) {
// TODO check if contract is fulfilled!
const wantedCargo = contract.terms.deliver[0].tradeSymbol;
const deliveryPoint = contract.terms.deliver[0].destinationSymbol;
- const asteroidFields = await systems.type({symbol: ships[0].nav.systemSymbol, type: 'ASTEROID_FIELD'});
- const asteroidField = asteroidFields[0].symbol;
+ const asteroids = await systems.type({symbol: ships[0].nav.systemSymbol, type: 'ENGINEERED_ASTEROID'});
+ const asteroidSymbol = asteroids[0].symbol;
ships.forEach(async function(ship) {
while (!dbContracts.getContract(contract.id).fulfilled) {
ship = dbShips.getShip(ship.symbol);
@@ -42,8 +42,11 @@ async function runProcurement(contract, ships) {
if (delay > 0) await api.sleep(delay);
// Then it depends on where we are
switch (ship.nav.waypointSymbol) {
- case asteroidField:
- let response = await mining.mineUntilFullOf({good: wantedCargo, symbol: ship.symbol});
+ case asteroidSymbol:
+ let response = await mining.mineUntilFullOf({
+ good: wantedCargo,
+ symbol: ship.symbol
+ });
await libShips.navigate({symbol: ship.symbol, waypoint: deliveryPoint});
break;
case deliveryPoint:
@@ -53,10 +56,10 @@ async function runProcurement(contract, ships) {
break;
}
}
- await libShips.navigate({symbol: ship.symbol, waypoint: asteroidField});
+ await libShips.navigate({symbol: ship.symbol, waypoint: asteroidSymbol});
break;
default:
- await libShips.navigate({symbol: ship.symbol, waypoint: asteroidField});
+ await libShips.navigate({symbol: ship.symbol, waypoint: asteroidSymbol});
}
}
// TODO repurpose the ship