1
0
Fork 0

[node] fixed and optimized contracting

This commit is contained in:
Julien Dessaux 2024-05-17 22:01:29 +02:00
parent 6504e44ffa
commit ccbfd9deb9
Signed by: adyxax
GPG key ID: F92E51B86E07177E
5 changed files with 61 additions and 44 deletions

View file

@ -25,15 +25,6 @@ import {
shortestPath,
} from './utils.ts';
export async function getShips(): Promise<Array<Ship>> {
const response = await send<Array<Ship>>({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<Ship> = [];
export function getShips(): Array<Ship> {
return myShips;
}
export async function initShips(): Promise<void> {
const response = await send<Array<Ship>>({endpoint: `/my/ships`, page: 1});
if (response.error) {
debugLog(response);
throw response;
}
myShips = response.data.map(ship => new Ship(ship));
}