Search in sources :

Example 26 with FilterCard

use of mage.filter.FilterCard in project mage by magefree.

the class DevelopmentEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (controller.chooseUse(Outcome.Benefit, staticText + "?", source, game)) {
            Cards cards = controller.getSideboard();
            if (cards.isEmpty()) {
                game.informPlayer(controller, "You have no cards outside the game.");
                return true;
            }
            TargetCard target = new TargetCard(0, 4, Zone.OUTSIDE, new FilterCard("cards you own from outside the game"));
            target.setNotTarget(true);
            if (controller.choose(Outcome.Benefit, controller.getSideboard(), target, game)) {
                controller.shuffleCardsToLibrary(new CardsImpl(target.getTargets()), game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) TargetCard(mage.target.TargetCard)

Example 27 with FilterCard

use of mage.filter.FilterCard in project mage by magefree.

the class SadisticSacramentEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    Player player = game.getPlayer(source.getControllerId());
    if (player != null && targetPlayer != null) {
        TargetCardInLibrary target = new TargetCardInLibrary(0, amount, new FilterCard("cards to exile"));
        if (player.searchLibrary(target, source, game, targetPlayer.getId())) {
            List<UUID> targets = target.getTargets();
            for (UUID targetId : targets) {
                Card card = targetPlayer.getLibrary().remove(targetId, game);
                if (card != null) {
                    card.moveToExile(null, "", source, game);
                }
            }
        }
        targetPlayer.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 28 with FilterCard

use of mage.filter.FilterCard in project mage by magefree.

the class RushedRebirthDelayedTriggeredAbility method makeEffect.

private static Effect makeEffect(Permanent permanent) {
    FilterCard filter = new FilterCreatureCard("creature card with lesser mana value than " + permanent.getIdName());
    filter.add(new RushedRebirthPredicate(permanent));
    return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), true);
}
Also used : FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Example 29 with FilterCard

use of mage.filter.FilterCard in project mage by magefree.

the class SecretSalvageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
        Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
        if (targetCard != null) {
            controller.moveCards(targetCard, Zone.EXILED, source, game);
            String nameToSearch = CardUtil.getCardNameForSameNameSearch(targetCard);
            FilterCard nameFilter = new FilterCard();
            nameFilter.add(new NamePredicate(nameToSearch));
            TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, nameFilter);
            if (controller.searchLibrary(target, source, game)) {
                if (!target.getTargets().isEmpty()) {
                    Cards cards = new CardsImpl();
                    for (UUID cardId : target.getTargets()) {
                        Card card = controller.getLibrary().remove(cardId, game);
                        if (card != null) {
                            cards.add(card);
                        }
                    }
                    controller.revealCards(sourceObject.getIdName(), cards, game);
                    controller.moveCards(cards, Zone.HAND, source, game);
                }
                controller.shuffleLibrary(source, game);
                return true;
            }
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) MageObject(mage.MageObject) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) FilterNonlandCard(mage.filter.common.FilterNonlandCard)

Example 30 with FilterCard

use of mage.filter.FilterCard in project mage by magefree.

the class SehtsTigerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject mageObject = game.getObject(source.getSourceId());
    ChoiceColor choice = new ChoiceColor();
    if (controller != null && mageObject != null && controller.choose(Outcome.Protect, choice, game)) {
        game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
        FilterCard filter = new FilterCard();
        filter.add(new ColorPredicate(choice.getColor()));
        filter.setMessage(choice.getChoice());
        Ability ability = new ProtectionAbility(filter);
        game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) FlashAbility(mage.abilities.keyword.FlashAbility) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) MageObject(mage.MageObject) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) ChoiceColor(mage.choices.ChoiceColor) GainAbilityControllerEffect(mage.abilities.effects.common.continuous.GainAbilityControllerEffect)

Aggregations

FilterCard (mage.filter.FilterCard)337 Player (mage.players.Player)287 Card (mage.cards.Card)148 TargetCard (mage.target.TargetCard)127 UUID (java.util.UUID)97 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)87 Permanent (mage.game.permanent.Permanent)79 MageObject (mage.MageObject)75 CardsImpl (mage.cards.CardsImpl)75 Cards (mage.cards.Cards)60 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)56 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)54 Target (mage.target.Target)41 TargetCardInHand (mage.target.common.TargetCardInHand)41 TargetPlayer (mage.target.TargetPlayer)35 ApprovingObject (mage.ApprovingObject)29 FilterCreatureCard (mage.filter.common.FilterCreatureCard)25 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)24 TargetCardInGraveyard (mage.target.common.TargetCardInGraveyard)22 ArrayList (java.util.ArrayList)21