1
0
Fork 0

[node] fixed mining and selling loop issues

This commit is contained in:
Julien Dessaux 2024-03-29 00:24:51 +01:00
parent 3cb4f4df51
commit 719a9c1a77
Signed by: adyxax
GPG key ID: F92E51B86E07177E
4 changed files with 15 additions and 11 deletions

View file

@ -19,10 +19,10 @@ export async function sell(ship: Ship, good: string): Promise<Ship> {
// can we sell anything here?
const goods = whatCanBeTradedAt(cargo.goods, market.imports.concat(market.exchange));
for (let i = 0; i < goods.length; i++) {
const symbol = goods[i].symbol;
await libShips.sell(ship, good);
await libShips.sell(ship, goods[i].symbol);
};
// are we done selling everything we can?
ship = dbShips.getShip(ship.symbol);
cargo = utils.categorizeCargo(ship.cargo, good);
if (Object.keys(cargo.goods).length === 0) {
return ship;