diff --git a/__tests__/basic.test.ts b/__tests__/basic.test.ts index 96f2f6c..dac9cea 100644 --- a/__tests__/basic.test.ts +++ b/__tests__/basic.test.ts @@ -151,3 +151,10 @@ test(`random card/set/serie`, async () => { expect((await tcgdex.random.set())).toBeTruthy() expect((await tcgdex.random.serie())).toBeTruthy() }) + +test(`Variant Detailed`, async () => { + const tcgdex = new TCGdex('en') + TCGdex.fetch = fetch + + expect((await tcgdex.card.get('me02-001'))?.variantsDetailed?.[0].type).toBeTruthy() +}) diff --git a/src/models/Card.ts b/src/models/Card.ts index d46e040..e57819a 100644 --- a/src/models/Card.ts +++ b/src/models/Card.ts @@ -1,5 +1,6 @@ +import { objectLoop } from '@dzeio/object-util' import CardResume from './CardResume' -import type { Booster, Variants } from './Other' +import type { Booster, Variants, VariantsDetailed } from './Other' import type TCGdexSet from './Set' import type SetResume from './SetResume' @@ -33,9 +34,15 @@ export default class Card extends CardResume { /** * Card Variants (Override Set Variants) + * @deprecated Use `variantsDetailed` when possible */ public variants?: Variants + /** + * A second generation variants system that will replace the previous one at [variants] in v3 + */ + public variantsDetailed?: Array + /** * Card Set */ @@ -197,4 +204,13 @@ export default class Card extends CardResume { public async getSet(): Promise { return (await this.sdk.set.get(this.set.id))! } + + protected override fill(obj: object): void { + objectLoop(obj, (value, key: string) => { + if (key === 'variants_detailed') { + key = 'variantsDetailed' + } + (this as any)[key] = value + }) + } } diff --git a/src/models/Other.d.ts b/src/models/Other.d.ts index 2c0441d..00c8b8f 100644 --- a/src/models/Other.d.ts +++ b/src/models/Other.d.ts @@ -12,4 +12,63 @@ export interface Booster { logo?: string artwork_front?: string artwork_back?: string -} \ No newline at end of file +} + +/** + * A better version of variants with additionnal details on each variants + */ +export interface VariantsDetailed { + /** + * define the variant type + * - normal: no holographic elements + * - holo: the illustration has a foil + * - reverse: everything but the illustration is foiled + */ + type: string + /** + * Some older sets had specific subtypes for the cards + * i.e Base Set had shadowless with and without a 1st-edition stamp. + * and the Unlimited version of the set had no shadow. + */ + subtype?: string + /** + * define the size of the card + * - standard: the classic size of a card + * - jumbo: also said oversized, big card. + */ + size?: string + /** + * indicate that this variant has stamps + * a card may have multiple stamps, example "Ethan's Typhlosion pre-release staff" + * this was a pre-release card only given to staff and has both the set-logo and the staff stamp. + * - 1st-edition: a 1st-edition card (mostly for the first series of the game) + * - w-promo: + * - pre-release: + * - pokemon-center: a card that is stamped with the Pokémon Center logo + * - set-promo: a card that is stamped with the set logo + * - staff: a card that is stamped with the staff text + * - gamestop: a card that is stamped with the GameStop logo + * - eb-games: a card that is stamped with the EB Games logo + * - snowflake: a card that is stamped with a snowflake, available in the yearly advent calendar + * - trick-or-trade: a card that is stamped with a pikachu-pumpkin, available in the yearly halloween/trick-or-trade boosters + * - ace-trainer: a card that is stamped with a golden ACE TRAINER, won by getting 200 championship points in the season since 2025 season. + * - player-rewards-program: a card that is stamped with the player reward logo, available in the yearly player rewards program (play! pokemon prize pack) + * - etc... + */ + stamp?: Array + /** + * for the holo & reverse, **optional** indicate which foil is used on the card + */ + foil?: string + /** + * IDs from third part websites + */ + thirdParty?: { + cardmarket?: number + tcgplayer?: number + } + /** + * A unique ID defining this variant + */ + variantId: string +}