mirror of
https://github.com/YouHaveTrouble/DiscipleOfLand.git
synced 2026-05-12 06:26:56 +00:00
zone data now contains aetheryte list
This commit is contained in:
+4
-19
@@ -58,23 +58,22 @@ export default defineComponent({
|
||||
data: () => ({
|
||||
eorzeaTime: new EorzeaTime() as EorzeaTime,
|
||||
nodes: [] as Node[],
|
||||
aetherytes: [] as Aetheryte[],
|
||||
items: {} as { [key: string]: Item },
|
||||
zones: {} as { [key: string]: Zone },
|
||||
filtersActive: false,
|
||||
filters: new Filters(),
|
||||
}),
|
||||
methods: {
|
||||
findNearestAetheryte(zone: string, x: number, y: number): Aetheryte | null {
|
||||
findNearestAetheryte(zoneName: string, x: number, y: number): Aetheryte | null {
|
||||
let result = null;
|
||||
let distance = Number.MAX_SAFE_INTEGER;
|
||||
for (const aetheryte of this.aetherytes) {
|
||||
if (aetheryte.position.zone !== zone) continue;
|
||||
const zone = this.zones[zoneName]
|
||||
if (!zone) return null;
|
||||
for (const aetheryte of zone.aetherytes) {
|
||||
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;
|
||||
}
|
||||
@@ -88,20 +87,6 @@ export default defineComponent({
|
||||
this.eorzeaTime = new EorzeaTime();
|
||||
}, 500);
|
||||
|
||||
const aetheryteData: Response | null = await fetch("/data/aetherytes.json")
|
||||
.catch((): null => {
|
||||
return null;
|
||||
});
|
||||
if (aetheryteData === null) {
|
||||
console.error("Failed to fetch aetheryte data!")
|
||||
return;
|
||||
}
|
||||
|
||||
const aetherytes = await aetheryteData.json();
|
||||
for (const aetheryteData of aetherytes) {
|
||||
this.aetherytes.push(new Aetheryte(aetheryteData));
|
||||
}
|
||||
|
||||
const itemData: Response | null = await fetch("/data/items.json")
|
||||
.catch((): null => {
|
||||
return null;
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
import Aetheryte from "@/entities/Aetheryte";
|
||||
|
||||
export default class Zone {
|
||||
|
||||
name: {
|
||||
en: string,
|
||||
}
|
||||
|
||||
constructor(data: {name: {en: string}}) {
|
||||
aetherytes: Array<Aetheryte> = [];
|
||||
|
||||
constructor(data: {name: {en: string}, aetherytes: Array<{position: {x: number, y: number, zone: string}, name: {en: string}}>}) {
|
||||
this.name = {
|
||||
en: data.name.en
|
||||
};
|
||||
if (!Array.isArray(data.aetherytes)) return;
|
||||
for (const aetheryte of data.aetherytes) {
|
||||
this.aetherytes.push(new Aetheryte(aetheryte));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user