From 58e2fa480e127c30a04dc81256f462b7ad206eb9 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 9 Apr 2022 19:30:59 -0500 Subject: add special profile modes --- src/cleaners/skyblock/gameMode.ts | 16 ++++++++++++++++ src/cleaners/skyblock/profile.ts | 4 ++++ 2 files changed, 20 insertions(+) create mode 100644 src/cleaners/skyblock/gameMode.ts (limited to 'src/cleaners') diff --git a/src/cleaners/skyblock/gameMode.ts b/src/cleaners/skyblock/gameMode.ts new file mode 100644 index 0000000..635c00a --- /dev/null +++ b/src/cleaners/skyblock/gameMode.ts @@ -0,0 +1,16 @@ +import typedHypixelApi from 'typed-hypixel-api' +import { fetchItemList } from '../../hypixel.js' +import { levelFromXpTable } from '../../util.js' +import { fetchPets } from '../../constants.js' +import { ItemListItem } from './itemList.js' + +export type GameMode = 'normal' | 'stranded' | 'bingo' | 'ironman' +const gameModeMap: Record, GameMode> = { + bingo: 'bingo', + island: 'stranded', + ironman: 'ironman', +} + +export function cleanGameMode(data: typedHypixelApi.SkyBlockProfile): GameMode { + return (data.game_mode && (data.game_mode in gameModeMap)) ? gameModeMap[data.game_mode] : 'normal' +} diff --git a/src/cleaners/skyblock/profile.ts b/src/cleaners/skyblock/profile.ts index 04d848a..48daa24 100644 --- a/src/cleaners/skyblock/profile.ts +++ b/src/cleaners/skyblock/profile.ts @@ -4,6 +4,7 @@ import typedHypixelApi from 'typed-hypixel-api' import * as constants from '../../constants.js' import { ApiOptions } from '../../hypixel.js' import { Bank, cleanBank } from './bank.js' +import { cleanGameMode, GameMode } from './gameMode.js' export interface CleanProfile extends CleanBasicProfile { members?: CleanBasicMember[] @@ -15,6 +16,7 @@ export interface CleanFullProfile extends CleanProfile { minions: CleanMinion[] minionCount: number maxUniqueMinions: number + mode: GameMode } export interface CleanFullProfileBasicMembers extends CleanProfile { @@ -23,6 +25,7 @@ export interface CleanFullProfileBasicMembers extends CleanProfile { minions: CleanMinion[] minionCount: number maxUniqueMinions: number + mode: GameMode } /** Return a `CleanProfile` instead of a `CleanFullProfile`, useful when we need to get members but don't want to waste much ram */ @@ -107,6 +110,7 @@ export async function cleanSkyblockProfileResponse( minions: minions, minionCount: uniqueMinions, maxUniqueMinions: maxUniqueMinions ?? 0, + mode: cleanGameMode(data) } return cleanFullProfile } -- cgit