Search in sources :

Example 1 with ReturnToBattlefieldUnderYourControlTargetEffect

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

the class CharmingPrinceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller == null || sourceObject == null) {
        return false;
    }
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    if (!controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourceObject.getIdName(), source, game, Zone.BATTLEFIELD, true)) {
        return false;
    }
    // create delayed triggered ability
    Effect effect = new ReturnToBattlefieldUnderYourControlTargetEffect();
    effect.setText("Return it to the battlefield under your control at the beginning of the next end step");
    effect.setTargetPointer(new FixedTarget(permanent.getId(), game));
    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) MageObject(mage.MageObject) ReturnToBattlefieldUnderYourControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ReturnToBattlefieldUnderYourControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect) ScryEffect(mage.abilities.effects.keyword.ScryEffect) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect) Effect(mage.abilities.effects.Effect)

Example 2 with ReturnToBattlefieldUnderYourControlTargetEffect

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

the class EscapePodEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (player == null || permanent == null) {
        return false;
    }
    Card card = permanent.getMainCard();
    player.moveCards(permanent, Zone.EXILED, source, game);
    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnToBattlefieldUnderYourControlTargetEffect().setText("Return that card to the battlefield under your control at the beginning of the next end step").setTargetPointer(new FixedTarget(card, game))), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) ReturnToBattlefieldUnderYourControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect) Card(mage.cards.Card)

Example 3 with ReturnToBattlefieldUnderYourControlTargetEffect

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

the class VenserTheSojournerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
        if (getTargetPointer().getFirst(game, source) != null) {
            Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
            if (permanent != null) {
                if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourceObject.getIdName(), source, game, Zone.BATTLEFIELD, true)) {
                    // create delayed triggered ability
                    Effect effect = new ReturnToBattlefieldUnderYourControlTargetEffect();
                    effect.setText("Return it to the battlefield under your control at the beginning of the next end step");
                    effect.setTargetPointer(new FixedTarget(permanent.getId(), 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) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) MageObject(mage.MageObject) ReturnToBattlefieldUnderYourControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ReturnToBattlefieldUnderYourControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect) Effect(mage.abilities.effects.Effect) CantBeBlockedAllEffect(mage.abilities.effects.common.combat.CantBeBlockedAllEffect) GetEmblemEffect(mage.abilities.effects.common.GetEmblemEffect)

Example 4 with ReturnToBattlefieldUnderYourControlTargetEffect

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

the class YodaJediMasterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (permanent != null && sourcePermanent != null) {
        if (permanent.moveToExile(source.getSourceId(), sourcePermanent.getName(), source, game)) {
            // create delayed triggered ability
            Effect effect = new ReturnToBattlefieldUnderYourControlTargetEffect();
            effect.setText("Return that card to the battlefield under your control at the beginning of your next end step");
            effect.setTargetPointer(new FixedTarget(permanent.getId(), game));
            game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ReturnToBattlefieldUnderYourControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect) LookLibraryAndPickControllerEffect(mage.abilities.effects.common.LookLibraryAndPickControllerEffect) ReturnToBattlefieldUnderYourControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) GetEmblemEffect(mage.abilities.effects.common.GetEmblemEffect)

Example 5 with ReturnToBattlefieldUnderYourControlTargetEffect

use of mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect 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

ReturnToBattlefieldUnderYourControlTargetEffect (mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect)9 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)7 Permanent (mage.game.permanent.Permanent)7 FixedTarget (mage.target.targetpointer.FixedTarget)7 Player (mage.players.Player)6 Effect (mage.abilities.effects.Effect)5 OneShotEffect (mage.abilities.effects.OneShotEffect)5 Card (mage.cards.Card)4 FilterPermanent (mage.filter.FilterPermanent)3 TargetPermanent (mage.target.TargetPermanent)3 MageObject (mage.MageObject)2 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)2 GetEmblemEffect (mage.abilities.effects.common.GetEmblemEffect)2 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)2 UUID (java.util.UUID)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 ExileTargetForSourceEffect (mage.abilities.effects.common.ExileTargetForSourceEffect)1 GainLifeEffect (mage.abilities.effects.common.GainLifeEffect)1 InfoEffect (mage.abilities.effects.common.InfoEffect)1 LookLibraryAndPickControllerEffect (mage.abilities.effects.common.LookLibraryAndPickControllerEffect)1