Search in sources :

Example 16 with DestroyTargetEffect

use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.

the class GravePerilEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    if (permanent != null) {
        if (permanent.sacrifice(source, game)) {
            Effect effect = new DestroyTargetEffect();
            effect.setTargetPointer(this.getTargetPointer());
            return effect.apply(game, source);
        }
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect)

Example 17 with DestroyTargetEffect

use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.

the class ZagrasThiefOfHeartbeatsTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
    if (permanent == null || !permanent.isCreature(game) || !permanent.isControlledBy(getControllerId())) {
        return false;
    }
    Permanent damaged = game.getPermanentOrLKIBattlefield(event.getTargetId());
    if (damaged == null || !permanent.isPlaneswalker(game)) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new DestroyTargetEffect().setTargetPointer(new FixedTarget(event.getTargetId(), game)));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect)

Example 18 with DestroyTargetEffect

use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.

the class BlindZealotTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player opponent = game.getPlayer(event.getPlayerId());
    if (opponent == null || !event.getSourceId().equals(getSourceId()) || !((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent("creature or planeswalker" + opponent.getLogName() + " controls");
    filter.add(new ControllerIdPredicate(opponent.getId()));
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DestroyTargetEffect(), false, "destroy target creature or planeswalker that player controls");
    this.getEffects().clear();
    this.addEffect(new DoWhenCostPaid(ability, new DiscardTargetCost(new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE)), "Discard a creature card?"));
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) DamagedEvent(mage.game.events.DamagedEvent) DoWhenCostPaid(mage.abilities.effects.common.DoWhenCostPaid) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) TargetCardInHand(mage.target.common.TargetCardInHand) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) FilterCreatureOrPlaneswalkerPermanent(mage.filter.common.FilterCreatureOrPlaneswalkerPermanent)

Example 19 with DestroyTargetEffect

use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.

the class FinaleOfEternityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    new DestroyTargetEffect(false, true).apply(game, source);
    if (source.getManaCostsToPay().getX() < 10) {
        return true;
    }
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    return player.moveCards(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game), Zone.BATTLEFIELD, source, game);
}
Also used : Player(mage.players.Player) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect)

Example 20 with DestroyTargetEffect

use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.

the class ChainOfAcidEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        UUID targetId = source.getFirstTarget();
        Permanent permanent = game.getPermanent(targetId);
        if (permanent != null) {
            Player affectedPlayer = game.getPlayer(permanent.getControllerId());
            if (affectedPlayer != null) {
                Effect effect = new DestroyTargetEffect();
                effect.setTargetPointer(new FixedTarget(targetId, game));
                effect.apply(game, source);
                if (affectedPlayer.chooseUse(Outcome.Copy, "Copy the spell?", source, game)) {
                    Spell spell = game.getStack().getSpell(source.getSourceId());
                    if (spell != null) {
                        spell.createCopyOnStack(game, source, affectedPlayer.getId(), true);
                    }
                }
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID) Spell(mage.game.stack.Spell)

Aggregations

DestroyTargetEffect (mage.abilities.effects.common.DestroyTargetEffect)20 FixedTarget (mage.target.targetpointer.FixedTarget)13 Permanent (mage.game.permanent.Permanent)10 Effect (mage.abilities.effects.Effect)9 OneShotEffect (mage.abilities.effects.OneShotEffect)8 Player (mage.players.Player)6 UUID (java.util.UUID)4 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)4 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)4 FilterPermanent (mage.filter.FilterPermanent)3 TargetPermanent (mage.target.TargetPermanent)3 Ability (mage.abilities.Ability)2 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)2 InvertCondition (mage.abilities.condition.InvertCondition)2 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)2 MageObject (mage.MageObject)1 MageObjectReference (mage.MageObjectReference)1 SpellAbility (mage.abilities.SpellAbility)1