summaryrefslogtreecommitdiff
path: root/nodejs/lib/ships.ts
diff options
context:
space:
mode:
authorJulien Dessaux2024-05-21 00:26:17 +0200
committerJulien Dessaux2024-05-21 00:26:17 +0200
commitd77558b8def94fd1e1efecc3cfebb7dd3b6d6ae3 (patch)
treeec1c660af2badb2df4e407d81e16a5a297b4773d /nodejs/lib/ships.ts
parentFixed pathing function for probes (diff)
downloadspacetraders-d77558b8def94fd1e1efecc3cfebb7dd3b6d6ae3.tar.gz
spacetraders-d77558b8def94fd1e1efecc3cfebb7dd3b6d6ae3.tar.bz2
spacetraders-d77558b8def94fd1e1efecc3cfebb7dd3b6d6ae3.zip
[node] implement agent automation that visits all shipyards with the starting probe
Diffstat (limited to '')
-rw-r--r--nodejs/lib/ships.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/nodejs/lib/ships.ts b/nodejs/lib/ships.ts
index e4875f8..7daae71 100644
--- a/nodejs/lib/ships.ts
+++ b/nodejs/lib/ships.ts
@@ -88,6 +88,22 @@ export class Ship {
await sleep(response.data.cooldown.remainingSeconds*1000);
return this.cargo;
}
+ //async flightMode(mode: string): Promise<void> {
+ // if (this.nav.flightMode === mode) return;
+ // const response = await send<nav>({endpoint: `/my/ships/${this.symbol}/nav`, method: 'PATCH', payload: { flightmode: mode }});
+ // if (response.error) {
+ // switch(response.error.code) {
+ // case 4214:
+ // const sicite = response.error.data as ShipIsCurrentlyInTransitError;
+ // await sleep(sicite.secondsToArrival * 1000);
+ // return await this.flightMode(mode);
+ // default: // yet unhandled error
+ // debugLog(response);
+ // throw response;
+ // }
+ // }
+ // this.nav = response.data;
+ //}
isFull(): boolean {
return this.cargo.units >= this.cargo.capacity * 0.9;
}
@@ -105,6 +121,7 @@ export class Ship {
}
private async navigateTo(symbol: string): Promise<void> {
await this.orbit();
+ //if (this.fuel.capacity === 0) this.flightMode('BURN');
const response = await send<{fuel: Fuel, nav: Nav}>({endpoint: `/my/ships/${this.symbol}/navigate`, method: 'POST', payload: { waypointSymbol: symbol }}); // TODO events field
if (response.error) {
switch(response.error.code) {