From ff6dcfbe52cc325fce1acd3cb4f160d233967eec Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 16 Feb 2022 23:07:23 -0600 Subject: return max fairy souls and max minions in member makes it so we don't have to fetch /constants from the frontend --- src/cleaners/skyblock/fairysouls.ts | 8 +++++++- src/cleaners/skyblock/member.ts | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/cleaners/skyblock') diff --git a/src/cleaners/skyblock/fairysouls.ts b/src/cleaners/skyblock/fairysouls.ts index 11bbc9e..29c8502 100644 --- a/src/cleaners/skyblock/fairysouls.ts +++ b/src/cleaners/skyblock/fairysouls.ts @@ -1,14 +1,20 @@ +import * as constants from '../../constants' + export interface FairySouls { total: number /** The number of fairy souls that haven't been exchanged yet */ unexchanged: number exchanges: number + /** The highest possible number of total fairy souls */ + max: number } -export function cleanFairySouls(data: any): FairySouls { +export async function cleanFairySouls(data: any): Promise { + const { max_fairy_souls } = await constants.fetchConstantValues() return { total: data?.fairy_souls_collected ?? 0, unexchanged: data?.fairy_souls ?? 0, exchanges: data?.fairy_exchanges ?? 0, + max: max_fairy_souls ?? 0, } } \ No newline at end of file diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts index 59dd493..932b016 100644 --- a/src/cleaners/skyblock/member.ts +++ b/src/cleaners/skyblock/member.ts @@ -29,6 +29,7 @@ export interface CleanMember extends CleanBasicMember { stats: StatItem[] rawHypixelStats?: { [ key: string ]: number } minions: CleanMinion[] + max_minions: number fairy_souls: FairySouls inventories?: Inventories objectives: Objective[] @@ -57,10 +58,12 @@ export async function cleanSkyBlockProfileMemberResponse(member, included: Inclu const player = await cached.fetchPlayer(member.uuid) if (!player) return null - const fairySouls = cleanFairySouls(member) + const fairySouls = await cleanFairySouls(member) const { max_fairy_souls: maxFairySouls } = await constants.fetchConstantValues() if (fairySouls.total > (maxFairySouls ?? 0)) await constants.setConstantValues({ max_fairy_souls: fairySouls.total }) + + const { max_minions } = await constants.fetchConstantValues() return { uuid: member.uuid, @@ -77,6 +80,7 @@ export async function cleanSkyBlockProfileMemberResponse(member, included: Inclu rawHypixelStats: member.stats ?? {}, minions: await cleanMinions(member), + max_minions: max_minions ?? 0, fairy_souls: fairySouls, inventories: inventoriesIncluded ? await cleanInventories(member) : undefined, objectives: cleanObjectives(member), -- cgit