diff options
author | Julien Dessaux | 2024-04-04 22:01:47 +0200 |
---|---|---|
committer | Julien Dessaux | 2024-04-07 23:01:42 +0200 |
commit | a58394230d4657e1fcae8505de61da34357609b7 (patch) | |
tree | 4020f74b7e6a0583c1f30287f8dcb1e1e6fd44ed | |
parent | [node] implemented basic procurement trading loop (diff) | |
download | spacetraders-a58394230d4657e1fcae8505de61da34357609b7.tar.gz spacetraders-a58394230d4657e1fcae8505de61da34357609b7.tar.bz2 spacetraders-a58394230d4657e1fcae8505de61da34357609b7.zip |
[node] Fixed basic procurement trading loop
-rw-r--r-- | nodejs/automation/contracting.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/nodejs/automation/contracting.ts b/nodejs/automation/contracting.ts index 02715c8..fa9a4c4 100644 --- a/nodejs/automation/contracting.ts +++ b/nodejs/automation/contracting.ts @@ -94,11 +94,11 @@ async function runTradeProcurement(contract: Contract, ship: Ship): Promise<void return 0; }); // check from the closest one that exports what we need - let buyingPoint: string = null; + let buyingPoint: string = ""; outer: for (let i = 0; i < markets.length; i++) { const waypointSymbol = markets[i].data.symbol; const market = await libSystems.market(waypointSymbol); - for (let j = 0; j < market.exports; j++) { + for (let j = 0; j < market.exports.length; j++) { if (market.exports[j].symbol === wantedCargo) { buyingPoint = market.symbol; break outer; @@ -106,11 +106,11 @@ async function runTradeProcurement(contract: Contract, ship: Ship): Promise<void } } // if we did not find an exporting market we look for an exchange - if (buyingPoint === null) { + if (buyingPoint === "") { outer: for (let i = 0; i < markets.length; i++) { const waypointSymbol = markets[i].data.symbol; const market = await libSystems.market(waypointSymbol); - for (let j = 0; j < market.exchanges; j++) { + for (let j = 0; j < market.exchange.length; j++) { if (market.exports[j].symbol === wantedCargo) { buyingPoint = market.symbol; break outer; @@ -118,7 +118,7 @@ async function runTradeProcurement(contract: Contract, ship: Ship): Promise<void } } } - if (buyingPoint === null) { + if (buyingPoint === "") { throw `runTradeProcurement failed, no market exports or exchanges ${wantedCargo}`; } // go buy what we need |