aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cleaners/achievements.ts24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/cleaners/achievements.ts b/src/cleaners/achievements.ts
index 2e75cc6..5d10209 100644
--- a/src/cleaners/achievements.ts
+++ b/src/cleaners/achievements.ts
@@ -11,7 +11,7 @@ interface TieredAchievement {
interface ChallengeAchievement {
id: string
name: string
- achieved: boolean
+ unlocked: boolean
description: string
}
@@ -37,18 +37,30 @@ export async function cleanPlayerAchievements(data: typedHypixelApi.PlayerDataRe
description: value ? achievementData.description.replace(/%s/g, value.toString()) : achievementData.description
})
}
+ tieredAchievements.sort((a, b) => (b.value ?? 0) - (a.value ?? 0))
+
+ let unlockedChallengeAchievements: ChallengeAchievement[] = []
+ let lockedChallengeAchievements: ChallengeAchievement[] = []
- let challengeAchievements: ChallengeAchievement[] = []
for (const [achievementId, achievementData] of Object.entries(achievementsData.one_time)) {
- challengeAchievements.push({
+ const achievement: ChallengeAchievement = {
id: achievementId.toLowerCase(),
name: achievementData.name,
- achieved: data.achievementsOneTime.includes(`skyblock_${achievementId.toLowerCase()}`),
+ unlocked: data.achievementsOneTime.includes(`skyblock_${achievementId.toLowerCase()}`),
description: achievementData.description
- })
+ }
+ if (achievement.unlocked)
+ unlockedChallengeAchievements.push(achievement)
+ else
+ lockedChallengeAchievements.push(achievement)
}
- return { tiered: tieredAchievements, challenge: challengeAchievements }
+ return {
+ tiered: tieredAchievements, challenge: [
+ ...unlockedChallengeAchievements,
+ ...lockedChallengeAchievements
+ ]
+ }
}
// this shouldn't be possible