Search in sources :

Example 31 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.

the class TouchTheSpiritRealmEffect 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.moveCardsToExile(permanent, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
    ReturnToBattlefieldUnderOwnerControlTargetEffect returnEffect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, true);
    returnEffect.setTargetPointer(new FixedTarget(card, game));
    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnEffect), 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) TargetPermanent(mage.target.TargetPermanent) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) Card(mage.cards.Card)

Example 32 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.

the class VoidwalkEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && permanent != null && sourceObject != null) {
        if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourceObject.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 at the beginning of the next end step");
            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) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) MageObject(mage.MageObject) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CipherEffect(mage.abilities.effects.common.CipherEffect) Effect(mage.abilities.effects.Effect)

Example 33 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.

the class KillerInstinctEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
    if (player == null || sourceObject == null) {
        return false;
    }
    Library library = player.getLibrary();
    if (library == null || !library.hasCards()) {
        return false;
    }
    Card card = library.getFromTop(game);
    if (card == null) {
        return false;
    }
    player.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
    if (card.isCreature(game) && player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        Permanent permanent = game.getPermanent(card.getId());
        if (permanent != null) {
            FixedTarget ft = new FixedTarget(permanent, game);
            ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
            effect.setTargetPointer(ft);
            game.addEffect(effect, source);
            Effect sacrificeEffect = new SacrificeTargetEffect("Sacrifice it at the beginning of the next end step", source.getControllerId());
            sacrificeEffect.setTargetPointer(ft);
            game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), 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) MageObject(mage.MageObject) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) Library(mage.players.Library) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 34 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.

the class KikiJikiMirrorBreakerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (permanent != null) {
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        effect.apply(game, source);
        for (Permanent addedToken : effect.getAddedPermanents()) {
            SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("Sacrifice the token at the beginning of the next end step", source.getControllerId());
            sacrificeEffect.setTargetPointer(new FixedTarget(addedToken.getId()));
            game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect)

Example 35 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility 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)

Aggregations

AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)143 FixedTarget (mage.target.targetpointer.FixedTarget)115 Permanent (mage.game.permanent.Permanent)101 Player (mage.players.Player)86 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)61 Effect (mage.abilities.effects.Effect)60 OneShotEffect (mage.abilities.effects.OneShotEffect)60 Card (mage.cards.Card)57 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)33 ContinuousEffect (mage.abilities.effects.ContinuousEffect)32 SacrificeTargetEffect (mage.abilities.effects.common.SacrificeTargetEffect)31 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)29 ReturnToBattlefieldUnderOwnerControlTargetEffect (mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect)27 UUID (java.util.UUID)24 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)21 MageObject (mage.MageObject)20 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)17 FilterCard (mage.filter.FilterCard)16 TargetPermanent (mage.target.TargetPermanent)16 FixedTargets (mage.target.targetpointer.FixedTargets)14