Search in sources :

Example 1 with ReturnFromGraveyardToBattlefieldTargetEffect

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

the class InameAsOneEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
    if (controller != null && sourceObject != null && targetCard != null) {
        if (controller.chooseUse(outcome, "Exile " + sourceObject.getLogName() + " to return Spirit card?", source, game)) {
            // In a Commander game, you may send Iname to the Command Zone instead of exiling it during the resolution
            // of its ability. If you do, its ability still works. Iname's ability only requires that you attempted to
            // exile it, not that it actually gets to the exile zone. This is similar to how destroying a creature
            // (with, for example, Rest in Peace) doesn't necessarily ensure that creature will end up in the graveyard;
            // it just so happens that the action of exiling something and the exile zone both use the same word: "exile".
            Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
            effect.setTargetPointer(new FixedTarget(targetCard.getId(), targetCard.getZoneChangeCounter(game)));
            new ExileSourceEffect().apply(game, source);
            return effect.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ExileSourceEffect(mage.abilities.effects.common.ExileSourceEffect) Player(mage.players.Player) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) MageObject(mage.MageObject) ExileSourceEffect(mage.abilities.effects.common.ExileSourceEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect) Effect(mage.abilities.effects.Effect) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) Card(mage.cards.Card) FilterPermanentCard(mage.filter.common.FilterPermanentCard)

Example 2 with ReturnFromGraveyardToBattlefieldTargetEffect

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

the class ChainerDementiaMasterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        UUID cardId = this.getTargetPointer().getFirst(game, source);
        new ReturnFromGraveyardToBattlefieldTargetEffect().apply(game, source);
        Permanent permanent = game.getPermanent(cardId);
        if (permanent != null) {
            ContinuousEffectImpl effect = new BecomesColorTargetEffect(ObjectColor.BLACK, Duration.WhileOnBattlefield);
            effect.setTargetPointer(new FixedTarget(permanent, game));
            game.addEffect(effect, source);
            effect = new BecomesCreatureTypeTargetEffect(Duration.WhileOnBattlefield, SubType.NIGHTMARE, false);
            effect.setTargetPointer(new FixedTarget(permanent, game));
            game.addEffect(effect, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) BecomesColorTargetEffect(mage.abilities.effects.common.continuous.BecomesColorTargetEffect) Player(mage.players.Player) BecomesCreatureTypeTargetEffect(mage.abilities.effects.common.continuous.BecomesCreatureTypeTargetEffect) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) ContinuousEffectImpl(mage.abilities.effects.ContinuousEffectImpl) UUID(java.util.UUID)

Example 3 with ReturnFromGraveyardToBattlefieldTargetEffect

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

the class DiabolicServitudeSourceLeftBattlefieldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card cardInGraveyard = game.getCard(getTargetPointer().getFirst(game, source));
    if (cardInGraveyard != null) {
        Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
        effect.setTargetPointer(getTargetPointer());
        effect.apply(game, source);
        game.getState().setValue(source.getSourceId().toString() + "returnedCreature", new MageObjectReference(cardInGraveyard.getId(), game));
        return true;
    }
    return false;
}
Also used : ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) Effect(mage.abilities.effects.Effect) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card)

Example 4 with ReturnFromGraveyardToBattlefieldTargetEffect

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

the class LilianaDefiantNecromancerEmblemEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card != null) {
        Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
        effect.setTargetPointer(new FixedTarget(card, game));
        effect.setText("return that card to the battlefield at the beginning of the next end step");
        game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY), source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) Card(mage.cards.Card)

Example 5 with ReturnFromGraveyardToBattlefieldTargetEffect

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

the class DarettiScrapSavantEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
        Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
        effect.setTargetPointer(new FixedTarget(card, game));
        effect.setText("return that card to the battlefield at the beginning of the next end step");
        game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY), source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) Card(mage.cards.Card)

Aggregations

ReturnFromGraveyardToBattlefieldTargetEffect (mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect)7 Effect (mage.abilities.effects.Effect)6 OneShotEffect (mage.abilities.effects.OneShotEffect)6 FixedTarget (mage.target.targetpointer.FixedTarget)6 Card (mage.cards.Card)5 Player (mage.players.Player)4 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)2 UUID (java.util.UUID)1 MageObject (mage.MageObject)1 MageObjectReference (mage.MageObjectReference)1 PayLifeCost (mage.abilities.costs.common.PayLifeCost)1 ContinuousEffectImpl (mage.abilities.effects.ContinuousEffectImpl)1 DoUnlessAnyPlayerPaysEffect (mage.abilities.effects.common.DoUnlessAnyPlayerPaysEffect)1 ExileSourceEffect (mage.abilities.effects.common.ExileSourceEffect)1 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)1 ReturnToHandSourceEffect (mage.abilities.effects.common.ReturnToHandSourceEffect)1 BecomesColorTargetEffect (mage.abilities.effects.common.continuous.BecomesColorTargetEffect)1 BecomesCreatureTypeTargetEffect (mage.abilities.effects.common.continuous.BecomesCreatureTypeTargetEffect)1 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)1 SearchLibraryPutInPlayEffect (mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect)1