1
0
Fork 0

[node] Big Contracts lib refactoring

This commit is contained in:
Julien Dessaux 2024-05-13 23:45:45 +02:00
parent 1f6daef018
commit de0251bc22
Signed by: adyxax
GPG key ID: F92E51B86E07177E
7 changed files with 88 additions and 139 deletions

View file

@ -1,8 +1,7 @@
import * as selling from './selling.js';
import * as dbContracts from '../database/contracts.js';
import { Contract } from '../lib/contracts.js';
import { Ship } from '../lib/ships.js';
import {
Contract,
Waypoint,
} from '../lib/types.ts';
import { categorizeCargo } from '../lib/utils.ts';
@ -11,7 +10,6 @@ export async function mineUntilFullFor(contract: Contract, ship: Ship, asteroid:
// TODO find a good asteroid
while(true) {
await mineUntilFull(ship);
contract = dbContracts.getContract(contract.id);
const deliver = contract.terms.deliver[0];
const cargo = categorizeCargo(ship.cargo, deliver.tradeSymbol);
const wantedUnits = Object.values(cargo.wanted).reduce((acc, e) => acc += e, 0);