Search in sources :

Example 11 with SearchLibraryPutInHandEffect

use of mage.abilities.effects.common.search.SearchLibraryPutInHandEffect in project mage by magefree.

the class UrzasHotTubPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Cost cost : source.getCosts()) {
        if (cost instanceof DiscardTargetCost) {
            DiscardTargetCost discardCost = (DiscardTargetCost) cost;
            Card discardedCard = discardCost.getCards().get(0);
            if (discardedCard != null) {
                FilterCard filter = new FilterCard();
                filter.add(new UrzasHotTubPredicate(discardedCard.getName()));
                return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true).apply(game, source);
            }
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) Cost(mage.abilities.costs.Cost) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard)

Example 12 with SearchLibraryPutInHandEffect

use of mage.abilities.effects.common.search.SearchLibraryPutInHandEffect in project mage by magefree.

the class UrzasHotTubPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Cost cost : source.getCosts()) {
        if (cost instanceof DiscardTargetCost) {
            DiscardTargetCost discardCost = (DiscardTargetCost) cost;
            Card discardedCard = discardCost.getCards().get(0);
            if (discardedCard != null) {
                FilterCard filter = new FilterCard();
                filter.add(new UrzasHotTubPredicate(discardedCard.getName()));
                return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true).apply(game, source);
            }
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard)

Example 13 with SearchLibraryPutInHandEffect

use of mage.abilities.effects.common.search.SearchLibraryPutInHandEffect in project mage by magefree.

the class IsperiaTheInscrutableEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
    if (player != null && cardName != null) {
        player.revealCards(player.getLogName() + " hand", player.getHand(), game, true);
        for (Card card : player.getHand().getCards(game)) {
            if (CardUtil.haveSameNames(card, cardName, game)) {
                return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true).apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Aggregations

SearchLibraryPutInHandEffect (mage.abilities.effects.common.search.SearchLibraryPutInHandEffect)13 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)13 FilterCard (mage.filter.FilterCard)10 Player (mage.players.Player)7 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)5 Card (mage.cards.Card)4 MageObject (mage.MageObject)3 Cost (mage.abilities.costs.Cost)3 DiscardTargetCost (mage.abilities.costs.common.DiscardTargetCost)3 Permanent (mage.game.permanent.Permanent)3 TargetCardInHand (mage.target.common.TargetCardInHand)3 CardsImpl (mage.cards.CardsImpl)2 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)2 Target (mage.target.Target)2 Ability (mage.abilities.Ability)1 SpellAbility (mage.abilities.SpellAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)1 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)1