From a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Wed, 27 Mar 2024 15:20:14 +0100 Subject: [node] finished the great typescript rewrite --- nodejs/automation/mining.js | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 nodejs/automation/mining.js (limited to 'nodejs/automation/mining.js') diff --git a/nodejs/automation/mining.js b/nodejs/automation/mining.js deleted file mode 100644 index 79a784a..0000000 --- a/nodejs/automation/mining.js +++ /dev/null @@ -1,33 +0,0 @@ -import * as selling from './selling.js'; -import * as dbShips from '../database/ships.js'; -import * as api from '../lib/api.js'; -import * as libShips from '../lib/ships.js'; -import * as utils from '../lib/utils.js'; - -// example ctx { asteroidSymbol: XXXXX, good: 'SILVER_ORE', symbol: 'ADYXAX-2' } -// returns the number of units of the good the ship holds -export async function mineUntilFullOf(ctx) { - while(true) { - const ship = dbShips.getShip(ctx.symbol); - const cargo = utils.categorizeCargo(await mineUntilFull({symbol: ctx.symbol}), ctx.good); - const wantedUnits = Object.values(cargo.wanted).reduce((acc, e) => acc += e, 0); - // > 90% full of the valuable goods ? - if (wantedUnits >= ship.cargo.capacity * 0.9) return; - // we are full but need to sell junk - await selling.sell(ship, ctx.good); - await libShips.navigate({symbol: ship.symbol, waypoint: ctx.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(ctx) { - while(true) { - const ship = dbShips.getShip(ctx.symbol); - if (ship.cargo.units >= ship.cargo.capacity * 0.9) return ship.cargo; - if (await libShips.extract({symbol: ctx.symbol}) === null) - await ship(ctx); // refresh the ships status from the server just in case - } -} - -// TODO surveying the asteroid field -- cgit v1.2.3