1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-07-03 08:59:18 +00:00
This commit is contained in:
2025-05-22 17:30:40 +02:00
parent 5f5afdea80
commit 615a1d23b5
2 changed files with 374 additions and 143 deletions

364
interfaces.d.ts vendored
View File

@ -1,11 +1,100 @@
export type SupportedLanguages =
// inter languages
'en' | 'fr' | 'es' | 'es-mx' | 'it' | 'pt' | 'pt-br' | 'pt-pt' | 'de' | 'nl' | 'pl' | 'ru' |
// Asian languages
'ja' | 'ko' | 'zh-tw' | 'id' | 'th' | 'zh-cn'
| 'en' // English en-US
| 'fr' // French fr-FR
| 'es' // Spanish es-ES
| 'es-mx' // Latin America Spanish es-MX
| 'it' // Italian it-IT
| 'pt' // a merge of `pt-br` & `pt-pt`
| 'pt-br' // Brazilian Portuguese pt-BR
| 'pt-pt' // Portugal Portuguese pt-PT
| 'de' // German de-DE
| 'nl' // Dutch nl-NL
| 'pl' // Polish pl-PL
| 'ru' // Russian ru-RU
// Asian languages
| 'ja' // Japanese ja-JP
| 'ko' // korean ko-KO
| 'zh-tw' // Traditionnal Chinese zh-TW
| 'id' // Indonesian id-ID
| 'th' // Thai th-TH
| 'zh-cn' // Simplified Chinese zh-CN
/**
* The list of Pokémon types
*/
export type Types =
| 'Grass'
| 'Fire'
| 'Water'
| 'Lightning'
| 'Psychic'
| 'Fighting'
| 'Darkness'
| 'Metal'
| 'Dragon'
| 'Fairy'
| 'Colorless'
export type Rarity =
| 'ACE SPEC Rare'
| 'Amazing Rare'
| 'Classic Collection'
| 'Common'
| 'Double rare'
| 'Full Art Trainer'
| 'Holo Rare'
| 'Holo Rare V'
| 'Holo Rare VMAX'
| 'Holo Rare VSTAR'
| 'Hyper rare'
| 'Illustration rare'
| 'LEGEND'
| 'None'
| 'Radiant Rare'
| 'Rare'
| 'Rare Holo'
| 'Rare Holo LV.X'
| 'Rare PRIME'
| 'Secret Rare'
| 'Shiny Ultra Rare'
| 'Shiny rare'
| 'Shiny rare V'
| 'Shiny rare VMAX'
| 'Special illustration rare'
| 'Ultra Rare'
| 'Uncommon'
// Pokémon TCG Pocket Rarities
| 'One Diamond'
| 'Two Diamond'
| 'Three Diamond'
| 'Four Diamond'
| 'One Star'
| 'Two Star'
| 'Three Star'
| 'Crown'
| 'One Shiny'
| 'Two Shiny'
/**
* utility to help in multi language strings
*/
export type Languages<T = string> = Partial<Record<SupportedLanguages, T>>
/**
* Helper to define an ISO date
*/
type ISODate = `${number}-${number}-${number}`
/**
* Definition of a serie
*/
export interface Serie {
id: string
name: Languages
@ -16,49 +105,6 @@ export interface Serie {
energies?: Array<Types>
}
interface variants {
/**
* Card base version
*/
normal?: boolean
/**
* Holo Reverse
* (colored Background holographic)
*/
reverse?: boolean
/**
* Holo Card
* (illustration holographic)
*/
holo?: boolean
/**
* can have a first Edition stamp
*/
firstEdition?: boolean
/**
* Can be found in Jumob Format
*/
jumbo?: boolean
/**
* Card has a pre-release stamp
*/
preRelease?: boolean
/**
* Card has a W stamp
*/
wPromo?: true
}
export type Types = 'Colorless' | 'Darkness' | 'Dragon' |
'Fairy' | 'Fighting' | 'Fire' |
'Grass' | 'Lightning' | 'Metal' |
'Psychic' | 'Water'
type ISODate = `${number}-${number}-${number}`
export interface Set {
id: string
@ -81,17 +127,55 @@ export interface Set {
releaseDate: ISODate | Languages<ISODate>
}
export interface Card {
type VariantShortcut =
| 'normal' // = { type: 'normal' }
| 'foil'
| 'reverse'
type VariantDefinition = {
/**
* if not set it is `normal`
*/
type?: 'normal' | 'holo' | 'reverse'
size?:
| 'jumbo'
| 'standard'
stamp?: '1st edition' | 'w-promo' | 'pre-release'
} & ({
type: 'holo'
foil?: string
} | {
type: 'reverse'
foil?: 'pokeball' | 'hyperball'
})
type Variant = VariantShortcut | VariantDefinition
/**
* base interface with everything in common between cards
*/
interface BaseCard {
/**
* Card Name (Including the suffix if next to card name)
*/
name: Languages
subtitle?: Languages
/**
* the card number
*/
number?: string
/**
* Card illustrator
*/
illustrator?: string
copyright?: {
text: Language
year?: number
}
/**
* indicate in which boosters the card is available
*/
@ -134,28 +218,12 @@ export interface Card {
* - Ultra Rare: https://www.tcgdex.net/database/Sword-&-Shield/Shining-Fates/18-Cinderace-V
* - Uncommon: https://www.tcgdex.net/database/Sword-&-Shield/Darkness-Ablaze/136-Furret
*/
rarity: 'ACE SPEC Rare' | 'Amazing Rare' | 'Classic Collection' | 'Common' |
'Double rare' | 'Full Art Trainer' | 'Holo Rare' | 'Holo Rare V' |
'Holo Rare VMAX' | 'Holo Rare VSTAR' | 'Hyper rare' | 'Illustration rare' |
'LEGEND' | 'None' | 'Radiant Rare' | 'Rare' | 'Rare Holo' | 'Rare Holo LV.X' |
'Rare PRIME' | 'Secret Rare' | 'Shiny Ultra Rare' | 'Shiny rare' | 'Shiny rare V' |
'Shiny rare VMAX' | 'Special illustration rare' | 'Ultra Rare' | 'Uncommon' |
// Pokémon TCG Pocket Rarities
'One Diamond' | 'Two Diamond' | 'Three Diamond' | 'Four Diamond' | 'One Star' | 'Two Star' | 'Three Star' | 'Crown' | 'One Shiny' | 'Two Shiny'
rarity?: Rarity
/**
* Card Category
*
* - Pokemon
* - Trainer
* - Energy
* Card Variants
*/
category: 'Pokemon' | 'Trainer' | 'Energy'
/**
* Card Variants (Override Set Variants)
*/
variants?: variants
variants?: Array<Variant>
/**
* Card Set
@ -170,45 +238,17 @@ export interface Card {
regulationMark?: string
/**
* Pokemon only elements
* indicate the pokémons that are present on the card graphic
*/
pokemons?: Array<string | {
name: string
isShiny?: boolean
}>
}
/**
* Pokemon Pokedex ID
*/
dexId?: Array<number>
/**
* Pokemon HP
*/
hp?: number
/**
* Pokemon Types
*/
types?: Array<Types> // ex for multiple https://www.tcgdex.net/database/ex/ex13/17
/**
* Pokemon Sub Evolution
*/
evolveFrom?: Languages
/**
* Pokemon Weight
*/
weight?: string
/**
* Pokemon Description
*/
description?: Languages
/**
* Level of the Pokemon
*
* NOTE: can be equal to 'X' when the pokemon is a LEVEL-UP one
*/
level?: number | string
export interface PokemonCard extends BaseCard {
category: 'Pokemon'
/**
* Pokemon Stage
@ -239,6 +279,43 @@ export interface Card {
*/
suffix?: 'EX' | 'GX' | 'V' | 'Legend' | 'Prime' | 'SP' | 'TAG TEAM-GX'
/**
* Pokemon HP
*/
hp?: number
/**
* Pokemon Types
*/
types?: Array<Types> // ex for multiple https://www.tcgdex.net/database/ex/ex13/17
/**
* Pokemon Pokedex ID
*/
dexId?: Array<number>
/**
* Pokemon Sub Evolution
*/
evolveFrom?: Languages
/**
* Pokemon Weight
*/
weight?: string
/**
* Pokemon Description
*/
description?: Languages
/**
* Level of the Pokemon
*
* NOTE: can be equal to 'X' when the pokemon is a LEVEL-UP one
*/
level?: number | string
/**
* Pokemon Held Item
*
@ -271,38 +348,63 @@ export interface Card {
}>
/**
* Pokemon Weaknesses
* The Pokémon Weakness
*
* Old cards don't have text with their weakness, but the rules indicate that it does `x2`
*/
weaknesses?: Array<{
type: Types
value?: string
}>
resistances?: Array<{
type: Types
value?: string
}>
retreat?: number
//Trainer/Energy
effect?: Languages
// Trainer Only
trainerType?: 'Supporter' | // https://www.tcgdex.net/database/ex/ex7/83
'Item' | // https://www.tcgdex.net/database/ex/ex7/89
'Stadium' | // https://www.tcgdex.net/database/ex/ex7/87
'Tool' | // https://www.tcgdex.net/database/neo/neo1/93
'Ace Spec' | // https://www.tcgdex.net/database/bw/bw7/139
'Technical Machine' | // https://www.tcgdex.net/database/ecard/ecard1/144
'Goldenrod Game Corner' | // https://www.tcgdex.net/database/neo/neo1/83
'Rocket\'s Secret Machine' // https://www.tcgdex.net/database/ex/ex7/84
// Energy Only
energyType?: 'Normal' | // https://www.tcgdex.net/database/ecard/ecard1/160
'Special' // https://www.tcgdex.net/database/ecard/ecard1/158
weakness?: {
/**
* the list of types the pokemon is weak to
*/
types: Array<Types>
/**
* the full line text of the weakness (exlucding types)
*/
text?: string
}
resistance?: {
types: Array<Types>
text: string
}
/**
* The retreat count of the card
*/
retreat?: number
}
export interface TrainerCard extends BaseCard {
category: 'Trainer'
effect?: Languages
/**
* Pokemon HP
*/
hp?: number
// Trainer Only
trainerType?: 'Supporter' // https://www.tcgdex.net/database/ex/ex7/83
| 'Item' // https://www.tcgdex.net/database/ex/ex7/89
| 'Stadium' // https://www.tcgdex.net/database/ex/ex7/87
| 'Tool' // https://www.tcgdex.net/database/neo/neo1/93
| 'Ace Spec' // https://www.tcgdex.net/database/bw/bw7/139
| 'Technical Machine' // https://www.tcgdex.net/database/ecard/ecard1/144
| 'Goldenrod Game Corner' // https://www.tcgdex.net/database/neo/neo1/83
| 'Rocket\'s Secret Machine' // https://www.tcgdex.net/database/ex/ex7/84
}
export interface EnergyCard extends BaseCard {
category: 'Energy'
effect?: Languages
// Energy Only
energyType?: 'Normal' // https://www.tcgdex.net/database/ecard/ecard1/160
| 'Special' // https://www.tcgdex.net/database/ecard/ecard1/158
}
export type Card = PokemonCard | TrainerCard | EnergyCard
/**
* Filter for cards legality
*/

View File

@ -162,6 +162,7 @@ export interface Card extends CardResume {
* - Secret Rare
*/
rarity: string;
// rarity: { icon: string, designation: string }
/**
* Card Category
*
@ -169,11 +170,44 @@ export interface Card extends CardResume {
* - Trainer
* - Energy
*/
category: string;
category: string
/**
* Card Variants (Override Set Variants)
* Card Variants
* @deprecated `variants` is deprecated in favor of the current `variants_detailed` that contains more informations & is WAY more precise
*/
variants?: variants;
variants?: variants
/**
* define the list of variants the card is available in
*/
variants_detailed?: Array<{
/**
* define the variant type
* - normal: no holographic elements
* - holo: the illustration has a foil
* - reverse: everything but the illustration is foiled
*/
type: 'normal' | 'holo' | 'reverse'
/**
* define the size of the card
* - standard: the classic size of a card
* - jumbo: also said oversized, big card.
*/
size?: 'standard' | 'jumbo'
/**
* indicate that this variant has a stamp
* - 1st edition: a 1st edition card (mostly for the first serie of the game)
* - w-promo:
* - pre-release:
*/
stamp?: '1st edition' | 'w-promo' | 'pre-release'
/**
* for the holo & reverse, **optionnnal** indicate which foil is used on the card
*/
foil?: 'pokeball' | 'hyperball'
}>
/**
* Card Set
*/
@ -260,22 +294,71 @@ export interface Card extends CardResume {
* Pokemon Attacks
*/
attacks?: Array<{
cost?: Array<string>;
name: string;
effect?: string;
damage?: string | number;
cost?: Array<string>
/**
* the attack name
*/
name: string
/**
* the attack effect
*/
effect?: string
/**
* The damage text or number
*/
damage?: string | number
/**
* the damage amount as a number
*/
amount?: number
/**
* the damage operator as a standardized character
*/
operator?: '+' | 'x' | '-'
}>;
/**
* Pokemon Weaknesses
*/
weaknesses?: Array<{
type: string;
value?: string;
}>;
/**
* Indicate the type the Pokémon is weak to
*/
type: string
/**
* the full line text of the weakness (excluding the type)
*/
value?: string
/**
* the amount as a number
* note: not set for old card but it is a `2`
*/
amount?: number
/**
* the operator
* note: not set for old cards, but it is a `x`
*/
operator?: '+' | 'x'
}>
resistances?: Array<{
type: string;
value?: string;
}>;
/**
* Indicate the type the Pokémon resist
*/
type: string
/**
* the full line text of the resistance (excluding the type)
*/
value: string
/**
* the amount as a number
*/
amount: number
/**
* the operator, currently always a `-`
*/
operator: '-'
}>
retreat?: number;
effect?: string;
trainerType?: string;
@ -293,11 +376,11 @@ export interface Card extends CardResume {
/**
* Ability to play in standard tournaments
*/
standard: boolean;
standard: boolean
/**
* Ability to play in expanded tournaments
*/
expanded: boolean;
expanded: boolean
}
/**
@ -305,6 +388,52 @@ export interface Card extends CardResume {
*/
boosters?: Array<Booster>
/**
* the list of Pokémons that appear on the card
*/
pokemons?: Array<{
/**
* the National Pokédex ID of the Pokémon
*
* note: you can then fetch aditionnal infos thorugh pokeapi.co like https://pokeapi.co/api/v2/pokemon/{id}
*/
id: number
/**
* The Pokémon name
*/
name: string
/**
* indicate if the pokémon is shiny or not
*/
isShiny?: true
}>
/**
* get the copyright informations about the card
*/
copyright?: {
text: string
year?: number
}
/**
* The card no.
*/
number: {
/**
* the first part of the no. (if there is no `/` it will include everything)
*/
nominator: string
/**
* a parseable area as a number (ex: 065 = 65, GG55 = 55)
*/
numeric: number
/**
* The second part of the no (skipped if there is no `/`)
*/
denominator?: string
}
updated: string
}