import { inject , injectable } from "inversify" ; import { YgoprodeckApiService } from "./YgoprodeckApiService" ; import { YGOPRODECK_INTERNAL_TYPES } from "../types" ; import type { CardDataLoaderService , CardSet , CardValues , UnlinkedCard , } from "@yugioh-deck-tool/core" ; import { FindCardBy } from "@yugioh-deck-tool/core" ; /**
 * Implementation of  CardDataLoaderService using  YgoprodeckApiService .
 * Can be used outside ygoprodeck.com.
  @ injectable ( ) export class YgoprodeckCardDataLoaderService implements CardDataLoaderService { readonly #ygoprodeckApiService : YgoprodeckApiService ; constructor ( @ inject ( YGOPRODECK_INTERNAL_TYPES . YgoprodeckApiService ) ygoprodeckApiService ) { this . #ygoprodeckApiService = ygoprodeckApiService ; } async getCard ( cardKey , findCardBy ) { if ( findCardBy == FindCardBy . PASSCODE ) { return this . #ygoprodeckApiService . getSingleCard ( { passcode : cardKey , format : null , includeAliased : true , } ) ; } else { return this . #ygoprodeckApiService . getSingleCard ( { fuzzyName : cardKey , sorting : "relevance" , format : null , includeAliased : false , } ) ; } } async getAllCards ( ) { return this . #ygoprodeckApiService . getCards ( { format : null , includeAliased : true , } ) ; } async getAllCardSets ( ) { return this . #ygoprodeckApiService . getCardSets ( ) ; } async getCardValues ( ) { return this . #ygoprodeckApiService . getCardValues ( ) ; } async getArchetypes ( ) { return this . #ygoprodeckApiService . getArchetypes ( ) ; } }