diff options
Diffstat (limited to 'nodejs')
-rw-r--r-- | nodejs/automation/contracting.js | 15 | ||||
-rw-r--r-- | nodejs/lib/api.js | 2 | ||||
-rw-r--r-- | nodejs/lib/ships.js | 2 | ||||
-rw-r--r-- | nodejs/package-lock.json | 24 | ||||
-rw-r--r-- | nodejs/shell.nix | 7 |
5 files changed, 30 insertions, 20 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 diff --git a/nodejs/lib/api.js b/nodejs/lib/api.js index b9f768f..ecb0282 100644 --- a/nodejs/lib/api.js +++ b/nodejs/lib/api.js @@ -10,7 +10,7 @@ let busy = false; // true if we are already sending api requests. let backoffSeconds = 0; let running = false; // other module variables -let headers = undefined; // a file scope variable so that we only evaluate these once. +let headers = undefined; // a file scoped variable so that we only evaluate these once. let queue = new PriorityQueue(); // a priority queue to hold api calls we want to send, allows for throttling. // a single queue processor should be running at any time, otherwise there will be trouble! diff --git a/nodejs/lib/ships.js b/nodejs/lib/ships.js index eb59013..f6cb027 100644 --- a/nodejs/lib/ships.js +++ b/nodejs/lib/ships.js @@ -5,7 +5,7 @@ import * as systems from '../lib/systems.js'; export async function extract(ctx) { const ship = dbShips.getShip(ctx.symbol); - const asteroidFields = await systems.type({symbol: ship.nav.systemSymbol, type: 'ASTEROID_FIELD'}); + const asteroidFields = await systems.type({symbol: ship.nav.systemSymbol, type: 'ENGINEERED_ASTEROID'}); // TODO if there are multiple fields, find the closest one? await navigate({symbol: ctx.symbol, waypoint: asteroidFields[0].symbol}); await orbit(ctx); diff --git a/nodejs/package-lock.json b/nodejs/package-lock.json index 03a732e..0764b8a 100644 --- a/nodejs/package-lock.json +++ b/nodejs/package-lock.json @@ -31,9 +31,9 @@ ] }, "node_modules/better-sqlite3": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-9.3.0.tgz", - "integrity": "sha512-ww73jVpQhRRdS9uMr761ixlkl4bWoXi8hMQlBGhoN6vPNlUHpIsNmw4pKN6kjknlt/wopdvXHvLk1W75BI+n0Q==", + "version": "9.4.3", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-9.4.3.tgz", + "integrity": "sha512-ud0bTmD9O3uWJGuXDltyj3R47Nz0OHX8iqPOT5PMspGqlu/qQFn+5S2eFBUCrySpavTjFXbi4EgrfVvPAHlImw==", "hasInstallScript": true, "dependencies": { "bindings": "^1.5.0", @@ -217,9 +217,9 @@ "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" }, "node_modules/node-abi": { - "version": "3.51.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.51.0.tgz", - "integrity": "sha512-SQkEP4hmNWjlniS5zdnfIXTk1x7Ome85RDzHlTbBtzE97Gfwz/Ipw4v/Ryk20DWIy3yCNVLVlGKApCnmvYoJbA==", + "version": "3.56.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.56.0.tgz", + "integrity": "sha512-fZjdhDOeRcaS+rcpve7XuwHBmktS1nS1gzgghwKUQQ8nTy2FdSDr6ZT8k6YhvlJeHmmQMYiT/IH9hfco5zeW2Q==", "dependencies": { "semver": "^7.3.5" }, @@ -236,9 +236,9 @@ } }, "node_modules/prebuild-install": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", - "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.2.tgz", + "integrity": "sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==", "dependencies": { "detect-libc": "^2.0.0", "expand-template": "^2.0.3", @@ -316,9 +316,9 @@ ] }, "node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "dependencies": { "lru-cache": "^6.0.0" }, diff --git a/nodejs/shell.nix b/nodejs/shell.nix new file mode 100644 index 0000000..afa559e --- /dev/null +++ b/nodejs/shell.nix @@ -0,0 +1,7 @@ +{ pkgs ? import <nixpkgs> {} }: + +pkgs.mkShell { + LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive"; + name = "node"; + nativeBuildInputs = with pkgs; [ ijq jq nodejs ]; +} |