-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add types for
/v2/achievements
, /v2/achievements/categories
and `…
…/v2/achievements/groups`
- Loading branch information
Showing
5 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@gw2api/types": patch | ||
--- | ||
|
||
Add types for `/v2/achievements`, `/v2/achievements/categories` and `/v2/achievements/groups` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import type { SchemaAfter, SchemaVersion } from "../schema"; | ||
|
||
/** | ||
* AchievementCategory as returned from `/v2/achievements/categories` | ||
* @see https://wiki.guildwars2.com/wiki/API:2/achievements/categories | ||
*/ | ||
export type AchievementCategory<Schema extends SchemaVersion> = | ||
Schema extends undefined ? AchievementCategory_Base : | ||
Schema extends SchemaAfter<'2022-03-23T19:00:00.000Z'> | 'latest' ? AchievementCategory_2022_03_23 : | ||
AchievementCategory_Base; | ||
|
||
|
||
interface AchievementCategory_Base { | ||
/** The id of the achievement category */ | ||
id: number; | ||
|
||
/** The name of the achievement category */ | ||
name: string; | ||
|
||
/** The description of the achievement category */ | ||
description: string; | ||
|
||
/** The icon of the achievement category */ | ||
icon: string; | ||
|
||
/** The order of the achievement category in which they appear in-game (ascending) */ | ||
order: number; | ||
|
||
/** List of achievement ids that are part of this achievement category */ | ||
achievements: number[]; | ||
} | ||
|
||
interface AchievementCategory_2022_03_23 extends Omit<AchievementCategory_Base, 'achievements'> { | ||
/** List of achievements that are currently part of this achievement category */ | ||
achievements: AchievementCategoryAchievement[]; | ||
|
||
/** List of achievements that will be part of this achievement category tomorrow, if this achievement category is on a rotation */ | ||
tomorrow?: AchievementCategoryAchievement[]; | ||
} | ||
|
||
interface AchievementCategoryAchievement { | ||
/** The id of the achievement */ | ||
id: number; | ||
|
||
/** Flags of the achievement */ | ||
flags?: ('PvE' | 'PvP' | 'WvW' | 'SpecialEvent')[]; | ||
|
||
/** The required level range for this achievement to be available in-game (both inclusive) */ | ||
level?: [number, number]; | ||
|
||
/** Required access to an extension for this achievement to be available in-game */ | ||
required_access?: { | ||
/** The extension for this requirement */ | ||
product: 'PathOfFire' | 'HeartOfThorns'; | ||
|
||
/** Condition for this extension */ | ||
condition: 'NoAccess' | 'HasAccess'; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* AchievementGroup as returned from `/v2/achievements/groups` | ||
* @see https://wiki.guildwars2.com/wiki/API:2/achievements/groups | ||
*/ | ||
export interface AchievementGroup { | ||
/** The id of the achievement group */ | ||
id: string; | ||
|
||
/** The name of the achievement group */ | ||
name: string; | ||
|
||
/** The description of the achievement group */ | ||
description: string; | ||
|
||
/** The order in-game (ascending) */ | ||
order: number; | ||
|
||
/** Achievement category ids that are part of this group */ | ||
categories: number[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Achievement as returned from `/v2/achievements` | ||
* @see https://wiki.guildwars2.com/wiki/API:2/achievements | ||
*/ | ||
export interface Achievement { | ||
/** The id of the achievement */ | ||
id: number; | ||
|
||
/** The name of the achievement */ | ||
name: string; | ||
|
||
/** Description of the achievement */ | ||
description: string; | ||
|
||
/** The icon of the achievement if different from the achievement category */ | ||
icon?: string; | ||
|
||
/** The type of the achievement */ | ||
type: 'Default' | 'ItemSet'; | ||
|
||
/** Achievement Flags */ | ||
flags: AchievementFlags[]; | ||
|
||
/** The description of the achievement when it is still locked */ | ||
locked_text: string; | ||
|
||
/** List of achievement ids that have to be completed before unlocking this achievement */ | ||
prerequisites?: number[]; | ||
|
||
/** Achievement requirement */ | ||
requirement: string; | ||
|
||
/** Achievement objectives */ | ||
bits?: AchievementBit[]; | ||
|
||
/** Final rewards */ | ||
rewards?: AchievementReward[]; | ||
|
||
/** Reward tiers */ | ||
tiers: AchievementTier[]; | ||
|
||
/** Maximum AP for repeatable achievements */ | ||
point_cap?: number; | ||
}; | ||
|
||
export type AchievementFlags = | ||
| 'Pvp' | ||
| 'CategoryDisplay' | ||
| 'MoveToTop' | ||
| 'IgnoreNearlyComplete' | ||
| 'Repeatable' | ||
| 'Hidden' | ||
| 'RequiresUnlock' | ||
| 'RepairOnLogin' | ||
| 'Daily' | ||
| 'Weekly' | ||
| 'Monthly' | ||
| 'Permanent' | ||
|
||
export type AchievementBit = | ||
| { type: 'Text', text: string } | ||
| { type: 'Item' | 'Skin' | 'Minipet', id: number } | ||
|
||
export type AchievementReward = | ||
| { type: 'Item', id: number, count: number } | ||
| { type: 'Title', id: number } | ||
| { type: 'Mastery', id: number, region: MasteryRegion } | ||
| { type: 'Coins', count: number } | ||
|
||
export type MasteryRegion = | ||
| 'Tyria' // core | ||
| 'Maguuma' // HoT | ||
| 'Desert' // PoF | ||
| 'Tundra' // Icebrood | ||
| 'Jade' // EoD | ||
| 'Sky' // SotO | ||
| 'Unknown'; // Non whitelisted regions for future expansions | ||
|
||
export type AchievementTier = { | ||
/** Number of objectives that need to be completed */ | ||
count: number; | ||
|
||
/** AP rewarded for this tier */ | ||
points: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters