Search in sources :

Example 6 with ExileTargetEffect

use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.

the class ProfaneProcessionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    UUID exileId = CardUtil.getCardExileZoneId(game, source);
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && exileId != null && sourceObject != null) {
        new ExileTargetEffect(exileId, sourceObject.getIdName()).setTargetPointer(targetPointer).apply(game, source);
        game.getState().processAction(game);
        ExileZone exileZone = game.getExile().getExileZone(exileId);
        if (exileZone != null && exileZone.size() > 2) {
            new TransformSourceEffect().apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect) MageObject(mage.MageObject) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 7 with ExileTargetEffect

use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.

the class RallyTheAncestorsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        int xValue = source.getManaCostsToPay().getX();
        FilterCreatureCard filter = new FilterCreatureCard();
        filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
        Set<Card> cards = player.getGraveyard().getCards(filter, game);
        player.moveCards(cards, Zone.BATTLEFIELD, source, game);
        List<Permanent> toExile = new ArrayList<>(cards.size());
        for (Card card : cards) {
            if (card != null) {
                Permanent permanent = game.getPermanent(card.getId());
                if (permanent != null) {
                    toExile.add(permanent);
                }
            }
        }
        Effect exileEffect = new ExileTargetEffect("Exile those creatures at the beginning of your next upkeep");
        exileEffect.setTargetPointer(new FixedTargets(toExile, game));
        DelayedTriggeredAbility delayedAbility = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(exileEffect);
        game.addDelayedTriggeredAbility(delayedAbility, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FixedTargets(mage.target.targetpointer.FixedTargets) ArrayList(java.util.ArrayList) AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ExileSpellEffect(mage.abilities.effects.common.ExileSpellEffect) Effect(mage.abilities.effects.Effect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 8 with ExileTargetEffect

use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.

the class StormHeraldAttachableToPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        FilterCard filter = new FilterCard("aura cards to attach to creatures you control");
        filter.add(SubType.AURA.getPredicate());
        filter.add(new StormHeraldAttachablePredicate(controller.getId()));
        Set<Card> possibleTargets = controller.getGraveyard().getCards(filter, source.getSourceId(), controller.getId(), game);
        if (!possibleTargets.isEmpty()) {
            TargetCard targetAuras = new TargetCard(0, Integer.MAX_VALUE, Zone.GRAVEYARD, filter);
            targetAuras.setNotTarget(true);
            controller.chooseTarget(outcome, new CardsImpl(possibleTargets), targetAuras, source, game);
            // Move the cards to the battlefield to a creature you control
            List<Permanent> toExile = new ArrayList<>();
            for (UUID auraId : targetAuras.getTargets()) {
                Card auraCard = game.getCard(auraId);
                if (auraCard != null) {
                    FilterPermanent filterAttachTo = new FilterControlledCreaturePermanent("creature you control to attach " + auraCard.getIdName() + " to");
                    filterAttachTo.add(new StormHeraldAttachableToPredicate(auraCard));
                    TargetPermanent targetCreature = new TargetPermanent(filterAttachTo);
                    targetCreature.setNotTarget(true);
                    if (controller.choose(Outcome.PutCardInPlay, targetCreature, source.getSourceId(), game)) {
                        Permanent targetPermanent = game.getPermanent(targetCreature.getFirstTarget());
                        if (!targetPermanent.cantBeAttachedBy(auraCard, source, game, true)) {
                            game.getState().setValue("attachTo:" + auraCard.getId(), targetPermanent);
                            controller.moveCards(auraCard, Zone.BATTLEFIELD, source, game);
                            targetPermanent.addAttachment(auraCard.getId(), source, game);
                            Permanent permanent = game.getPermanent(auraId);
                            if (permanent != null) {
                                toExile.add(permanent);
                            }
                        }
                    }
                }
            }
            ContinuousEffect continuousEffect = new StormHeraldReplacementEffect();
            continuousEffect.setTargetPointer(new FixedTargets(toExile, game));
            game.addEffect(continuousEffect, source);
            Effect exileEffect = new ExileTargetEffect("exile those Auras");
            exileEffect.setTargetPointer(new FixedTargets(toExile, game));
            game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) FixedTargets(mage.target.targetpointer.FixedTargets) ArrayList(java.util.ArrayList) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetCard(mage.target.TargetCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) FilterCard(mage.filter.FilterCard) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) TargetPermanent(mage.target.TargetPermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 9 with ExileTargetEffect

use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.

the class MimicVatCreateTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent == null) {
        return false;
    }
    if (!permanent.getImprinted().isEmpty()) {
        Card card = game.getCard(permanent.getImprinted().get(0));
        if (card != null) {
            CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
            effect.setTargetPointer(new FixedTarget(card, game));
            effect.apply(game, source);
            for (Permanent addedToken : effect.getAddedPermanents()) {
                ExileTargetEffect exileEffect = new ExileTargetEffect();
                exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
                DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
                game.addDelayedTriggeredAbility(delayedAbility, source);
            }
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Card(mage.cards.Card) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 10 with ExileTargetEffect

use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.

the class NemesisTrapEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent targetedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && targetedCreature != null) {
        // exile target
        controller.moveCards(targetedCreature, Zone.EXILED, source, game);
        // create token
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect();
        effect.setTargetPointer(new FixedTarget(targetedCreature, game));
        effect.apply(game, source);
        for (Permanent addedToken : effect.getAddedPermanents()) {
            Effect exileEffect = new ExileTargetEffect("Exile " + addedToken.getName() + " at the beginning of the next end step");
            exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
            DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
            game.addDelayedTriggeredAbility(delayedAbility, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Effect(mage.abilities.effects.Effect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Aggregations

ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)51 Permanent (mage.game.permanent.Permanent)40 FixedTarget (mage.target.targetpointer.FixedTarget)38 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)31 Player (mage.players.Player)31 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)26 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)20 Card (mage.cards.Card)20 ContinuousEffect (mage.abilities.effects.ContinuousEffect)15 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)13 Effect (mage.abilities.effects.Effect)12 OneShotEffect (mage.abilities.effects.OneShotEffect)12 FixedTargets (mage.target.targetpointer.FixedTargets)10 UUID (java.util.UUID)9 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)9 TargetPermanent (mage.target.TargetPermanent)8 ArrayList (java.util.ArrayList)6 AtTheEndOfCombatDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)6 FilterCreatureCard (mage.filter.common.FilterCreatureCard)6 FilterCard (mage.filter.FilterCard)5