summaryrefslogtreecommitdiff
path: root/nodejs
diff options
context:
space:
mode:
authorJulien Dessaux2024-03-19 02:05:15 +0100
committerJulien Dessaux2024-03-19 02:05:15 +0100
commit3b61a9694d0053fb08c93a2e23b5a49edeac0a07 (patch)
treecaf9e57c2a7d777bac4fc45ea2dcb52de0316e5f /nodejs
parent[javascript] Implement the selling loop of the contracting automation (diff)
downloadspacetraders-3b61a9694d0053fb08c93a2e23b5a49edeac0a07.tar.gz
spacetraders-3b61a9694d0053fb08c93a2e23b5a49edeac0a07.tar.bz2
spacetraders-3b61a9694d0053fb08c93a2e23b5a49edeac0a07.zip
[javascript] fixed mining loop
Diffstat (limited to 'nodejs')
-rw-r--r--nodejs/automation/mining.js4
-rw-r--r--nodejs/lib/ships.js2
-rw-r--r--nodejs/shell.nix2
3 files changed, 4 insertions, 4 deletions
diff --git a/nodejs/automation/mining.js b/nodejs/automation/mining.js
index ea1d35d..79a784a 100644
--- a/nodejs/automation/mining.js
+++ b/nodejs/automation/mining.js
@@ -12,7 +12,7 @@ export async function mineUntilFullOf(ctx) {
const cargo = utils.categorizeCargo(await mineUntilFull({symbol: ctx.symbol}), ctx.good);
const wantedUnits = Object.values(cargo.wanted).reduce((acc, e) => acc += e, 0);
// > 90% full of the valuable goods ?
- if (wantedUnits >= cargo.capacity * 0.9) return;
+ if (wantedUnits >= ship.cargo.capacity * 0.9) return;
// we are full but need to sell junk
await selling.sell(ship, ctx.good);
await libShips.navigate({symbol: ship.symbol, waypoint: ctx.asteroidSymbol});
@@ -26,7 +26,7 @@ async function mineUntilFull(ctx) {
const ship = dbShips.getShip(ctx.symbol);
if (ship.cargo.units >= ship.cargo.capacity * 0.9) return ship.cargo;
if (await libShips.extract({symbol: ctx.symbol}) === null)
- ship = await ship(ctx); // refresh the ships status from the server just in case
+ await ship(ctx); // refresh the ships status from the server just in case
}
}
diff --git a/nodejs/lib/ships.js b/nodejs/lib/ships.js
index 6415cdb..835e62b 100644
--- a/nodejs/lib/ships.js
+++ b/nodejs/lib/ships.js
@@ -62,7 +62,7 @@ export async function jump(ctx) {
export async function navigate(ctx) {
const ship = dbShips.getShip(ctx.symbol);
if (ship.nav.waypointSymbol === ctx.waypoint) {
- return await orbit(ctx);
+ return;
}
await orbit(ctx);
// TODO if we do not have enough fuel, make a stop to refuel along the way or drift to the destination
diff --git a/nodejs/shell.nix b/nodejs/shell.nix
index afa559e..a8d584e 100644
--- a/nodejs/shell.nix
+++ b/nodejs/shell.nix
@@ -3,5 +3,5 @@
pkgs.mkShell {
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
name = "node";
- nativeBuildInputs = with pkgs; [ ijq jq nodejs ];
+ nativeBuildInputs = with pkgs; [ ijq jq nodejs_21 ];
}