Search in sources :

Example 31 with ReturnToBattlefieldUnderOwnerControlTargetEffect

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

the class AngelOfCondemnationExileUntilEOTEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (controller != null && permanent != null && sourcePermanent != null) {
        if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourcePermanent.getIdName(), source, game, Zone.BATTLEFIELD, true)) {
            // create delayed triggered ability
            Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
            effect.setText("return that card to the battlefield under its owner's control");
            effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
            game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ExileUntilSourceLeavesEffect(mage.abilities.effects.common.ExileUntilSourceLeavesEffect)

Aggregations

ReturnToBattlefieldUnderOwnerControlTargetEffect (mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect)31 Effect (mage.abilities.effects.Effect)28 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)27 OneShotEffect (mage.abilities.effects.OneShotEffect)27 FixedTarget (mage.target.targetpointer.FixedTarget)27 Permanent (mage.game.permanent.Permanent)25 Player (mage.players.Player)24 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)12 MageObject (mage.MageObject)11 UUID (java.util.UUID)9 TargetPermanent (mage.target.TargetPermanent)8 Card (mage.cards.Card)6 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)6 FilterPermanent (mage.filter.FilterPermanent)5 FixedTargets (mage.target.targetpointer.FixedTargets)4 HashSet (java.util.HashSet)3 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)2 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)2 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)2 PermanentCard (mage.game.permanent.PermanentCard)2