java.lang.Object
net.demilich.metastone.game.spells.desc.source.CardSource
All Implemented Interfaces:
Serializable, HasDesc<CardSourceDesc>
Direct Known Subclasses:
AftermathsCardSource, CatalogueSource, CombinedSource, DeckCollectionSource, DeckSource, FormatCatalogueSource, GraveyardActorsSource, GraveyardCardAndActorSourceCardSource, GraveyardCardsSource, GraveyardDiedMinionsSource, HandSource, MinionsSource, SecretSource, ShuffledCardsSource, StoredEntitiesSource, SummonWithoutReplacementCardSource, UncollectibleCatalogueSource, UnweightedCatalogueSource

public abstract class CardSource extends Object implements Serializable, HasDesc<CardSourceDesc>
See Also:
  • Constructor Details

  • Method Details

    • getArg

      public Object getArg(CardSourceArg arg)
    • hasArg

      public boolean hasArg(CardSourceArg arg)
    • getCards

      public CardList getCards(GameContext context, Entity source, Player player)
    • match

      protected abstract CardList match(GameContext context, Entity source, Player player)
      Overridden by card source implementations to return a list of cards that usually get filtered in an EntityFilter.

      See the implementations for examples of how, e.g. the graveyard is turned into a CardList instance by iterating through all the actors in the graveyard and retrieving their Entity.getSourceCard().

      Parameters:
      context - The game context
      source - The entity that is the origin of this matching operation
      player - The casting player
      Returns:
      A list of cards pre-filter.
    • match

      protected Stream<Card> match(GameContext context, Entity source, Player player, Predicate<Card> filter, int limit, boolean shuffled)
      Provides cards performantly, on demand, without having to iterate through the entire card catalogue for many kinds of sources.

      The implementations are responsible for providing an efficient answer.

      Parameters:
      context -
      source -
      player -
      limit -
      shuffled -
      Returns:
    • getTargetPlayer

      public TargetPlayer getTargetPlayer()
    • getDesc

      public CardSourceDesc getDesc()
      Specified by:
      getDesc in interface HasDesc<CardSourceDesc>
    • setDesc

      public void setDesc(Desc<?,?> desc)
      Specified by:
      setDesc in interface HasDesc<CardSourceDesc>