Search in sources :

Example 1 with SearchLibraryPutInPlayEffect

use of mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect in project mage by magefree.

the class FiendArtisanEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = source.getManaCostsToPay().getX();
    FilterCard filter = new FilterCreatureCard("creature card with mana value " + xValue + " or less");
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
    return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)).apply(game, source);
}
Also used : FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Example 2 with SearchLibraryPutInPlayEffect

use of mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect 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 3 with SearchLibraryPutInPlayEffect

use of mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect in project mage by magefree.

the class EnigmaticIncarnationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 0 || !player.chooseUse(outcome, "Sacrifice an enchantment?", source, game)) {
        return false;
    }
    TargetPermanent target = new TargetPermanent(0, 1, filter, true);
    player.choose(outcome, target, source.getSourceId(), game);
    Permanent permanent = game.getPermanent(target.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    game.getState().processAction(game);
    int cmc = permanent.getManaValue();
    if (!permanent.sacrifice(source, game)) {
        return false;
    }
    FilterCard filterCard = new FilterCreatureCard("creature card with mana value " + (cmc + 1));
    filterCard.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc + 1));
    return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filterCard)).apply(game, source);
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterPermanent(mage.filter.FilterPermanent) FilterControlledEnchantmentPermanent(mage.filter.common.FilterControlledEnchantmentPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) TargetPermanent(mage.target.TargetPermanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Example 4 with SearchLibraryPutInPlayEffect

use of mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect in project mage by magefree.

the class BifurcateEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    FilterCard filter = new FilterPermanentCard();
    filter.add(new NamePredicate(permanent.getName()));
    return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)).apply(game, source);
}
Also used : FilterCard(mage.filter.FilterCard) FilterPermanentCard(mage.filter.common.FilterPermanentCard) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Example 5 with SearchLibraryPutInPlayEffect

use of mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect in project mage by magefree.

the class CartographersHawkEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (permanent == null || player == null) {
        return false;
    }
    if (!player.moveCards(permanent, Zone.HAND, source, game)) {
        return false;
    }
    if (!player.chooseUse(Outcome.PutLandInPlay, "Search your library for Plains card?", source, game)) {
        return true;
    }
    return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), true).apply(game, source);
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Aggregations

SearchLibraryPutInPlayEffect (mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)13 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)12 FilterCard (mage.filter.FilterCard)9 Permanent (mage.game.permanent.Permanent)7 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)6 Player (mage.players.Player)5 FilterCreatureCard (mage.filter.common.FilterCreatureCard)4 FilterPermanent (mage.filter.FilterPermanent)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 FilterPermanentCard (mage.filter.common.FilterPermanentCard)2 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)2 TargetPermanent (mage.target.TargetPermanent)2 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 UUID (java.util.UUID)1 ConditionalOneShotEffect (mage.abilities.decorator.ConditionalOneShotEffect)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 UntapTargetEffect (mage.abilities.effects.common.UntapTargetEffect)1 BecomesCreatureTargetEffect (mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect)1 Cards (mage.cards.Cards)1