Search in sources :

Example 81 with ManaValuePredicate

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

the class CitanulFluteSearchEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    FilterCard filter = new FilterCreatureCard("creature card with mana value X or less");
    // Set the mana cost one higher to 'emulate' a less than or equal to comparison.
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
    TargetCardInLibrary target = new TargetCardInLibrary(filter);
    player.searchLibrary(target, source, game);
    Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
    if (card != null) {
        player.revealCards(source, new CardsImpl(card), game);
        player.moveCards(card, Zone.HAND, source, game);
    }
    player.shuffleLibrary(source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 82 with ManaValuePredicate

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

the class BloodOnTheSnowEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int snow = ManaPaidSourceWatcher.getSnowPaid(source.getId(), game);
        FilterCard filter = new FilterCard("a creature or planeswalker card with mana value " + snow + " or less from your graveyard");
        filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.PLANESWALKER.getPredicate()));
        filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, snow + 1));
        TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(1, 1, filter, true);
        controller.chooseTarget(outcome, target, source, game);
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            controller.moveCards(card, Zone.BATTLEFIELD, source, game);
            return true;
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 83 with ManaValuePredicate

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

the class HasLowestCMCAmongstNonlandPermanentsPredicate method apply.

@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
    FilterPermanent filter = new FilterNonlandPermanent();
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, input.getObject().getManaValue()));
    return !game.getBattlefield().contains(filter, input.getSourceId(), input.getPlayerId(), game, 1);
}
Also used : ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterPermanent(mage.filter.FilterPermanent) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent)

Example 84 with ManaValuePredicate

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

the class BringToLightEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int numberColors = ColorsOfManaSpentToCastCount.getInstance().calculate(game, source, this);
        FilterCard filter = new FilterCard("a creature, instant, or sorcery card with mana value " + "less than or equal to " + numberColors);
        filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.INSTANT.getPredicate(), CardType.SORCERY.getPredicate()));
        filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, numberColors + 1));
        TargetCardInLibrary target = new TargetCardInLibrary(filter);
        controller.searchLibrary(target, source, game);
        Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
        if (card != null) {
            controller.moveCards(card, Zone.EXILED, source, game);
        }
        controller.shuffleLibrary(source, game);
        if (card != null) {
            if (controller.chooseUse(Outcome.PlayForFree, "Cast " + card.getName() + " without paying its mana cost?", source, game)) {
                game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
                Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
                game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) ApprovingObject(mage.ApprovingObject) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

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