import { inject , injectable } from "inversify" ; import type { Card } from "@yugioh-deck-tool/core" ; import { CardDatabase , FindCardBy , TYPES } from "@yugioh-deck-tool/core" ; @ injectable ( ) export class TooltipController { private readonly cardDatabase : CardDatabase ; constructor ( @ inject ( TYPES . CardDatabase ) cardDatabase ) { this . cardDatabase = cardDatabase ; } param cardKey return async loadCard ( cardKey ) { let resolvedCardKey = await this . cardDatabase . prepareCard ( cardKey , FindCardBy . NAME ) ; if ( resolvedCardKey != null && this . cardDatabase . hasCard ( resolvedCardKey , FindCardBy . NAME ) ) { return this . cardDatabase . getCard ( resolvedCardKey , FindCardBy . NAME ) ! ; } resolvedCardKey = await this . cardDatabase . prepareCard ( cardKey , FindCardBy . PASSCODE ) ; if ( resolvedCardKey != null && this . cardDatabase . hasCard ( resolvedCardKey , FindCardBy . PASSCODE ) ) { return this . cardDatabase . getCard ( resolvedCardKey , FindCardBy . PASSCODE ) ! ; } throw new Error ( `Could not find card '${ cardKey }'.` ) ; } }