[node] Fixed basic procurement trading loop
This commit is contained in:
parent
a34e4fbed4
commit
a58394230d
1 changed files with 5 additions and 5 deletions
|
@ -94,11 +94,11 @@ async function runTradeProcurement(contract: Contract, ship: Ship): Promise<void
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
// check from the closest one that exports what we need
|
// 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++) {
|
outer: for (let i = 0; i < markets.length; i++) {
|
||||||
const waypointSymbol = markets[i].data.symbol;
|
const waypointSymbol = markets[i].data.symbol;
|
||||||
const market = await libSystems.market(waypointSymbol);
|
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) {
|
if (market.exports[j].symbol === wantedCargo) {
|
||||||
buyingPoint = market.symbol;
|
buyingPoint = market.symbol;
|
||||||
break outer;
|
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 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++) {
|
outer: for (let i = 0; i < markets.length; i++) {
|
||||||
const waypointSymbol = markets[i].data.symbol;
|
const waypointSymbol = markets[i].data.symbol;
|
||||||
const market = await libSystems.market(waypointSymbol);
|
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) {
|
if (market.exports[j].symbol === wantedCargo) {
|
||||||
buyingPoint = market.symbol;
|
buyingPoint = market.symbol;
|
||||||
break outer;
|
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}`;
|
throw `runTradeProcurement failed, no market exports or exchanges ${wantedCargo}`;
|
||||||
}
|
}
|
||||||
// go buy what we need
|
// go buy what we need
|
||||||
|
|
Loading…
Add table
Reference in a new issue