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

@ -20,12 +20,9 @@ export async function mineUntilFullOf(good: string, ship: Ship, asteroidSymbol:
}
}
// example ctx { symbol: 'ADYXAX-2' }
// extract the ship's cargo contents when more than 80% full then returns the ships cargo object
async function mineUntilFull(ship: Ship): Promise<void> {
ship = dbShips.getShip(ship.symbol) as Ship;
while (ship.cargo.units <= ship.cargo.capacity * 0.9) {
ship.cargo = await libShips.extract(ship);
while (!libShips.isFull(ship)) {
await libShips.extract(ship);
}
}