Search in sources :

Example 26 with DelayedTriggeredAbility

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

the class NalathniDragonEffect 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 27 with DelayedTriggeredAbility

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

the class NahiriTheHarbingerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (controller.searchLibrary(target, source, game)) {
            if (!target.getTargets().isEmpty()) {
                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) {
                        ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
                        effect.setTargetPointer(new FixedTarget(permanent.getId(), permanent.getZoneChangeCounter(game)));
                        game.addEffect(effect, source);
                        Effect effect2 = new ReturnToHandTargetEffect();
                        effect2.setTargetPointer(new FixedTarget(permanent.getId(), permanent.getZoneChangeCounter(game)));
                        DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect2);
                        game.addDelayedTriggeredAbility(delayedAbility, source);
                    }
                }
            }
            controller.shuffleLibrary(source, game);
        }
        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) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SearchEffect(mage.abilities.effects.SearchEffect) Effect(mage.abilities.effects.Effect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 28 with DelayedTriggeredAbility

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

the class PlaneboundAccompliceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    if (!controller.chooseUse(Outcome.PutCardInPlay, "Put a planeswalker card from your hand onto the battlefield?", source, game)) {
        return true;
    }
    TargetCardInHand target = new TargetCardInHand(filter);
    if (!controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
        return true;
    }
    Card card = game.getCard(target.getFirstTarget());
    if (card == null) {
        return false;
    }
    if (!controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        return false;
    }
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent == null) {
        return true;
    }
    SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + card.getName(), source.getControllerId());
    sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
    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) TargetCardInHand(mage.target.common.TargetCardInHand) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) FilterCard(mage.filter.FilterCard) FilterPlaneswalkerCard(mage.filter.common.FilterPlaneswalkerCard) Card(mage.cards.Card)

Example 29 with DelayedTriggeredAbility

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

the class SurpriseDeploymentEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (controller.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) {
            TargetCardInHand target = new TargetCardInHand(filter);
            if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
                        Permanent permanent = game.getPermanent(card.getId());
                        if (permanent != null) {
                            ReturnToHandTargetEffect effect = new ReturnToHandTargetEffect();
                            effect.setTargetPointer(new FixedTarget(permanent, game));
                            DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
                            game.addDelayedTriggeredAbility(delayedAbility, source);
                            return true;
                        }
                    }
                }
                return false;
            }
        }
        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) TargetCardInHand(mage.target.common.TargetCardInHand) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 30 with DelayedTriggeredAbility

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

the class TheLocustGodEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // Create delayed triggered ability
    Effect effect = new ReturnToHandTargetEffect();
    effect.setText("return {this} to its owner's hand");
    effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
    game.addDelayedTriggeredAbility(delayedAbility, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) DrawDiscardControllerEffect(mage.abilities.effects.common.DrawDiscardControllerEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect)

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