aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-09-10 19:44:00 -0500
committermat <github@matdoes.dev>2021-09-10 19:44:00 -0500
commitbc53d88408f42a27acaa04132850c16ecbb40c2d (patch)
treeef86f82f0109fa5759da90448a89ad618cfec6ab
parent94205e15c1e0d2b843727765691c566cac548a45 (diff)
downloadskyblock-api-bc53d88408f42a27acaa04132850c16ecbb40c2d.tar.gz
skyblock-api-bc53d88408f42a27acaa04132850c16ecbb40c2d.tar.bz2
skyblock-api-bc53d88408f42a27acaa04132850c16ecbb40c2d.zip
make the zones api include unvisited zones
-rw-r--r--build/cleaners/skyblock/member.js2
-rw-r--r--build/cleaners/skyblock/zones.js17
-rw-r--r--src/cleaners/skyblock/member.ts2
-rw-r--r--src/cleaners/skyblock/zones.ts22
4 files changed, 35 insertions, 8 deletions
diff --git a/build/cleaners/skyblock/member.js b/build/cleaners/skyblock/member.js
index 2242828..3a6a143 100644
--- a/build/cleaners/skyblock/member.js
+++ b/build/cleaners/skyblock/member.js
@@ -47,7 +47,7 @@ export async function cleanSkyBlockProfileMemberResponse(member, included = unde
inventories: inventoriesIncluded ? await cleanInventories(member) : undefined,
objectives: cleanObjectives(member),
skills: await cleanSkills(member),
- visited_zones: cleanVisitedZones(member),
+ visited_zones: await cleanVisitedZones(member),
collections: cleanCollections(member),
slayers: cleanSlayers(member)
};
diff --git a/build/cleaners/skyblock/zones.js b/build/cleaners/skyblock/zones.js
index ef7015e..90c689b 100644
--- a/build/cleaners/skyblock/zones.js
+++ b/build/cleaners/skyblock/zones.js
@@ -1,12 +1,23 @@
-export function cleanVisitedZones(data) {
+import * as constants from '../../constants.js';
+export async function cleanVisitedZones(data) {
const rawZones = data?.visited_zones || [];
// TODO: store all the zones that exist in SkyBlock, add add those to the array with visited being false
const zones = [];
- for (const rawZoneName of rawZones) {
+ const knownZones = await constants.fetchZones();
+ for (const rawZoneName of knownZones) {
zones.push({
name: rawZoneName,
- visited: true
+ visited: rawZones.includes(rawZoneName)
});
}
+ // if this user somehow has a zone that we don't know about, just add it to zones
+ for (const rawZoneName of rawZones) {
+ if (!knownZones.includes(rawZoneName)) {
+ zones.push({
+ name: rawZoneName,
+ visited: true
+ });
+ }
+ }
return zones;
}
diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts
index a9a12b8..59dd493 100644
--- a/src/cleaners/skyblock/member.ts
+++ b/src/cleaners/skyblock/member.ts
@@ -81,7 +81,7 @@ export async function cleanSkyBlockProfileMemberResponse(member, included: Inclu
inventories: inventoriesIncluded ? await cleanInventories(member) : undefined,
objectives: cleanObjectives(member),
skills: await cleanSkills(member),
- visited_zones: cleanVisitedZones(member),
+ visited_zones: await cleanVisitedZones(member),
collections: cleanCollections(member),
slayers: cleanSlayers(member)
}
diff --git a/src/cleaners/skyblock/zones.ts b/src/cleaners/skyblock/zones.ts
index 87d008d..b07c542 100644
--- a/src/cleaners/skyblock/zones.ts
+++ b/src/cleaners/skyblock/zones.ts
@@ -1,18 +1,34 @@
+import * as constants from '../../constants.js'
+
export interface Zone {
name: string
visited: boolean
}
-export function cleanVisitedZones(data: any): Zone[] {
+export async function cleanVisitedZones(data: any): Promise<Zone[]> {
const rawZones = data?.visited_zones || []
// TODO: store all the zones that exist in SkyBlock, add add those to the array with visited being false
const zones: Zone[] = []
- for (const rawZoneName of rawZones) {
+
+ const knownZones = await constants.fetchZones()
+
+ for (const rawZoneName of knownZones) {
zones.push({
name: rawZoneName,
- visited: true
+ visited: rawZones.includes(rawZoneName)
})
}
+
+ // if this user somehow has a zone that we don't know about, just add it to zones
+ for (const rawZoneName of rawZones) {
+ if (!knownZones.includes(rawZoneName)) {
+ zones.push({
+ name: rawZoneName,
+ visited: true
+ })
+ }
+ }
+
return zones
}