Search in sources :

Example 6 with SearchLibraryPutInPlayEffect

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

the class HibernationsEndEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (sourcePermanent != null && player != null) {
        int newConvertedCost = sourcePermanent.getCounters(game).getCount("age");
        FilterCard filter = new FilterCard("creature card with mana value " + newConvertedCost);
        filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, newConvertedCost));
        filter.add(CardType.CREATURE.getPredicate());
        TargetCardInLibrary target = new TargetCardInLibrary(filter);
        return new SearchLibraryPutInPlayEffect(target).apply(game, source);
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Permanent(mage.game.permanent.Permanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Example 7 with SearchLibraryPutInPlayEffect

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

the class SisayWeatherlightCaptainEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (permanent == null) {
        return false;
    }
    int power = permanent.getPower().getValue();
    FilterCard filter = new FilterPermanentCard("legendary permanent card with mana value less than " + power);
    filter.add(SuperType.LEGENDARY.getPredicate());
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, power));
    return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)).apply(game, source);
}
Also used : FilterCard(mage.filter.FilterCard) FilterPermanentCard(mage.filter.common.FilterPermanentCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Permanent(mage.game.permanent.Permanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Example 8 with SearchLibraryPutInPlayEffect

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

the class SurveyorsScopeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int numberOfLands = 0;
        int ownLands = game.getBattlefield().countAll(new FilterLandPermanent(), controller.getId(), game);
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            if (!playerId.equals(controller.getId())) {
                if (game.getBattlefield().countAll(new FilterLandPermanent(), playerId, game) > ownLands + 1) {
                    numberOfLands++;
                }
            }
        }
        game.informPlayers("Surveyor's Scope: X = " + numberOfLands);
        // 10/17/2013 	If no players control at least two more lands than you when the ability resolves, you'll still search and shuffle your library.
        return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(0, numberOfLands, StaticFilters.FILTER_CARD_BASIC_LAND)).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) FilterLandPermanent(mage.filter.common.FilterLandPermanent) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Example 9 with SearchLibraryPutInPlayEffect

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

the class SylvanPrimordialEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean result = false;
    int destroyedCreatures = 0;
    for (Target target : source.getTargets()) {
        if (target instanceof TargetPermanent) {
            Permanent targetPermanent = game.getPermanent(target.getFirstTarget());
            if (targetPermanent != null) {
                if (targetPermanent.destroy(source, game, false)) {
                    destroyedCreatures++;
                }
            }
        }
    }
    if (destroyedCreatures > 0) {
        new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(destroyedCreatures, filterForest), true, true).apply(game, source);
    }
    return result;
}
Also used : Target(mage.target.Target) FilterPermanent(mage.filter.FilterPermanent) 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 10 with SearchLibraryPutInPlayEffect

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

the class TajNarSwordsmithEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null && player.chooseUse(Outcome.Benefit, "Do you want to pay {X} to search and put Equipment?", source, game)) {
        // can be zero
        int payCount = ManaUtil.playerPaysXGenericMana(true, "Taj-Nar Swordsmith", player, source, game);
        FilterCard filter = new FilterCard("Equipment card with mana value {" + payCount + "} or less");
        filter.add(SubType.EQUIPMENT.getPredicate());
        filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, payCount + 1));
        new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(0, 1, filter), false, true).apply(game, source);
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) 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