From 28b3a695dce34b5adafb0139978de63271f75180 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Mon, 12 Jun 2023 23:40:07 +0200 Subject: Use the database cache for mining and contracting automations --- automation/mining.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'automation/mining.js') diff --git a/automation/mining.js b/automation/mining.js index 393a98c..f35af36 100644 --- a/automation/mining.js +++ b/automation/mining.js @@ -25,8 +25,9 @@ export async function mineUntilFullOf(ctx) { async function mineUntilFull(ctx) { while(true) { const ship = dbShips.getShip(ctx.symbol); - if (ship.cargo.units >= ship.cargo.capacity * 0.8) return ship.cargo; - await ships.extract({symbol: ctx.symbol}); + if (ship.cargo.units >= ship.cargo.capacity * 0.9) return ship.cargo; + if (await ships.extract({symbol: ctx.symbol}) === null) + ship = await ship(ctx); // refresh the ships status from the server just in case } } -- cgit v1.2.3