import { injectable } from "inversify" ; import type { Card } from "./Card" ; export type CardPredicate = ( card : Card ) => boolean ; export type CardCountFunction = ( card : Card ) => number ; @ injectable ( ) export class CardPredicateService { return createAtLeastOneAvailablePredicate ( cardCodeFunction ) { return ( card ) => cardCodeFunction ( card ) > 0 ; } return createAddableInAtLeastOneDeckPartCardPredicate ( ) { return ( card ) => card . type . deckParts . size > 0 ; } return createUniqueByNameCardPredicate ( ) { const seenNames = new Set < string > ( ) ; return ( card ) => { if ( seenNames . has ( card . name ) ) { return false ; } seenNames . add ( card . name ) ; return true ; } ; } }