1
0
Fork 0

[node] waypoints usage refactoring

This commit is contained in:
Julien Dessaux 2024-04-06 10:55:11 +02:00
parent 234770b611
commit eeaa64b5ed
Signed by: adyxax
GPG key ID: F92E51B86E07177E
5 changed files with 43 additions and 33 deletions

View file

@ -1,10 +1,13 @@
import * as selling from './selling.js';
import * as dbContracts from '../database/contracts.js';
import { Ship } from '../lib/ships.js';
import { Contract } from '../lib/types.ts';
import {
Contract,
Waypoint,
} from '../lib/types.ts';
import { categorizeCargo } from '../lib/utils.ts';
export async function mineUntilFullFor(contract: Contract, ship: Ship, asteroidSymbol: string): Promise<void> {
export async function mineUntilFullFor(contract: Contract, ship: Ship, asteroid: Waypoint): Promise<void> {
// TODO find a good asteroid
while(true) {
await mineUntilFull(ship);
@ -17,7 +20,7 @@ export async function mineUntilFullFor(contract: Contract, ship: Ship, asteroidS
|| cargo.wanted[deliver.tradeSymbol] >= deliver.unitsRequired - deliver.unitsFulfilled) return;
// we are full but need to sell junk
await selling.sell(ship, deliver.tradeSymbol);
await ship.navigate(asteroidSymbol);
await ship.navigate(asteroid);
}
}