Search in sources :

Example 1 with DestroyTargetEffect

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

the class NorrittDelayedDestroyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    DestroyTargetEffect effect = new DestroyTargetEffect();
    effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
    AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY, new InvertCondition(TargetAttackedThisTurnCondition.instance));
    delayedAbility.getDuration();
    delayedAbility.getTargets().addAll(source.getTargets());
    game.addDelayedTriggeredAbility(delayedAbility, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) InvertCondition(mage.abilities.condition.InvertCondition)

Example 2 with DestroyTargetEffect

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

the class TransmogrifyingWandEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getFirstTarget());
    if (creature == null) {
        return false;
    }
    Effect effect = new CreateTokenTargetEffect(new OxToken());
    effect.setTargetPointer(new FixedTarget(creature.getControllerId(), game));
    new DestroyTargetEffect().apply(game, source);
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) OxToken(mage.game.permanent.token.OxToken) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect)

Example 3 with DestroyTargetEffect

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

the class FatalLoreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player chosenOpponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (controller != null && chosenOpponent != null) {
        if (chosenOpponent.chooseUse(Outcome.Neutral, "If you choose Yes, the controller draws three cards. If no, the controller gets to destroy up to two target creatures that you control and you get to draw up to 3 cards. Those creatures can't be regenerated.", source, game)) {
            controller.drawCards(3, source, game);
        } else {
            FilterCreaturePermanent filter = new FilterCreaturePermanent("chosen opponent's creature");
            filter.add(new ControllerIdPredicate(chosenOpponent.getId()));
            TargetCreaturePermanent target = new TargetCreaturePermanent(0, 2, filter, false);
            if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.DestroyPermanent, target, source.getSourceId(), game)) {
                for (UUID targetId : target.getTargets()) {
                    Effect destroyCreature = new DestroyTargetEffect(true);
                    destroyCreature.setTargetPointer(new FixedTarget(targetId, game));
                    destroyCreature.apply(game, source);
                }
                Effect opponentDrawsCards = new DrawCardTargetEffect(StaticValue.get(3), false, true);
                opponentDrawsCards.setTargetPointer(new FixedTarget(chosenOpponent.getId()));
                opponentDrawsCards.apply(game, source);
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID)

Example 4 with DestroyTargetEffect

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

the class DestroyPlaneswalkerWhenDamagedTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent permanent = getSourcePermanentIfItStillExists(game);
    if (permanent == null) {
        return false;
    }
    boolean applies = filter != null ? permanent.isPlaneswalker(game) && filter.match(permanent, game) : event.getSourceId().equals(getSourceId());
    if (applies) {
        Effect effect = new DestroyTargetEffect();
        effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
        this.getEffects().clear();
        this.addEffect(effect);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterPermanent(mage.filter.FilterPermanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) Effect(mage.abilities.effects.Effect)

Example 5 with DestroyTargetEffect

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

the class EvilTwinPredicate method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{U}{B}"));
    ability.addCost(new TapSourceCost());
    ability.addTarget(new TargetCreaturePermanent(filter));
    blueprint.getAbilities().add(ability);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) EntersBattlefieldAbility(mage.abilities.common.EntersBattlefieldAbility) Ability(mage.abilities.Ability) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TapSourceCost(mage.abilities.costs.common.TapSourceCost)

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