Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions __tests__/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
18 changes: 17 additions & 1 deletion src/models/Card.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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<VariantsDetailed>

/**
* Card Set
*/
Expand Down Expand Up @@ -197,4 +204,13 @@ export default class Card extends CardResume {
public async getSet(): Promise<TCGdexSet> {
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
})
}
}
61 changes: 60 additions & 1 deletion src/models/Other.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,63 @@ export interface Booster {
logo?: string
artwork_front?: string
artwork_back?: string
}
}

/**
* 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<string>
/**
* 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
}