2 Commits

Author SHA1 Message Date
YouHaveTrouble b3ec17f2c0 version bump 2024-07-15 23:25:08 +02:00
YouHaveTrouble c00e4178c5 fix nearest aetheryte finder 2024-07-15 21:09:14 +02:00
2 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "discipleofland",
"version": "0.0.4",
"version": "0.0.5",
"private": true,
"type": "module",
"scripts": {
+9 -9
View File
@@ -67,16 +67,16 @@ export default defineComponent({
methods: {
findNearestAetheryte(zone: string, x: number, y: number): Aetheryte | null {
let result = null;
let distance = Number.MAX_SAFE_INTEGER;
for (const aetheryte of this.aetherytes) {
let distance = Number.MAX_VALUE;
if (aetheryte.position.zone === zone) {
const a = aetheryte.position.x - x;
const b = aetheryte.position.y - y;
const distanceToAetheryte = Math.sqrt((a * a) + (b * b));
if (distanceToAetheryte < distance) {
distance = distanceToAetheryte;
result = aetheryte;
}
if (aetheryte.position.zone !== zone) continue;
const a = aetheryte.position.x - x;
const b = aetheryte.position.y - y;
const distanceToAetheryte = Math.hypot(a, b);
if (distanceToAetheryte < distance) {
`Aetheryte ${aetheryte.name.en} (${distance}) is new nearest aetheryte`;
distance = distanceToAetheryte;
result = aetheryte;
}
}
return result;