summaryrefslogtreecommitdiff
path: root/lib/ships.js
diff options
context:
space:
mode:
authorJulien Dessaux2023-05-14 01:50:19 +0200
committerJulien Dessaux2023-05-14 01:53:57 +0200
commitefdf50a55a32c18c3563b883563f271531a6c38b (patch)
tree07343aa025294e93ea9207f0da2e437f167af8cd /lib/ships.js
parentInitial import (diff)
downloadspacetraders-efdf50a55a32c18c3563b883563f271531a6c38b.tar.gz
spacetraders-efdf50a55a32c18c3563b883563f271531a6c38b.tar.bz2
spacetraders-efdf50a55a32c18c3563b883563f271531a6c38b.zip
Implemented a basic extraction loop
Diffstat (limited to 'lib/ships.js')
-rw-r--r--lib/ships.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/ships.js b/lib/ships.js
new file mode 100644
index 0000000..e536e73
--- /dev/null
+++ b/lib/ships.js
@@ -0,0 +1,35 @@
+import * as api from './api.js';
+
+export function extract(ctx) {
+ console.log(`${ctx.ship}: extracting`);
+ api.send({endpoint: `/my/ships/${ctx.ship}/extract`, method: 'POST', next: ctx.next});
+}
+
+export function dock(ctx) {
+ console.log(`${ctx.ship}: docking`);
+ api.send({endpoint: `/my/ships/${ctx.ship}/dock`, method: 'POST', next: ctx.next});
+}
+
+export function navigate(ctx) {
+ console.log(`${ctx.ship}: navigating to ${ctx.waypoint}`);
+ api.send({endpoint: `/my/ships/${ctx.ship}/navigate`, method: 'POST', payload: { waypointSymbol: ctx.waypoint }, next: ctx.next});
+}
+
+export function orbit(ctx) {
+ console.log(`${ctx.ship}: orbiting`);
+ api.send({endpoint: `/my/ships/${ctx.ship}/orbit`, method: 'POST', next: ctx.next});
+}
+
+export function refuel(ctx) {
+ console.log(`${ctx.ship}: refueling`);
+ api.send({endpoint: `/my/ships/${ctx.ship}/refuel`, method: 'POST', next: ctx.next});
+}
+
+export function sell(ctx) {
+ console.log(`${ctx.ship}: selling ${ctx.units} of ${ctx.good}`);
+ api.send({endpoint: `/my/ships/${ctx.ship}/sell`, method: 'POST', payload: { symbol: ctx.good, units: ctx.units }, next: ctx.next});
+}
+
+export function ship(ctx) {
+ api.send({endpoint: `/my/ships/${ctx.ship}`, next: ctx.next});
+}