import { injectable } from "inversify" ; import type { Card } from "../Card" ; import { Format } from "../format/Format" ; import type { BanState } from "./BanState" ; import { DefaultBanState } from "./BanState" ; import type { BanlistInfo } from "./BanlistInfo" ; @ injectable ( ) export class BanlistService { /**
     * Formats which have a banlist. See  BanlistInfo .
      private static readonly BANLIST_FORMATS : Set < Format > = new Set ( [ Format . OCG , Format . TCG , Format . GOAT , ] ) ; param format return hasBanlist ( format ) { return BanlistService . BANLIST_FORMATS . has ( format ) ; } /**
     * Gets the  BanState of a card by format.
     *
     *  param card param format return getBanStateByFormat ( card , format ) { if ( format == null ) { return DefaultBanState . UNLIMITED ; } if ( ! card . formats . includes ( format ) ) { return DefaultBanState . BANNED ; } if ( ! this . hasBanlist ( format ) ) { return DefaultBanState . UNLIMITED ; } return card . banlist [ format as keyof BanlistInfo ] ; } }