Skip to content

Commit

Permalink
[WoW] Add support for Character Statistics APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pewtro committed Aug 11, 2024
1 parent 2029362 commit e102c3e
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-shoes-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blizzard-api/wow': minor
---

Add support for Character Statistics APIs
20 changes: 20 additions & 0 deletions packages/wow/src/character-statistics/character-statistics.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
14 changes: 14 additions & 0 deletions packages/wow/src/character-statistics/character-statistics.ts
Original file line number Diff line number Diff line change
@@ -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<CharacterStatisticsSummaryResponse> {
return {
namespace: 'profile',
path: `/profile/wow/character/${realmSlug}/${characterName}/statistics`,
token,
};
}
68 changes: 68 additions & 0 deletions packages/wow/src/character-statistics/types.ts
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 6 additions & 0 deletions packages/wow/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -250,6 +251,8 @@ export const wow = {
characterSoulbinds,
//Character Specializations
characterSpecializationsSummary,
//Character Statistics
characterStatisticsSummary,
//Connected Realm
connectedRealm,
connectedRealmIndex,
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit e102c3e

Please sign in to comment.