This commit is contained in:
Aslan 2026-01-20 19:54:45 -05:00
parent d36e98ad0b
commit c071b286af
23 changed files with 713 additions and 11 deletions

View file

@ -0,0 +1,26 @@
import {
locationFarlands,
locations,
type ILocation,
type Location,
} from "./structures/locations.js";
const getLocation = (id: Location): ILocation => {
const location = locations.find((location) => location.id === id);
return location ? location : locationFarlands;
};
const getLocationDistance = (
locationA: ILocation,
locationB: ILocation,
): number => {
const deltaX = Math.abs(locationA.X - locationB.X);
const deltaY = Math.abs(locationA.Y - locationB.Y);
const deltaPow = Math.pow(deltaX, 2) + Math.pow(deltaY, 2);
return Math.sqrt(deltaPow);
};
export { getLocation, getLocationDistance };