export interface ForeignData {
  flavorText: string;
  language: string;
  multiverseId: number;
  name: string;
  text: string;
  type: string;
}

export interface Legalities {
  commander: string;
  duel: string;
  legacy: string;
  modern: string;
  vintage: string;
}

export interface Prices {
  mtgo: Record<string, number>;
  mtgoFoil: Record<string, number>;
  paper: Record<string, number>;
  paperFoil: Record<string, number>;
}

export interface PurchaseUrls {
  cardmarket: string;
  tcgplayer: string;
}

export interface MCMCard {
  artist: string;
  borderColor: string;
  colorIdentity: string[];
  colors: string[];
  convertedManaCost: number;
  edhrecRank: number;
  flavorText: string;
  foreignData: ForeignData[];
  frameVersion: string;
  hasFoil: boolean;
  hasNonFoil: boolean;
  isMtgo: boolean;
  isPaper: boolean;
  layout: string;
  legalities: Legalities;
  manaCost: string;
  mcmId: number;
  mcmMetaId: number;
  mtgoFoilId: number;
  mtgoId: number;
  multiverseId: number;
  name: string;
  number: string;
  originalText: string;
  originalType: string;
  power: string;
  prices: Prices;
  printings: string[];
  purchaseUrls: PurchaseUrls;
  rarity: string;
  rulings: any[];
  scryfallId: string;
  scryfallIllustrationId: string;
  scryfallOracleId: string;
  scryfallImageUrl: string;
  scryfallUrl: string;
  subtypes: string[];
  supertypes: any[];
  tcgplayerProductId: number;
  text: string;
  toughness: string;
  type: string;
  types: string[];
  uuid: string;
  set: string;
}

export type MCMDB = Record<string, MCMCard>;

// Lighther version of MCMCard without a lot of useless information
export interface LeanMCMCard {
  colorIdentity: string[];
  colors: string[];
  convertedManaCost: number;
  edhrecRank: number;
  manaCost: string;
  mcmId: number;
  name: string;
  rarity: string;
  scryfallId: string;
  scryfallImageUrl: string;
  scryfallUrl: string;
  subtypes: string[];
  supertypes: any[];
  text: string;
  type: string;
  types: string[];
  set: string;
  number: string;
}

export interface Language {
  idLanguage: number;
  languageName: string;
}

export interface Link {
  rel: string;
  href: string;
  method: string;
  action: string;
  idArticle?: number;
}

export interface Article {
  idArticle: number;
  idProduct: number;
  language: Language;
  comments: string;
  price: number;
  count: number;
  inShoppingCart: boolean;
  condition: string;
  isFoil: boolean;
  isSigned: boolean;
  isPlayset: boolean;
  isAltered: boolean;
  links: Link[];
}

export interface LeanArticle {
  idArticle: number;
  language: string;
  comments: string;
  price: number;
  count: number;
  condition: string;
}

export type CardItem = LeanMCMCard & LeanArticle;

export interface ImageUris {
  small: string;
  normal: string;
  large: string;
  png: string;
  art_crop: string;
  border_crop: string;
}

export interface Legalities {
  standard: string;
  future: string;
  historic: string;
  pioneer: string;
  modern: string;
  legacy: string;
  pauper: string;
  vintage: string;
  penny: string;
  commander: string;
  brawl: string;
  duel: string;
  oldschool: string;
}

export interface RelatedUris {
  tcgplayer_decks: string;
  edhrec: string;
  mtgtop8: string;
}

export interface CardFace {
  object: string;
  name: string;
  mana_cost: string;
  type_line: string;
  oracle_text: string;
  colors: string[];
  power: string;
  toughness: string;
  artist: string;
  artist_id: string;
  illustration_id: string;
  image_uris: ImageUris;
  color_indicator: string[];
  loyalty: string;
}

export interface ScryfallCard {
  object: string;
  id: string;
  oracle_id: string;
  multiverse_ids: any[];
  tcgplayer_id: number;
  name: string;
  lang: string;
  released_at: string;
  uri: string;
  scryfall_uri: string;
  layout: string;
  highres_image: boolean;
  image_uris: ImageUris;
  card_faces?: CardFace[];
  mana_cost: string;
  cmc: number;
  type_line: string;
  oracle_text: string;
  colors: any[];
  color_identity: string[];
  legalities: Legalities;
  games: string[];
  reserved: boolean;
  foil: boolean;
  nonfoil: boolean;
  oversized: boolean;
  promo: boolean;
  reprint: boolean;
  variation: boolean;
  set: string;
  set_name: string;
  set_type: string;
  set_uri: string;
  set_search_uri: string;
  scryfall_set_uri: string;
  rulings_uri: string;
  prints_search_uri: string;
  collector_number: string;
  digital: boolean;
  rarity: string;
  card_back_id: string;
  artist: string;
  artist_ids: string[];
  illustration_id: string;
  border_color: string;
  frame: string;
  full_art: boolean;
  textless: boolean;
  booster: boolean;
  story_spotlight: boolean;
  edhrec_rank: number;
  related_uris: RelatedUris;
}

export type ScryfallDB = ScryfallCard[];
