Search in sources :

Example 16 with FilterCreatureCard

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

the class CryptChampionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Set<Card> toBattlefield = new HashSet<>();
    if (controller != null) {
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                FilterCard filter = new FilterCreatureCard("creature card with mana value 3 or less from your graveyard");
                filter.add(new OwnerIdPredicate(playerId));
                filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 4));
                Target target = new TargetCardInGraveyard(filter);
                if (target.canChoose(source.getSourceId(), playerId, game) && player.chooseTarget(outcome, target, source, game)) {
                    Card card = game.getCard(target.getFirstTarget());
                    if (card != null) {
                        toBattlefield.add(card);
                    }
                }
            }
        }
        // must happen simultaneously Rule 101.4
        controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, true, null);
        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) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Target(mage.target.Target) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) UUID(java.util.UUID) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) HashSet(java.util.HashSet)

Example 17 with FilterCreatureCard

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

the class CrypticGatewayPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (source.getCosts() == null) {
        return false;
    }
    FilterCard filter = new FilterCreatureCard("creature card from your hand that shares a creature type with each creature tapped this way");
    for (Cost cost : source.getCosts()) {
        if (cost instanceof CrypticGatewayCost) {
            Predicate predicate = ((CrypticGatewayCost) cost).getPredicate();
            filter.add(predicate);
            return new PutCardFromHandOntoBattlefieldEffect(filter).apply(game, source);
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect) Cost(mage.abilities.costs.Cost) Predicate(mage.filter.predicate.Predicate) TappedPredicate(mage.filter.predicate.permanent.TappedPredicate)

Example 18 with FilterCreatureCard

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

the class DermoplasmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent thisCreature = game.getPermanent(source.getId());
    FilterCreatureCard filter = new FilterCreatureCard("a creature card with a morph ability");
    filter.add(new AbilityPredicate(MorphAbility.class));
    Effect effect = new PutCardFromHandOntoBattlefieldEffect(filter);
    if (effect.apply(game, source)) {
        if (thisCreature != null) {
            effect = new ReturnToHandTargetEffect();
            effect.setTargetPointer(new FixedTarget(thisCreature.getId(), game));
            effect.apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreatureCard(mage.filter.common.FilterCreatureCard) MorphAbility(mage.abilities.keyword.MorphAbility) Permanent(mage.game.permanent.Permanent) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) AbilityPredicate(mage.filter.predicate.mageobject.AbilityPredicate)

Example 19 with FilterCreatureCard

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

the class ExhumeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Set<Card> toBattlefield = new HashSet<>();
    if (controller != null) {
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                FilterCreatureCard filterCreatureCard = new FilterCreatureCard("creature card from your graveyard");
                filterCreatureCard.add(new OwnerIdPredicate(playerId));
                TargetCardInGraveyard target = new TargetCardInGraveyard(filterCreatureCard);
                target.setNotTarget(true);
                if (target.canChoose(source.getSourceId(), playerId, game) && player.chooseTarget(outcome, target, source, game)) {
                    Card card = game.getCard(target.getFirstTarget());
                    if (card != null) {
                        toBattlefield.add(card);
                    }
                }
            }
        }
        // must happen simultaneously Rule 101.4
        controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, true, null);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) OwnerIdPredicate(mage.filter.predicate.card.OwnerIdPredicate) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) UUID(java.util.UUID) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 20 with FilterCreatureCard

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

the class LifesFinaleEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    List<Permanent> permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, source.getControllerId(), game);
    for (Permanent permanent : permanents) {
        permanent.destroy(source, game, false);
    }
    Player opponent = game.getPlayer(source.getFirstTarget());
    Player player = game.getPlayer(source.getControllerId());
    if (player != null && opponent != null) {
        TargetCardInLibrary target = new TargetCardInLibrary(0, 3, new FilterCreatureCard("creature cards from their library to put in their graveyard"));
        if (player.searchLibrary(target, source, game, opponent.getId())) {
            player.moveCards(new CardsImpl(target.getTargets()), Zone.GRAVEYARD, source, game);
        }
        opponent.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Permanent(mage.game.permanent.Permanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl)

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