Search in sources :

Example 51 with FilterCreatureCard

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

the class InfernalOfferingReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Target target = new TargetOpponent(true);
        target.choose(Outcome.PutCreatureInPlay, source.getControllerId(), source.getSourceId(), game);
        Player opponent = game.getPlayer(target.getFirstTarget());
        target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
        if (target.choose(Outcome.PutCreatureInPlay, controller.getId(), source.getSourceId(), game)) {
            Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
            }
        }
        if (opponent != null) {
            target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
            if (target.choose(Outcome.PutCreatureInPlay, opponent.getId(), source.getSourceId(), game)) {
                Card card = opponent.getGraveyard().get(target.getFirstTarget(), game);
                if (card != null) {
                    opponent.moveCards(card, Zone.BATTLEFIELD, source, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetOpponent(mage.target.common.TargetOpponent) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 52 with FilterCreatureCard

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

the class JaradsOrdersEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterCreatureCard("creature cards"));
        if (controller.searchLibrary(target, source, game)) {
            if (!target.getTargets().isEmpty()) {
                Cards revealed = new CardsImpl();
                for (UUID cardId : target.getTargets()) {
                    Card card = controller.getLibrary().getCard(cardId, game);
                    revealed.add(card);
                }
                controller.revealCards("Jarad's Orders", revealed, game);
                if (target.getTargets().size() == 2) {
                    TargetCard target2 = new TargetCard(Zone.LIBRARY, filter);
                    controller.choose(Outcome.Benefit, revealed, target2, game);
                    Card card = revealed.get(target2.getFirstTarget(), game);
                    controller.moveCards(card, Zone.HAND, source, game);
                    revealed.remove(card);
                    Set<Card> cards = revealed.getCards(game);
                    card = cards.isEmpty() ? null : cards.iterator().next();
                    controller.moveCards(card, Zone.GRAVEYARD, source, game);
                } else if (target.getTargets().size() == 1) {
                    Set<Card> cards = revealed.getCards(game);
                    Card card = cards.isEmpty() ? null : cards.iterator().next();
                    controller.moveCards(card, Zone.HAND, source, game);
                }
            }
            controller.shuffleLibrary(source, game);
            return true;
        }
        controller.shuffleLibrary(source, game);
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Set(java.util.Set) TargetCard(mage.target.TargetCard) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard)

Example 53 with FilterCreatureCard

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

the class MoorlandRescuerTarget method makeFilter.

private static FilterCard makeFilter(int xValue, Ability source, Game game) {
    FilterCard filter = new FilterCreatureCard("creature cards with total power " + xValue + " or less from your graveyard");
    filter.add(Predicates.not(new MageObjectReferencePredicate(source.getSourceObject(game), game)));
    return filter;
}
Also used : FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) MageObjectReferencePredicate(mage.filter.predicate.mageobject.MageObjectReferencePredicate)

Example 54 with FilterCreatureCard

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

the class TemptWithImmortalityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        returnCreatureFromGraveToBattlefield(controller, source, game);
        int opponentsReturnedCreatures = 0;
        for (UUID playerId : game.getOpponents(controller.getId())) {
            Player opponent = game.getPlayer(playerId);
            if (opponent != null) {
                FilterCard filter = new FilterCreatureCard("creature card from your graveyard");
                filter.add(new OwnerIdPredicate(opponent.getId()));
                Target targetCardOpponent = new TargetCardInGraveyard(filter);
                if (targetCardOpponent.canChoose(source.getSourceId(), opponent.getId(), game)) {
                    if (opponent.chooseUse(outcome, "Return a creature card from your graveyard to the battlefield?", source, game)) {
                        if (opponent.chooseTarget(outcome, targetCardOpponent, source, game)) {
                            Card card = game.getCard(targetCardOpponent.getFirstTarget());
                            if (card != null) {
                                opponentsReturnedCreatures++;
                                opponent.moveCards(card, Zone.BATTLEFIELD, source, game);
                            }
                        }
                    }
                }
            }
        }
        if (opponentsReturnedCreatures > 0) {
            for (int i = 0; i < opponentsReturnedCreatures; i++) {
                returnCreatureFromGraveToBattlefield(controller, source, game);
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) OwnerIdPredicate(mage.filter.predicate.card.OwnerIdPredicate) Target(mage.target.Target) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 55 with FilterCreatureCard

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

the class TrackersInstinctsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
        boolean creaturesFound = cards.count(StaticFilters.FILTER_CARD_CREATURE, game) > 0;
        if (!cards.isEmpty()) {
            controller.revealCards(source, cards, game);
            TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to put in hand"));
            if (creaturesFound && controller.choose(Outcome.DrawCard, cards, target, game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    controller.moveCards(card, Zone.HAND, source, game);
                    cards.remove(card);
                }
            }
            controller.moveCards(cards, Zone.GRAVEYARD, source, game);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Aggregations

FilterCreatureCard (mage.filter.common.FilterCreatureCard)69 Player (mage.players.Player)58 Card (mage.cards.Card)31 FilterCard (mage.filter.FilterCard)26 Permanent (mage.game.permanent.Permanent)22 UUID (java.util.UUID)17 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)17 TargetCard (mage.target.TargetCard)16 CardsImpl (mage.cards.CardsImpl)15 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)15 TargetCardInGraveyard (mage.target.common.TargetCardInGraveyard)14 MageObject (mage.MageObject)13 OwnerIdPredicate (mage.filter.predicate.card.OwnerIdPredicate)10 Target (mage.target.Target)10 HashSet (java.util.HashSet)8 Cards (mage.cards.Cards)8 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)7 Ability (mage.abilities.Ability)6 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)6 OneShotEffect (mage.abilities.effects.OneShotEffect)4