import { CardName } from './CardName' ; import { ICard } from './cards/ICard' ; import { ICardFactory } from './cards/ICardFactory' ; const CARD_RENAMES = new Map < string , CardName > ( [ ] ) ; export class Deck < T extends ICard > { public readonly factories : Map < CardName , ICardFactory < T > > ; constructor ( cards ) { this . factories = new Map ( cards . map ( ( cf ) => [ cf . cardName , cf ] ) ) ; } public findByCardName ( name ) { const updatedName = CARD_RENAMES . get ( name ) ; if ( updatedName !== undefined ) { name = updatedName ; } return this . factories . get ( name ) ; } }