diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-05-02 20:38:28 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-02 20:38:28 -0500 |
commit | fbd9446806ad3535435729179276ecca4df319d5 (patch) | |
tree | 83b3ea672dac268417d93ac236eafc3c6fd3debe /src/cleaners | |
parent | fd7991ba7318b32027db8dbe9160490e8652b199 (diff) | |
download | skyblock-api-fbd9446806ad3535435729179276ecca4df319d5.tar.gz skyblock-api-fbd9446806ad3535435729179276ecca4df319d5.tar.bz2 skyblock-api-fbd9446806ad3535435729179276ecca4df319d5.zip |
add `/constants` api to get max minions and fairy souls (#21)
Diffstat (limited to 'src/cleaners')
-rw-r--r-- | src/cleaners/skyblock/member.ts | 9 | ||||
-rw-r--r-- | src/cleaners/skyblock/profile.ts | 12 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts index cfa9a71..7a57975 100644 --- a/src/cleaners/skyblock/member.ts +++ b/src/cleaners/skyblock/member.ts @@ -9,6 +9,7 @@ import { cleanSlayers, SlayerData } from './slayers' import { cleanVisitedZones, Zone } from './zones' import { cleanSkills, Skill } from './skills' import * as cached from '../../hypixelCached' +import * as constants from '../../constants' import { Included } from '../../hypixel' import { CleanPlayer } from '../player' import { CleanRank } from '../rank' @@ -53,6 +54,12 @@ export async function cleanSkyBlockProfileMemberResponse(member, included: Inclu const inventoriesIncluded = included === null || included.includes('inventories') const player = await cached.fetchPlayer(member.uuid) if (!player) return + + const fairySouls = cleanFairySouls(member) + const { max_fairy_souls: maxFairySouls } = await constants.fetchConstantValues() + if (fairySouls.total > (maxFairySouls ?? 0)) + await constants.setConstantValues({ max_fairy_souls: fairySouls.total }) + return { uuid: member.uuid, username: player.username, @@ -68,7 +75,7 @@ export async function cleanSkyBlockProfileMemberResponse(member, included: Inclu rawHypixelStats: member.stats ?? {}, minions: await cleanMinions(member), - fairy_souls: cleanFairySouls(member), + fairy_souls: fairySouls, inventories: inventoriesIncluded ? await cleanInventories(member) : undefined, objectives: cleanObjectives(member), skills: cleanSkills(member), diff --git a/src/cleaners/skyblock/profile.ts b/src/cleaners/skyblock/profile.ts index 433471b..a796d8f 100644 --- a/src/cleaners/skyblock/profile.ts +++ b/src/cleaners/skyblock/profile.ts @@ -1,7 +1,8 @@ import { CleanBasicMember, CleanMember, cleanSkyBlockProfileMemberResponse, cleanSkyBlockProfileMemberResponseBasic } from './member' import { CleanMinion, combineMinionArrays, countUniqueMinions } from './minions' -import { Bank, cleanBank } from './bank' import { ApiOptions } from '../../hypixel' +import { Bank, cleanBank } from './bank' +import * as constants from '../../constants' export interface CleanProfile extends CleanBasicProfile { members?: CleanBasicMember[] @@ -78,6 +79,13 @@ export async function cleanSkyblockProfileResponse(data: any, options?: ApiOptio } const minions: CleanMinion[] = combineMinionArrays(memberMinions) + const { max_minions: maxUniqueMinions } = await constants.fetchConstantValues() + + const uniqueMinions = countUniqueMinions(minions) + console.log(uniqueMinions, (maxUniqueMinions ?? 0), uniqueMinions > (maxUniqueMinions ?? 0)) + if (uniqueMinions > (maxUniqueMinions ?? 0)) + await constants.setConstantValues({ max_minions: uniqueMinions }) + // return more detailed info return { uuid: data.profile_id, @@ -85,7 +93,7 @@ export async function cleanSkyblockProfileResponse(data: any, options?: ApiOptio members: cleanedMembers, bank: cleanBank(data), minions: minions, - minion_count: countUniqueMinions(minions) + minion_count: uniqueMinions } } |