Search in sources :

Example 31 with DelayedTriggeredAbility

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

the class ArcaneDenialEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = null;
    boolean countered = false;
    UUID targetId = this.getTargetPointer().getFirst(game, source);
    if (targetId != null) {
        controller = game.getPlayer(game.getControllerId(targetId));
    }
    if (targetId != null && game.getStack().counter(targetId, source, game)) {
        countered = true;
    }
    if (controller != null) {
        Effect effect = new DrawCardTargetEffect(StaticValue.get(2), false, true);
        effect.setTargetPointer(new FixedTarget(controller.getId()));
        effect.setText("Its controller may draw up to two cards");
        DelayedTriggeredAbility ability = new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(effect);
        game.addDelayedTriggeredAbility(ability, source);
    }
    return countered;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) AtTheBeginOfNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) UUID(java.util.UUID)

Example 32 with DelayedTriggeredAbility

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

the class ChancellorOfTheAnnexDelayedTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (UUID opponentId : game.getOpponents(source.getControllerId())) {
        DelayedTriggeredAbility ability = new ChancellorOfTheAnnexDelayedTriggeredAbility(opponentId);
        game.addDelayedTriggeredAbility(ability, source);
    }
    return true;
}
Also used : DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) UUID(java.util.UUID)

Example 33 with DelayedTriggeredAbility

use of mage.abilities.DelayedTriggeredAbility 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 34 with DelayedTriggeredAbility

use of mage.abilities.DelayedTriggeredAbility 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)

Example 35 with DelayedTriggeredAbility

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

the class WhipOfErebosReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && card != null) {
        if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
            Permanent creature = game.getPermanent(card.getId());
            if (creature != null) {
                // gains haste
                ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
                effect.setTargetPointer(new FixedTarget(creature, game));
                game.addEffect(effect, source);
                // Exile at begin of next end step
                ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
                exileEffect.setTargetPointer(new FixedTarget(creature, 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) Permanent(mage.game.permanent.Permanent) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Card(mage.cards.Card) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

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