Search in sources :

Example 41 with ManaValuePredicate

use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.

the class BlastZoneEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    int xValue = permanent.getCounters(game).getCount(CounterType.CHARGE);
    FilterPermanent filter = new FilterNonlandPermanent();
    filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
    return new DestroyAllEffect(filter).apply(game, source);
}
Also used : ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterPermanent(mage.filter.FilterPermanent) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 42 with ManaValuePredicate

use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.

the class LegacyOfTheBelovedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card sourceCard = game.getCard(source.getSourceId());
    if (sourceCard != null) {
        for (Cost cost : source.getCosts()) {
            if (cost instanceof SacrificeTargetCost) {
                Permanent p = (Permanent) game.getLastKnownInformation(((SacrificeTargetCost) cost).getPermanents().get(0).getId(), Zone.BATTLEFIELD);
                if (p != null) {
                    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, p.getManaValue()));
                    TargetCardInLibrary target = new TargetCardInLibrary(0, 2, filter);
                    Player player = game.getPlayer(source.getControllerId());
                    if (player != null && player.searchLibrary(target, source, game)) {
                        player.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
                        player.shuffleLibrary(source, game);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 43 with ManaValuePredicate

use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.

the class LaviniaAzoriusRenegadeTriggeredAbility method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (game.getPlayer(source.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
        FilterCard filter = new FilterCard();
        filter.add(Predicates.not(CardType.CREATURE.getPredicate()));
        filter.add(new ManaValuePredicate(ComparisonType.MORE_THAN, getLandCount(source, event, game)));
        Card card = game.getCard(event.getSourceId());
        return card != null && filter.match(card, game);
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 44 with ManaValuePredicate

use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.

the class OrahSkyclaveHierophantTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (!zEvent.isDiesEvent() || !zEvent.getTarget().isControlledBy(getControllerId()) || (!zEvent.getTarget().hasSubtype(SubType.CLERIC, game) && !zEvent.getTarget().getId().equals(getSourceId()))) {
        return false;
    }
    FilterCard filterCard = new FilterCard("Cleric card with mana value less than " + (zEvent.getTarget().getManaValue()));
    filterCard.add(SubType.CLERIC.getPredicate());
    filterCard.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, zEvent.getTarget().getManaValue()));
    this.getTargets().clear();
    this.addTarget(new TargetCardInYourGraveyard(filterCard));
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 45 with ManaValuePredicate

use of mage.filter.predicate.mageobject.ManaValuePredicate in project mage by magefree.

the class PowderKegEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (sourcePermanent == null) {
        return false;
    }
    int count = sourcePermanent.getCounters(game).getCount(CounterType.FUSE);
    FilterPermanent filter = new FilterPermanent();
    filter.add(Predicates.or(CardType.ARTIFACT.getPredicate(), CardType.CREATURE.getPredicate()));
    filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, count));
    for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
        perm.destroy(source, game, false);
    }
    return true;
}
Also used : ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent)

Aggregations

ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)84 Player (mage.players.Player)64 FilterCard (mage.filter.FilterCard)57 Card (mage.cards.Card)37 Permanent (mage.game.permanent.Permanent)33 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)31 FilterCreatureCard (mage.filter.common.FilterCreatureCard)16 FilterPermanent (mage.filter.FilterPermanent)15 CardsImpl (mage.cards.CardsImpl)14 FilterPermanentCard (mage.filter.common.FilterPermanentCard)13 TargetCard (mage.target.TargetCard)13 ApprovingObject (mage.ApprovingObject)11 Cost (mage.abilities.costs.Cost)10 TargetCardInHand (mage.target.common.TargetCardInHand)9 UUID (java.util.UUID)8 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)8 Cards (mage.cards.Cards)7 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)7 MageObject (mage.MageObject)6 SearchLibraryPutInPlayEffect (mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)6