summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulien Dessaux2023-06-07 00:22:52 +0200
committerJulien Dessaux2023-06-07 00:23:11 +0200
commit4d5384aa43cdfb147b9bcafddc16343749bd4fd7 (patch)
tree0e2d131546a6e49c370055a13c3b7751b03a94ce /lib
parentUpdate ships status at the end of the nav cooldown (diff)
downloadspacetraders-4d5384aa43cdfb147b9bcafddc16343749bd4fd7.tar.gz
spacetraders-4d5384aa43cdfb147b9bcafddc16343749bd4fd7.tar.bz2
spacetraders-4d5384aa43cdfb147b9bcafddc16343749bd4fd7.zip
Use waypoints function where relevant
Diffstat (limited to 'lib')
-rw-r--r--lib/systems.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/systems.js b/lib/systems.js
index fcbf41a..e03da6c 100644
--- a/lib/systems.js
+++ b/lib/systems.js
@@ -29,20 +29,21 @@ export async function system(ctx) {
// Retrieves a list of waypoints that have a specific ctx.trait like a SHIPYARD or a MARKETPLACE in the system ctx.symbol
export async function trait(ctx) {
- const s = await system(ctx);
- return s.waypoints.filter(s => s.traits.some(t => t.symbol === ctx.trait));
+ const w = await waypoints(ctx);
+ return w.filter(s => s.traits.some(t => t.symbol === ctx.trait));
}
// Retrieves a list of waypoints that have a specific ctx.type like ASTEROID_FIELD in the system ctx.symbol
export async function type(ctx, response) {
- const s = await system(ctx);
- return s.waypoints.filter(s => s.type === ctx.type);
+ const w = await waypoints(ctx);
+ return w.filter(s => s.type === ctx.type);
}
// Retrieves the system's information for ctx.symbol and caches it in the database
export async function waypoints(ctx) {
await system(ctx);
let updated = db.getSystemUpdated(ctx.symbol);
+ // TODO handle uncharted systems
if (updated === null) {
let waypoints = [];
for (let page=1; true; ++page) {