diff options
author | mat <github@matdoes.dev> | 2022-04-09 19:30:59 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-04-09 19:30:59 -0500 |
commit | 58e2fa480e127c30a04dc81256f462b7ad206eb9 (patch) | |
tree | 31fa318182aa25bd22c5afc8dc4a2f19086e024e | |
parent | 44510a2390270c7aeb8ad7ade72cd03c56ad5a2d (diff) | |
download | skyblock-api-58e2fa480e127c30a04dc81256f462b7ad206eb9.tar.gz skyblock-api-58e2fa480e127c30a04dc81256f462b7ad206eb9.tar.bz2 skyblock-api-58e2fa480e127c30a04dc81256f462b7ad206eb9.zip |
add special profile modes
-rw-r--r-- | package-lock.json | 14 | ||||
-rw-r--r-- | package.json | 4 | ||||
-rw-r--r-- | src/cleaners/skyblock/gameMode.ts | 16 | ||||
-rw-r--r-- | src/cleaners/skyblock/profile.ts | 4 |
4 files changed, 29 insertions, 9 deletions
diff --git a/package-lock.json b/package-lock.json index 9c580a6..0b41db7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "prismarine-nbt": "github:PrismarineJS/prismarine-nbt", "prom-client": "^14.0.1", "queue-promise": "^2.2.1", - "typed-hypixel-api": "^0.4.0", + "typed-hypixel-api": "^0.5.1", "uuid": "^8.3.2" }, "devDependencies": { @@ -2734,9 +2734,9 @@ } }, "node_modules/typed-hypixel-api": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-0.4.2.tgz", - "integrity": "sha512-WpOvZ+f2k/C4lT8bqLptc0bjcZocrbjXZKsOdncdLcxFncpowuWAY6q7ySuwcGkH+cUGhKQIo1L0Pl4qso6G/Q==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-0.5.1.tgz", + "integrity": "sha512-VuQ/QyrCz8irmJbkydAvc89zwNf7Xc269GQgjwkN86j/Q9luhnUwk0Q2d6qVgwfNaFibYwmX8NbYCLj+mOk5uA==", "dependencies": { "typescript": "^4.6.3", "undici": "^4.16.0" @@ -5070,9 +5070,9 @@ } }, "typed-hypixel-api": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-0.4.2.tgz", - "integrity": "sha512-WpOvZ+f2k/C4lT8bqLptc0bjcZocrbjXZKsOdncdLcxFncpowuWAY6q7ySuwcGkH+cUGhKQIo1L0Pl4qso6G/Q==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-0.5.1.tgz", + "integrity": "sha512-VuQ/QyrCz8irmJbkydAvc89zwNf7Xc269GQgjwkN86j/Q9luhnUwk0Q2d6qVgwfNaFibYwmX8NbYCLj+mOk5uA==", "requires": { "typescript": "^4.6.3", "undici": "^4.16.0" diff --git a/package.json b/package.json index 64455e4..7f8d58e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "prismarine-nbt": "github:PrismarineJS/prismarine-nbt", "prom-client": "^14.0.1", "queue-promise": "^2.2.1", - "typed-hypixel-api": "^0.4.0", + "typed-hypixel-api": "^0.5.1", "uuid": "^8.3.2" }, "devDependencies": { @@ -54,4 +54,4 @@ "typescript": "^4.6.3" }, "type": "module" -}
\ No newline at end of file +} 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<NonNullable<typedHypixelApi.SkyBlockProfile['game_mode']>, 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<O extends ApiOptions>( minions: minions, minionCount: uniqueMinions, maxUniqueMinions: maxUniqueMinions ?? 0, + mode: cleanGameMode(data) } return cleanFullProfile } |