Skip to content
This repository was archived by the owner on Oct 27, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/cleaners/skyblock/member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cleanCoopInvitation, CoopInvitation } from './coopInvitation.js'
import { cleanCollections, Collection } from './collections.js'
import { cleanInventories, Inventories } from './inventory.js'
import { cleanFairySouls, FairySouls } from './fairysouls.js'
import { cleanObjectives, Objective } from './objectives.js'
import { cleanQuests, Quest } from './quests.js'
import { CleanFullProfileBasicMembers } from './profile.js'
import { cleanProfileStats, StatItem } from './stats.js'
import { CleanMinion, cleanMinions } from './minions.js'
Expand Down Expand Up @@ -39,7 +39,7 @@ interface ExtraCleanMemberFields {
minions: CleanMinion[]
fairySouls: FairySouls
inventories?: Inventories
objectives: Objective[]
quests: Quest[]
skills: Skills
zones: Zone[]
collections: Collection[]
Expand Down Expand Up @@ -110,8 +110,7 @@ export async function cleanSkyBlockProfileMemberResponse(member: typedHypixelApi
minions: await minionsPromise,
fairySouls: fairySouls,
inventories: inventoriesPromise ? await inventoriesPromise : undefined,
objectives: cleanObjectives(member),

quests: cleanQuests(member),
skills: await skillsPromise,

zones: await zonesPromise,
Expand Down
20 changes: 0 additions & 20 deletions src/cleaners/skyblock/objectives.ts

This file was deleted.

65 changes: 65 additions & 0 deletions src/cleaners/skyblock/quests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import typedHypixelApi from 'typed-hypixel-api'

/*
Each quest has a number of attached objectives that must be completed in order for the quest to be counted as complete. Quests show when they started and when they ended. All attached objectives will be in between these times.

An objective has a number called the "progress". This usually represents how much of the objective item has been collected, so if the objective requires you to collect logs the progress would be the amount collected. If the objective doesn't require you to collect items, this will be 0.

What we want to know:
- The attached objectives for each quest
- The minimum required progress for each objective for be completed
*/

export interface Objective {
id: string
completed: boolean
progress: {
done: number
required: number
} | null
}

export interface Quest {
id: string
completed: boolean
objectives: Objective
}

/** A record of objective ids to quest ids */
let knownAttachedQuests: Record<string, string> = {}

export function cleanQuests(data: typedHypixelApi.SkyBlockProfileMember): Quest[] {
for (const [objectiveId, objectiveValue] of Object.entries(data.objectives)) {
if (objectiveId in knownAttachedQuests)
continue

// here we try to figure out what quests this objective could belong to
let possibleAttachedQuests: string[] = []
if (objectiveValue.status === 'COMPLETE') {
for (const [questId, questValue] of Object.entries(data.quests)) {
if (questValue.status === 'COMPLETE') {
if (
objectiveValue.completed_at >= questValue.activated_at
&& objectiveValue.completed_at <= questValue.completed_at
) {
// console.log('objective', objectiveId, 'could belong to quest', questId)
possibleAttachedQuests.push(questId)
}
}
}
}
if (objectiveValue.status === 'ACTIVE') {
for (const [questId, questValue] of Object.entries(data.quests)) {
if (questValue.status === 'ACTIVE') {
possibleAttachedQuests.push(questId)
}
}
}
if (possibleAttachedQuests.length === 1) {
knownAttachedQuests[objectiveId] = possibleAttachedQuests[0]
console.log('Figured out that', objectiveId, 'belongs to quest', possibleAttachedQuests[0])
}
}

return []
}
1 change: 0 additions & 1 deletion src/hypixelApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import { shuffle, sleep } from './util.js'
import typedHypixelApi from 'typed-hypixel-api'
import { Agent } from 'https'

if (!process.env.hypixel_keys)
// if there's no hypixel keys in env, run dotenv
Expand Down