1
0
Fork 0

[node] implement shipyard info retrieval and database caching

This commit is contained in:
Julien Dessaux 2024-05-20 22:50:33 +02:00
parent ccbfd9deb9
commit 4cb5c7853c
Signed by: adyxax
GPG key ID: F92E51B86E07177E
5 changed files with 81 additions and 10 deletions

View file

@ -2,9 +2,8 @@ import {
debugLog,
} from './api.ts';
import { PriorityQueue } from './priority_queue.ts';
import {
market,
} from './systems.ts';
import { getShips } from './ships.ts';
import { market } from './systems.ts';
import {
Cargo,
CargoManifest,
@ -41,6 +40,10 @@ export function distance(a: Point, b: Point) {
return Math.sqrt((a.x-b.x)**2 + (a.y-b.y)**2);
}
export function isThereAShipAtThisWaypoint(waypoint: Waypoint): boolean {
return getShips().some(s => s.nav.waypointSymbol === waypoint.symbol);
}
export function sortByDistanceFrom<T extends Point>(a: Point, points: Array<T>): Array<{data: T, distance: number}>{
let result = points.map(function (m) { return {
data: m,