summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulien Dessaux2023-05-26 23:04:19 +0200
committerJulien Dessaux2023-05-26 23:04:19 +0200
commit88ef5666ca1ae800460b514c4778ffdfd514c9ad (patch)
tree4483ad8565fde9c961e5d76c5d90decb6feaec15 /lib
parentAutomated the extraction and delivery loop for a ship (diff)
downloadspacetraders-88ef5666ca1ae800460b514c4778ffdfd514c9ad.tar.gz
spacetraders-88ef5666ca1ae800460b514c4778ffdfd514c9ad.tar.bz2
spacetraders-88ef5666ca1ae800460b514c4778ffdfd514c9ad.zip
Fixed extraction issue with ships not carrying antimatter
Diffstat (limited to '')
-rw-r--r--lib/agent.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/agent.js b/lib/agent.js
index 18dbac3..7360dd3 100644
--- a/lib/agent.js
+++ b/lib/agent.js
@@ -58,7 +58,7 @@ async function mineUntilFullOf(ctx) {
let good = response.data.cargo.inventory.filter(i => i.symbol === ctx.good)[0];
const inventory = response.data.cargo.inventory.filter(i => i.symbol !== ctx.good);
const antimatter = response.data.cargo.inventory.filter(i => i.symbol === 'ANTIMATTER')[0];
- if (good?.units + antimatter?.units >= response.data.cargo.capacity * 0.9) { // > 90% full of the valuable goods
+ if (good?.units + (antimatter?.units ?? 0) >= response.data.cargo.capacity * 0.9) { // > 90% full of the valuable goods
return good.units;
} else { // we are full but need to sell junk
await ships.dock({ship: ctx.ship});