From ccbfd9deb947c776782b80229be4513485321a88 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Fri, 17 May 2024 22:01:29 +0200 Subject: [node] fixed and optimized contracting --- nodejs/lib/ships.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'nodejs/lib/ships.ts') diff --git a/nodejs/lib/ships.ts b/nodejs/lib/ships.ts index 920cc21..e4875f8 100644 --- a/nodejs/lib/ships.ts +++ b/nodejs/lib/ships.ts @@ -25,15 +25,6 @@ import { shortestPath, } from './utils.ts'; -export async function getShips(): Promise> { - const response = await send>({endpoint: `/my/ships`, page: 1}); - if (response.error) { - debugLog(response); - throw response; - } - return response.data.map(ship => new Ship(ship)); -} - export class Ship { cargo: Cargo; cooldown: Cooldown; @@ -228,3 +219,18 @@ export class Ship { return this.cargo; } } + +let myShips: Array = []; + +export function getShips(): Array { + return myShips; +} + +export async function initShips(): Promise { + const response = await send>({endpoint: `/my/ships`, page: 1}); + if (response.error) { + debugLog(response); + throw response; + } + myShips = response.data.map(ship => new Ship(ship)); +} -- cgit v1.2.3