Search in sources :

Example 61 with DelayedTriggeredAbility

use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.

the class ZirilanOfTheClawEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        FilterPermanentCard filter = new FilterPermanentCard("a Dragon permanent card");
        filter.add(SubType.DRAGON.getPredicate());
        TargetCardInLibrary target = new TargetCardInLibrary(filter);
        if (controller.searchLibrary(target, source, game)) {
            Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
                Permanent permanent = game.getPermanent(card.getId());
                if (permanent != null) {
                    // gains haste
                    ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                    effect.setTargetPointer(new FixedTarget(permanent, game));
                    game.addEffect(effect, source);
                    // Exile at begin of next end step
                    ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
                    exileEffect.setTargetPointer(new FixedTarget(permanent, 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) FilterPermanentCard(mage.filter.common.FilterPermanentCard) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterPermanentCard(mage.filter.common.FilterPermanentCard) Card(mage.cards.Card) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 62 with DelayedTriggeredAbility

use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.

the class RemoveCountersAtEndOfTurn method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (!source.getTargets().isEmpty()) {
        Target multiTarget = source.getTargets().get(0);
        for (UUID target : multiTarget.getTargets()) {
            Permanent permanent = game.getPermanent(target);
            if (permanent != null) {
                permanent.addCounters(counterType.createInstance(multiTarget.getTargetAmount(target)), source.getControllerId(), source, game);
            }
        }
        if (removeAtEndOfTurn) {
            DelayedTriggeredAbility ability = new AtTheBeginOfNextCleanupDelayedTriggeredAbility(new RemoveCountersAtEndOfTurn(counterType));
            ability.getTargets().addAll(source.getTargets());
            game.addDelayedTriggeredAbility(ability, source);
        }
        return true;
    }
    return false;
}
Also used : Target(mage.target.Target) AtTheBeginOfNextCleanupDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) AtTheBeginOfNextCleanupDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) UUID(java.util.UUID)

Example 63 with DelayedTriggeredAbility

use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.

the class InitiatesOfTheEbonHandEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ActivationInfo activationInfo = ActivationInfo.getInstance(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
    activationInfo.addActivation(game);
    if (activationInfo.getActivationCounter() == 4) {
        DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new SacrificeSourceEffect());
        game.addDelayedTriggeredAbility(delayedAbility, source);
    }
    return true;
}
Also used : AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ActivationInfo(mage.abilities.ActivationInfo) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect)

Example 64 with DelayedTriggeredAbility

use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.

the class PhytotitanEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // create delayed triggered ability
    Effect effect = new ReturnSourceFromGraveyardToBattlefieldEffect(true, true);
    effect.setText(staticText);
    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(effect);
    game.addDelayedTriggeredAbility(delayedAbility, source);
    return true;
}
Also used : ReturnSourceFromGraveyardToBattlefieldEffect(mage.abilities.effects.common.ReturnSourceFromGraveyardToBattlefieldEffect) AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ReturnSourceFromGraveyardToBattlefieldEffect(mage.abilities.effects.common.ReturnSourceFromGraveyardToBattlefieldEffect) AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility)

Example 65 with DelayedTriggeredAbility

use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.

the class SkeletonizeDelayedTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    DelayedTriggeredAbility delayedAbility = new SkeletonizeDelayedTriggeredAbility();
    game.addDelayedTriggeredAbility(delayedAbility, source);
    return true;
}
Also used : DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)

Aggregations

DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)88 Permanent (mage.game.permanent.Permanent)62 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)61 FixedTarget (mage.target.targetpointer.FixedTarget)61 Player (mage.players.Player)38 Card (mage.cards.Card)30 OneShotEffect (mage.abilities.effects.OneShotEffect)27 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)27 Effect (mage.abilities.effects.Effect)25 ContinuousEffect (mage.abilities.effects.ContinuousEffect)24 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)20 SacrificeTargetEffect (mage.abilities.effects.common.SacrificeTargetEffect)19 UUID (java.util.UUID)14 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)14 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)13 FilterCard (mage.filter.FilterCard)9 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)9 ReturnToHandTargetEffect (mage.abilities.effects.common.ReturnToHandTargetEffect)8 FilterCreatureCard (mage.filter.common.FilterCreatureCard)7 MageObjectReference (mage.MageObjectReference)6