Search in sources :

Example 16 with FilterPermanentCard

use of mage.filter.common.FilterPermanentCard in project mage by magefree.

the class PackHuntEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    FilterCard filter = new FilterPermanentCard();
    filter.add(new NamePredicate(permanent.getName()));
    return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, 3, filter), true).apply(game, source);
}
Also used : FilterCard(mage.filter.FilterCard) FilterPermanentCard(mage.filter.common.FilterPermanentCard) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) TargetCardInLibrary(mage.target.common.TargetCardInLibrary)

Example 17 with FilterPermanentCard

use of mage.filter.common.FilterPermanentCard in project mage by magefree.

the class LinSivviDefiantHeroEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int xCost = source.getManaCostsToPay().getX();
    FilterPermanentCard filter = new FilterPermanentCard("Rebel permanent card with mana value " + xCost + " or less");
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xCost + 1));
    filter.add(SubType.REBEL.getPredicate());
    TargetCardInLibrary target = new TargetCardInLibrary(filter);
    if (controller.searchLibrary(target, source, game)) {
        Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
        if (card != null) {
            controller.moveCards(card, Zone.BATTLEFIELD, source, game);
        }
        controller.shuffleLibrary(source, game);
        return true;
    }
    controller.shuffleLibrary(source, game);
    return false;
}
Also used : Player(mage.players.Player) FilterPermanentCard(mage.filter.common.FilterPermanentCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) FilterPermanentCard(mage.filter.common.FilterPermanentCard) Card(mage.cards.Card)

Example 18 with FilterPermanentCard

use of mage.filter.common.FilterPermanentCard in project mage by magefree.

the class ChaosWarpRevealEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
    if (permanent == null) {
        return false;
    }
    Player owner = game.getPlayer(permanent.getOwnerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (owner == null || sourceObject == null) {
        return false;
    }
    if (owner.getLibrary().hasCards()) {
        Card card = owner.getLibrary().getFromTop(game);
        if (card != null) {
            Cards cards = new CardsImpl(card);
            owner.revealCards(sourceObject.getIdName(), cards, game);
            if (new FilterPermanentCard().match(card, game)) {
                owner.moveCards(card, Zone.BATTLEFIELD, source, game);
            }
        }
    }
    return true;
}
Also used : Player(mage.players.Player) FilterPermanentCard(mage.filter.common.FilterPermanentCard) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) MageObject(mage.MageObject) FilterPermanentCard(mage.filter.common.FilterPermanentCard)

Example 19 with FilterPermanentCard

use of mage.filter.common.FilterPermanentCard in project mage by magefree.

the class AidFromTheCowlEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller == null || sourceObject == null) {
        return false;
    }
    if (controller.getLibrary().hasCards()) {
        Card card = controller.getLibrary().getFromTop(game);
        Cards cards = new CardsImpl(card);
        controller.revealCards(sourceObject.getIdName(), cards, game);
        if (card != null) {
            if (new FilterPermanentCard().match(card, game) && controller.chooseUse(Outcome.Neutral, "Put " + card.getIdName() + " onto the battlefield?", source, game)) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
            } else if (controller.chooseUse(Outcome.Neutral, "Put " + card.getIdName() + " on the bottom of your library?", source, game)) {
                controller.putCardsOnBottomOfLibrary(cards, game, source, false);
            } else {
                game.informPlayers(controller.getLogName() + " puts the revealed card back to the top of the library.");
            }
        }
    }
    return true;
}
Also used : Player(mage.players.Player) FilterPermanentCard(mage.filter.common.FilterPermanentCard) MageObject(mage.MageObject) FilterPermanentCard(mage.filter.common.FilterPermanentCard)

Aggregations

FilterPermanentCard (mage.filter.common.FilterPermanentCard)19 Player (mage.players.Player)16 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)12 FilterCard (mage.filter.FilterCard)11 Card (mage.cards.Card)9 Permanent (mage.game.permanent.Permanent)8 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)6 TargetCard (mage.target.TargetCard)5 CardsImpl (mage.cards.CardsImpl)4 TargetCardInHand (mage.target.common.TargetCardInHand)4 UUID (java.util.UUID)2 MageObject (mage.MageObject)2 SearchLibraryPutInPlayEffect (mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)2 Cards (mage.cards.Cards)2 FilterPermanent (mage.filter.FilterPermanent)2 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)2 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 ApprovingObject (mage.ApprovingObject)1 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)1 SpellAbility (mage.abilities.SpellAbility)1