From e102c3e9873abc216a1eececa15fc5c2df7e30d7 Mon Sep 17 00:00:00 2001 From: Putro <29204244+Pewtro@users.noreply.github.com> Date: Sun, 11 Aug 2024 02:02:17 +0200 Subject: [PATCH] [WoW] Add support for Character Statistics APIs --- .changeset/seven-shoes-wave.md | 5 ++ .../character-statistics.test.ts | 20 ++++++ .../character-statistics.ts | 14 ++++ .../wow/src/character-statistics/types.ts | 68 +++++++++++++++++++ packages/wow/src/index.ts | 6 ++ 5 files changed, 113 insertions(+) create mode 100644 .changeset/seven-shoes-wave.md create mode 100644 packages/wow/src/character-statistics/character-statistics.test.ts create mode 100644 packages/wow/src/character-statistics/character-statistics.ts create mode 100644 packages/wow/src/character-statistics/types.ts diff --git a/.changeset/seven-shoes-wave.md b/.changeset/seven-shoes-wave.md new file mode 100644 index 0000000..29d4f11 --- /dev/null +++ b/.changeset/seven-shoes-wave.md @@ -0,0 +1,5 @@ +--- +'@blizzard-api/wow': minor +--- + +Add support for Character Statistics APIs diff --git a/packages/wow/src/character-statistics/character-statistics.test.ts b/packages/wow/src/character-statistics/character-statistics.test.ts new file mode 100644 index 0000000..b7f7053 --- /dev/null +++ b/packages/wow/src/character-statistics/character-statistics.test.ts @@ -0,0 +1,20 @@ +import { describe, expect, it } from 'vitest'; +import { characterStatisticsSummary } from './character-statistics'; + +describe('characterStatisticsSummary', () => { + it('should return the correct protected resource object', () => { + const realmSlug = 'test-realm'; + const characterName = 'test-character'; + const token = 'test-token'; + + const expectedResource = { + namespace: 'profile', + path: `/profile/wow/character/${realmSlug}/${characterName}/statistics`, + token, + }; + + const result = characterStatisticsSummary(realmSlug, characterName, token); + + expect(result).toEqual(expectedResource); + }); +}); diff --git a/packages/wow/src/character-statistics/character-statistics.ts b/packages/wow/src/character-statistics/character-statistics.ts new file mode 100644 index 0000000..8dfe400 --- /dev/null +++ b/packages/wow/src/character-statistics/character-statistics.ts @@ -0,0 +1,14 @@ +import type { ProtectedResource } from '@blizzard-api/core'; +import type { CharacterStatisticsSummaryResponse } from './types'; + +export function characterStatisticsSummary( + realmSlug: string, + characterName: string, + token: string, +): ProtectedResource { + return { + namespace: 'profile', + path: `/profile/wow/character/${realmSlug}/${characterName}/statistics`, + token, + }; +} diff --git a/packages/wow/src/character-statistics/types.ts b/packages/wow/src/character-statistics/types.ts new file mode 100644 index 0000000..e1d8ef5 --- /dev/null +++ b/packages/wow/src/character-statistics/types.ts @@ -0,0 +1,68 @@ +import type { NameIdKey, ResponseBase } from '../base'; + +export interface CharacterStatisticsSummaryResponse extends ResponseBase { + agility: BaseEffectiveStat; + armor: BaseEffectiveStat; + attack_power: number; + avoidance: Rating; + block: RatingWithValue; + bonus_armor: number; + character: Character; + dodge: RatingWithValue; + health: number; + intellect: BaseEffectiveStat; + lifesteal: RatingWithValue; + main_hand_damage_max: number; + main_hand_damage_min: number; + main_hand_dps: number; + main_hand_speed: number; + mana_regen: number; + mana_regen_combat: number; + mastery: RatingWithValue; + melee_crit: RatingWithValue; + melee_haste: RatingWithValue; + off_hand_damage_max: number; + off_hand_damage_min: number; + off_hand_dps: number; + off_hand_speed: number; + parry: RatingWithValue; + power: number; + power_type: Character; + ranged_crit: RatingWithValue; + ranged_haste: RatingWithValue; + speed: Rating; + spell_crit: RatingWithValue; + spell_haste: RatingWithValue; + spell_penetration: number; + spell_power: number; + stamina: BaseEffectiveStat; + strength: BaseEffectiveStat; + versatility: number; + versatility_damage_done_bonus: number; + versatility_damage_taken_bonus: number; + versatility_healing_done_bonus: number; +} + +interface BaseEffectiveStat { + base: number; + effective: number; +} + +interface Rating { + rating: number; + rating_bonus: number; +} + +interface RatingWithValue { + rating: number; + rating_bonus: number; + value: number; +} + +interface Realm extends NameIdKey { + slug: string; +} + +interface Character extends NameIdKey { + realm: Realm; +} diff --git a/packages/wow/src/index.ts b/packages/wow/src/index.ts index b9d498f..13f3cd9 100644 --- a/packages/wow/src/index.ts +++ b/packages/wow/src/index.ts @@ -54,6 +54,7 @@ import { characterCompletedQuests, characterQuests } from './character-quests/ch import { characterReputationsSummary } from './character-reputations/character-reputations'; import { characterSoulbinds } from './character-soulbinds/character-soulbinds'; import { characterSpecializationsSummary } from './character-specializations/character-specializations'; +import { characterStatisticsSummary } from './character-statistics/character-statistics'; import { connectedRealm, connectedRealmIndex, connectedRealmSearch } from './connected-realm/connected-realm'; import { conduit, @@ -250,6 +251,8 @@ export const wow = { characterSoulbinds, //Character Specializations characterSpecializationsSummary, + //Character Statistics + characterStatisticsSummary, //Connected Realm connectedRealm, connectedRealmIndex, @@ -470,6 +473,9 @@ export * from './character-soulbinds/types'; //Character Specializations export * from './character-specializations/character-specializations'; export * from './character-specializations/types'; +//Character Statistics +export * from './character-statistics/character-statistics'; +export * from './character-statistics/types'; //Connected Realm export * from './connected-realm/connected-realm'; export * from './connected-realm/types';