Search in sources :

Example 61 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

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

the class FleetingSpiritEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (controller == null || permanent == null) {
        return false;
    }
    int zcc = permanent.getZoneChangeCounter(game);
    if (!controller.moveCards(permanent, Zone.EXILED, source, game)) {
        return false;
    }
    Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
    effect.setTargetPointer(new FixedTarget(permanent.getId(), zcc + 1));
    AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
    game.addDelayedTriggeredAbility(delayedAbility, 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) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect)

Example 62 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

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

the class GraveBetrayalReplacementEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zoneChangeEvent = (ZoneChangeEvent) event;
    if (zoneChangeEvent.isDiesEvent()) {
        Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
        if (permanent != null && !permanent.isControlledBy(this.getControllerId()) && permanent.isCreature(game)) {
            Card card = (Card) game.getObject(permanent.getId());
            if (card != null) {
                Effect effect = new GraveBetrayalEffect();
                effect.setTargetPointer(new FixedTarget(card, game));
                DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
                game.addDelayedTriggeredAbility(delayedAbility, this);
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BecomesBlackZombieAdditionEffect(mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect) Effect(mage.abilities.effects.Effect) Card(mage.cards.Card)

Example 63 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

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

the class InfiniteAuthorityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent aura = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (aura != null) {
        Permanent enchantedCreature = game.getPermanentOrLKIBattlefield(aura.getAttachedTo());
        if (enchantedCreature != null) {
            Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
            if (permanent != null) {
                if (permanent.destroy(source, game, false)) {
                    AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance()));
                    delayedAbility.getEffects().get(0).setTargetPointer(new FixedTarget(enchantedCreature, game));
                    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) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 64 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

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

the class PostmortemLungeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(source.getFirstTarget());
    if (card != null) {
        Player cardOwner = game.getPlayer(card.getOwnerId());
        if (cardOwner == null) {
            return false;
        }
        if (cardOwner.moveCards(card, Zone.BATTLEFIELD, source, game)) {
            Permanent permanent = game.getPermanent(card.getId());
            if (permanent != null) {
                ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
                effect.setTargetPointer(new FixedTarget(permanent, game));
                game.addEffect(effect, source);
                ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
                exileEffect.setTargetPointer(new FixedTarget(permanent, game));
                game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), 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) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 65 with AtTheBeginOfNextEndStepDelayedTriggeredAbility

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

the class SeanceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(source.getFirstTarget());
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && card != null) {
        // Also if the move to exile is replaced, the copy takes place
        controller.moveCards(card, Zone.EXILED, source, game);
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false);
        effect.setTargetPointer(new FixedTarget(card, game));
        effect.setAdditionalSubType(SubType.SPIRIT);
        effect.apply(game, source);
        ExileTargetEffect exileEffect = new ExileTargetEffect();
        exileEffect.setTargetPointer(new FixedTargets(effect.getAddedPermanents(), game));
        DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
        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) FixedTargets(mage.target.targetpointer.FixedTargets) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) 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