diff options
author | mat <github@matdoes.dev> | 2022-04-20 19:16:16 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-04-20 19:16:16 -0500 |
commit | 6b2bdd5b86eb0ebdf67b50bf5f2dcf74044fe914 (patch) | |
tree | 986d1f11c1267d9598a15f6031aeee1e2925ea63 /src/cleaners/skyblock/collections.ts | |
parent | 5712e10eec2c9fa881bdf19295808404c56f7d33 (diff) | |
download | skyblock-api-6b2bdd5b86eb0ebdf67b50bf5f2dcf74044fe914.tar.gz skyblock-api-6b2bdd5b86eb0ebdf67b50bf5f2dcf74044fe914.tar.bz2 skyblock-api-6b2bdd5b86eb0ebdf67b50bf5f2dcf74044fe914.zip |
store api ids in skyblock-constants
Diffstat (limited to 'src/cleaners/skyblock/collections.ts')
-rw-r--r-- | src/cleaners/skyblock/collections.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cleaners/skyblock/collections.ts b/src/cleaners/skyblock/collections.ts index 119e292..fe8ee1d 100644 --- a/src/cleaners/skyblock/collections.ts +++ b/src/cleaners/skyblock/collections.ts @@ -1,5 +1,6 @@ import { cleanItemId, hypixelItemNames } from './itemId.js' import typedHypixelApi from 'typed-hypixel-api' +import * as constants from '../../constants.js' const COLLECTIONS = { 'farming': [ @@ -97,13 +98,17 @@ function getCategory(collectionName): CollectionCategory | undefined { } export function cleanCollections(data: typedHypixelApi.SkyBlockProfileMember): Collection[] { + // collection tiers show up like this: [ GRAVEL_3, GOLD_INGOT_2, MELON_-1, LOG_2:1_7, RAW_FISH:3_-1] // these tiers are the same for all players in a coop const playerCollectionTiersRaw: string[] = data?.unlocked_coll_tiers ?? [] const playerCollectionTiers: { [key: string]: number } = {} + let rawCollectionNames: Set<string> = new Set() + for (const collectionTierNameValueRaw of playerCollectionTiersRaw) { const [collectionTierNameRaw, collectionTierValueRaw] = collectionTierNameValueRaw.split(/_(?=-?\d+$)/) + rawCollectionNames.add(collectionTierNameRaw) const collectionName = cleanItemId(collectionTierNameRaw) // ensure it's at least 0 const collectionValue: number = Math.max(parseInt(collectionTierValueRaw), 0) @@ -113,6 +118,9 @@ export function cleanCollections(data: typedHypixelApi.SkyBlockProfileMember): C playerCollectionTiers[collectionName] = collectionValue } + constants.addCollections(Array.from(rawCollectionNames)) + + // collection names show up like this: { LOG: 49789, LOG:2: 26219, MUSHROOM_COLLECTION: 2923} // these values are different for each player in a coop const playerCollectionXpsRaw: { [key in hypixelItemNames]?: number } = data?.collection ?? {} |