import { SupplyCard } from "../dominion/supply-card" ; import { Cards } from "../utils/cards" ; export class Supply { constructor ( readonly supplyCards , readonly baneCard , readonly replacements ) { if ( supplyCards . length > 10 ) { throw new Error ( "Unable to create supply with more than 10 cards." ) ; } } getSupplyCardsWithBane ( ) { const cards = this . supplyCards . concat ( ) ; if ( this . baneCard ) { cards . push ( this . baneCard ) ; } return cards ; } static empty ( ) { return new Supply ( [ ] , null , Replacements . empty ( ) ) ; } } export class Replacements { constructor ( readonly replacements ) { } getReplacementsForId ( supplyCardId ) { return this . replacements . has ( supplyCardId ) ? this . replacements . get ( supplyCardId ) ! : [ ] ; } static empty ( ) { return new Replacements ( new Map ( ) ) ; } static createReplacementByRemoveCards ( replacements , cardIds ) { const newReplacements = new Map ( ) ; for ( let id of replacements . keys ( ) ) { newReplacements . set ( id , replacements . get ( id ) ! . filter ( Cards . filterByExcludedIds ( cardIds ) ) ) ; } return newReplacements ; } }