Use waypoints function where relevant
This commit is contained in:
parent
458d08626f
commit
4d5384aa43
1 changed files with 5 additions and 4 deletions
|
@ -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
|
// 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) {
|
export async function trait(ctx) {
|
||||||
const s = await system(ctx);
|
const w = await waypoints(ctx);
|
||||||
return s.waypoints.filter(s => s.traits.some(t => t.symbol === ctx.trait));
|
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
|
// 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) {
|
export async function type(ctx, response) {
|
||||||
const s = await system(ctx);
|
const w = await waypoints(ctx);
|
||||||
return s.waypoints.filter(s => s.type === ctx.type);
|
return w.filter(s => s.type === ctx.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieves the system's information for ctx.symbol and caches it in the database
|
// Retrieves the system's information for ctx.symbol and caches it in the database
|
||||||
export async function waypoints(ctx) {
|
export async function waypoints(ctx) {
|
||||||
await system(ctx);
|
await system(ctx);
|
||||||
let updated = db.getSystemUpdated(ctx.symbol);
|
let updated = db.getSystemUpdated(ctx.symbol);
|
||||||
|
// TODO handle uncharted systems
|
||||||
if (updated === null) {
|
if (updated === null) {
|
||||||
let waypoints = [];
|
let waypoints = [];
|
||||||
for (let page=1; true; ++page) {
|
for (let page=1; true; ++page) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue