diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-13 16:03:49 -0600 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-13 16:03:49 -0600 |
commit | 43f194ff780d704834706ac6da454a8858098906 (patch) | |
tree | d22ca4d07b4adbbb7f1cc5dcc42663ab8934ac10 | |
parent | 604cf4233e3d69d7769d330c4f31876950a0e83d (diff) | |
download | skyblock-api-43f194ff780d704834706ac6da454a8858098906.tar.gz skyblock-api-43f194ff780d704834706ac6da454a8858098906.tar.bz2 skyblock-api-43f194ff780d704834706ac6da454a8858098906.zip |
add minion_count
-rw-r--r-- | src/cleaners/skyblock/minions.ts | 11 | ||||
-rw-r--r-- | src/cleaners/skyblock/profile.ts | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/cleaners/skyblock/minions.ts b/src/cleaners/skyblock/minions.ts index da69634..b5ac85d 100644 --- a/src/cleaners/skyblock/minions.ts +++ b/src/cleaners/skyblock/minions.ts @@ -67,4 +67,13 @@ export function combineMinionArrays(minions: CleanMinion[][]): CleanMinion[] { } return resultMinions -}
\ No newline at end of file +} + +export function countUniqueMinions(minions: CleanMinion[]): number { + let uniqueMinions: number = 0 + for (const minion of minions) { + // find the number of times `true` is in the list and add it to uniqueMinions + uniqueMinions += minion.levels.filter(x => x).length + } + return uniqueMinions +} diff --git a/src/cleaners/skyblock/profile.ts b/src/cleaners/skyblock/profile.ts index c61e6cf..5d2b7a3 100644 --- a/src/cleaners/skyblock/profile.ts +++ b/src/cleaners/skyblock/profile.ts @@ -1,5 +1,5 @@ import { CleanBasicMember, CleanMember, CleanMemberProfile, cleanSkyBlockProfileMemberResponse } from './member' -import { CleanMinion, combineMinionArrays } from './minions' +import { CleanMinion, combineMinionArrays, countUniqueMinions } from './minions' import * as cached from '../../hypixelCached' import { cleanBank } from './bank' @@ -92,6 +92,7 @@ export async function fetchMemberProfile(user: string, profile: string): Promise return { member: { + // the profile name is in member rather than profile since they sometimes differ for each member profileName: cleanProfile.name, first_join: member.first_join, last_save: member.last_save, @@ -102,6 +103,7 @@ export async function fetchMemberProfile(user: string, profile: string): Promise uuid: cleanProfile.uuid, bank: cleanProfile.bank, minions: cleanProfile.minions, + minion_count: countUniqueMinions(cleanProfile.minions) } } } |