Search in sources :

Example 1 with ExileTargetForSourceEffect

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

the class CosmicInterventionReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent permanent = game.getPermanent(event.getTargetId());
        if (permanent != null) {
            Card card = game.getCard(event.getTargetId());
            if (card != null) {
                ExileTargetForSourceEffect exileEffect = new ExileTargetForSourceEffect();
                exileEffect.setTargetPointer(new FixedTarget(card.getId(), game));
                exileEffect.apply(game, source);
                Effect returnEffect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
                returnEffect.setTargetPointer(new FixedTarget(card.getId(), game));
                AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnEffect);
                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) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) ExileTargetForSourceEffect(mage.abilities.effects.common.ExileTargetForSourceEffect) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) Effect(mage.abilities.effects.Effect) ExileTargetForSourceEffect(mage.abilities.effects.common.ExileTargetForSourceEffect) Card(mage.cards.Card)

Example 2 with ExileTargetForSourceEffect

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

the class HoardingDragonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller == null || sourceObject == null) {
        return false;
    }
    TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_ARTIFACT);
    controller.searchLibrary(target, source, game);
    Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
    if (card != null) {
        ExileTargetForSourceEffect effect = new ExileTargetForSourceEffect();
        effect.setTargetPointer(new FixedTarget(target.getFirstTarget()));
        effect.apply(game, source);
    }
    controller.shuffleLibrary(source, game);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) MageObject(mage.MageObject) ExileTargetForSourceEffect(mage.abilities.effects.common.ExileTargetForSourceEffect) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Card(mage.cards.Card)

Example 3 with ExileTargetForSourceEffect

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

the class JusticiarsPortalEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID targetId = source.getFirstTarget();
    new ExileTargetForSourceEffect().apply(game, source);
    new ReturnToBattlefieldUnderYourControlTargetEffect().apply(game, source);
    ContinuousEffect effect = new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn);
    effect.setTargetPointer(new FixedTarget(targetId, game));
    game.addEffect(effect, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ReturnToBattlefieldUnderYourControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect) ExileTargetForSourceEffect(mage.abilities.effects.common.ExileTargetForSourceEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Aggregations

ExileTargetForSourceEffect (mage.abilities.effects.common.ExileTargetForSourceEffect)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 Card (mage.cards.Card)2 Player (mage.players.Player)2 UUID (java.util.UUID)1 MageObject (mage.MageObject)1 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 Effect (mage.abilities.effects.Effect)1 ReturnToBattlefieldUnderOwnerControlTargetEffect (mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect)1 ReturnToBattlefieldUnderYourControlTargetEffect (mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect)1 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)1 Permanent (mage.game.permanent.Permanent)1 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)1