Search in sources :

Example 11 with SearchLibraryPutInPlayEffect

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

the class HuntingWildsToken method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Effect sourceEffect : source.getEffects()) {
        if (sourceEffect instanceof SearchLibraryPutInPlayEffect) {
            Cards foundCards = new CardsImpl(((SearchLibraryPutInPlayEffect) sourceEffect).getTargets());
            if (!foundCards.isEmpty()) {
                FixedTargets fixedTargets = new FixedTargets(foundCards, game);
                UntapTargetEffect untapEffect = new UntapTargetEffect();
                untapEffect.setTargetPointer(fixedTargets);
                untapEffect.apply(game, source);
                BecomesCreatureTargetEffect becomesCreatureEffect = new BecomesCreatureTargetEffect(new HuntingWildsToken(), false, true, Duration.Custom);
                becomesCreatureEffect.setTargetPointer(fixedTargets);
                game.addEffect(becomesCreatureEffect, source);
            }
            return true;
        }
    }
    return false;
}
Also used : FixedTargets(mage.target.targetpointer.FixedTargets) BecomesCreatureTargetEffect(mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect) ConditionalOneShotEffect(mage.abilities.decorator.ConditionalOneShotEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) BecomesCreatureTargetEffect(mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect) UntapTargetEffect(mage.abilities.effects.common.UntapTargetEffect) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect) Effect(mage.abilities.effects.Effect) UntapTargetEffect(mage.abilities.effects.common.UntapTargetEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Example 12 with SearchLibraryPutInPlayEffect

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

the class VivienMonstersAdvocateTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Spell spell = game.getSpell(event.getTargetId());
    if (spell != null && spell.isCreature(game)) {
        int cmc = spell.getManaValue();
        FilterCard filter = new FilterCreatureCard("creature card with mana value less than " + cmc);
        filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, cmc));
        this.getEffects().clear();
        this.getEffects().add(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)));
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Spell(mage.game.stack.Spell) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)

Example 13 with SearchLibraryPutInPlayEffect

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

the class MaskOfTheMimicEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getFirstTarget());
    if (creature == null) {
        return false;
    }
    FilterCard filter = new FilterCard("a card named " + creature.getName());
    filter.add(new NamePredicate(creature.getName()));
    return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)).apply(game, source);
}
Also used : FilterCard(mage.filter.FilterCard) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) 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