Skip to content

Commit

Permalink
[WoW] Standardize use of interfaces for Characters and Realms
Browse files Browse the repository at this point in the history
  • Loading branch information
Pewtro committed Aug 11, 2024
1 parent 9e40e24 commit dd401e4
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 172 deletions.
6 changes: 1 addition & 5 deletions packages/wow/src/account-profile/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Faction, Gender, Href, KeyBase, NameId, NameIdKey } from '../base';
import type { Faction, Gender, Href, KeyBase, NameId, NameIdKey, Realm } from '../base';

export interface AccountProfileSummaryResponse {
_links: Links;
Expand All @@ -18,10 +18,6 @@ interface WowAccount {
id: number;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character {
character: Href;
faction: Faction;
Expand Down
14 changes: 14 additions & 0 deletions packages/wow/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,17 @@ export interface Faction {
name: Capitalize<Lowercase<keyof typeof Factions>>;
type: keyof typeof Factions;
}

/**
* The standard structure to represent a World of Warcraft Realm.
*/
export interface Realm extends NameIdKey {
slug: string;
}

/**
* The standard structure to represent a World of Warcraft Character.
*/
export interface Character extends NameIdKey {
realm: Realm;
}
10 changes: 1 addition & 9 deletions packages/wow/src/character-achievements/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Href, NameIdKey, ResponseBase } from '../base';
import type { Character, Href, NameIdKey, ResponseBase } from '../base';

export interface CharacterAchievementsSummaryResponse extends ResponseBase {
achievements: Array<Achievement>;
Expand All @@ -17,14 +17,6 @@ interface Achievement {
id: number;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}

interface Criteria {
amount?: number;
child_criteria?: Array<Criteria>;
Expand Down
6 changes: 1 addition & 5 deletions packages/wow/src/character-appearance/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Color, Faction, Gender, KeyBase, NameId, NameIdKey, ResponseBase } from '../base';
import type { Character, Color, Faction, Gender, KeyBase, NameId, NameIdKey, ResponseBase } from '../base';

export interface CharacterAppearanceResponse extends ResponseBase {
active_spec: NameIdKey;
Expand All @@ -12,10 +12,6 @@ export interface CharacterAppearanceResponse extends ResponseBase {
playable_race: NameIdKey;
}

interface Character extends NameIdKey {
realm: { slug: string } & NameIdKey;
}

interface Customization {
choice: Choice;
option: NameId;
Expand Down
10 changes: 1 addition & 9 deletions packages/wow/src/character-collections/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Href, KeyBase, NameIdKey, ResponseBase } from '../base';
import type { Character, Href, KeyBase, NameIdKey, ResponseBase } from '../base';

export interface CharacterCollectionsIndexResponse extends ResponseBase {
character: Character;
Expand All @@ -9,14 +9,6 @@ export interface CharacterCollectionsIndexResponse extends ResponseBase {
transmogs: Href;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}

export interface CharacterHeirloomsCollectionSummaryResponse extends ResponseBase {
heirlooms: Array<Heirloom>;
}
Expand Down
10 changes: 1 addition & 9 deletions packages/wow/src/character-encounters/types.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import type { Href, NameIdKey, ResponseBase } from '../base';
import type { Character, Href, NameIdKey, ResponseBase } from '../base';

export interface CharacterEncountersSummaryResponse extends ResponseBase {
character: Character;
dungeons: Href;
raids: Href;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}

export interface CharacterDungeonsResponse extends ResponseBase {
expansions: Array<Expansion<DungeonMode>>;
}
Expand Down
10 changes: 1 addition & 9 deletions packages/wow/src/character-equipment/types.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import type { Color, KeyBase, NameIdKey, ResponseBase } from '../base';
import type { Character, Color, KeyBase, NameIdKey, ResponseBase } from '../base';

export interface CharacterEquipmentSummaryResponse extends ResponseBase {
character: Character;
equipped_item_sets: Array<Set>;
equipped_items: Array<EquippedItem>;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}

interface Set {
display_string: string;
effects: Array<Effect>;
Expand Down
10 changes: 1 addition & 9 deletions packages/wow/src/character-hunter-pets/types.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import type { KeyBase, NameIdKey, ResponseBase } from '../base';
import type { Character, KeyBase, NameIdKey, ResponseBase } from '../base';

export interface CharacterHunterPetsSummaryResponse extends ResponseBase {
character: Character;
hunter_pets: Array<HunterPet>;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}

interface HunterPet {
creature: NameIdKey;
creature_display: { id: number } & KeyBase;
Expand Down
10 changes: 1 addition & 9 deletions packages/wow/src/character-media/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NameIdKey, ResponseBase } from '../base';
import type { Character, ResponseBase } from '../base';

export interface CharacterMediaSummaryResponse extends ResponseBase {
assets: Array<Asset>;
Expand All @@ -9,11 +9,3 @@ interface Asset {
key: string;
value: string;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}
10 changes: 1 addition & 9 deletions packages/wow/src/character-mythic-keystone-profile/types.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import type { Color, KeyBase, NameId, NameIdKey, ResponseBase } from '../base';
import type { Character, Color, KeyBase, NameId, NameIdKey, Realm, ResponseBase } from '../base';

export interface CharacterMythicKeystoneProfileIndexResponse extends ResponseBase {
character: Character;
current_period: CurrentPeriod;
seasons: Array<{ id: number } & KeyBase>;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}

interface CurrentPeriod {
period: { id: number } & KeyBase;
}
Expand Down
10 changes: 1 addition & 9 deletions packages/wow/src/character-professions/types.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import type { NameId, NameIdKey, ResponseBase } from '../base';
import type { Character, NameId, NameIdKey, ResponseBase } from '../base';

export interface CharacterProfessionsSummaryResponse extends ResponseBase {
character: Character;
primaries: Array<Primary>;
secondaries: Array<Secondary>;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}

interface Primary {
profession: NameIdKey;
tiers: Array<Tier>;
Expand Down
6 changes: 1 addition & 5 deletions packages/wow/src/character-profile/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Faction, Href, NameIdKey, ResponseBase } from '../base';
import type { Faction, Href, NameIdKey, Realm, ResponseBase } from '../base';

export interface CharacterProfileSummaryResponse extends ResponseBase {
achievement_points: number;
Expand Down Expand Up @@ -43,10 +43,6 @@ interface CovenantProgress {
soulbinds: Href;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Guild extends NameIdKey {
faction: Faction;
realm: Realm;
Expand Down
10 changes: 1 addition & 9 deletions packages/wow/src/character-pvp/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NameId, NameIdKey, ResponseBase } from '../base';
import type { Character, NameId, ResponseBase } from '../base';

export interface CharacterPvpSummaryResponse extends ResponseBase {
character: Character;
Expand All @@ -7,14 +7,6 @@ export interface CharacterPvpSummaryResponse extends ResponseBase {
pvp_map_statistics: Array<PvpMapStatistic>;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}

interface PvpMapStatistic {
match_statistics: MatchStatistics;
world_map: NameId;
Expand Down
12 changes: 2 additions & 10 deletions packages/wow/src/character-quests/types.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import type { Href, NameIdKey, ResponseBase } from '../base';
import type { Character, Href, NameIdKey, ResponseBase } from '../base';

export interface CharacterQuestsResponse extends ResponseBase {
character: Character;
completed: Href;
in_progress: Array<Character>;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
in_progress: Array<NameIdKey>;
}

export interface CharacterCompletedQuestsResponse extends ResponseBase {
Expand Down
10 changes: 1 addition & 9 deletions packages/wow/src/character-reputations/types.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import type { NameIdKey, ResponseBase } from '../base';
import type { Character, NameIdKey, ResponseBase } from '../base';

export interface CharacterReputationsSummaryResponse extends ResponseBase {
character: Character;
reputations: Array<Reputation>;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}

interface Reputation {
faction: NameIdKey;
paragon?: Paragon;
Expand Down
10 changes: 1 addition & 9 deletions packages/wow/src/character-soulbinds/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NameIdKey, ResponseBase } from '../base';
import type { Character, NameIdKey, ResponseBase } from '../base';

export interface CharacterSoulbindsResponse extends ResponseBase {
character: Character;
Expand All @@ -7,14 +7,6 @@ export interface CharacterSoulbindsResponse extends ResponseBase {
soulbinds: Array<Soulbind>;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}

interface Soulbind {
is_active?: boolean;
soulbind: NameIdKey;
Expand Down
10 changes: 1 addition & 9 deletions packages/wow/src/character-specializations/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NameIdKey, ResponseBase } from '../base';
import type { Character, NameIdKey, ResponseBase } from '../base';

export interface CharacterSpecializationsSummaryResponse extends ResponseBase {
//TODO Awaiting The War Within launch to see how to type this
Expand All @@ -8,14 +8,6 @@ export interface CharacterSpecializationsSummaryResponse extends ResponseBase {
specializations: Array<Specialization>;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}

interface Specialization {
glyphs?: Array<NameIdKey>;
loadouts: Array<Loadout>;
Expand Down
10 changes: 1 addition & 9 deletions packages/wow/src/character-statistics/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NameIdKey, ResponseBase } from '../base';
import type { Character, ResponseBase } from '../base';

export interface CharacterStatisticsSummaryResponse extends ResponseBase {
agility: BaseEffectiveStat;
Expand Down Expand Up @@ -58,11 +58,3 @@ interface RatingWithValue {
rating_bonus: number;
value: number;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}
10 changes: 1 addition & 9 deletions packages/wow/src/character-titles/types.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import type { NameIdKey, ResponseBase } from '../base';
import type { Character, NameIdKey, ResponseBase } from '../base';

export interface CharacterTitlesSummaryResponse extends ResponseBase {
active_title: { display_string: string } & NameIdKey;
character: Character;
titles: Array<NameIdKey>;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}
Loading

0 comments on commit dd401e4

Please sign in to comment.