Search in sources :

Example 1 with DoWhenCostPaid

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

the class SpareDaggerEffect method makeAbility.

@Override
protected Ability makeAbility(Game game, Ability source) {
    if (source == null || game == null) {
        return null;
    }
    String sourceName = source.getSourcePermanentIfItStillExists(game).getName();
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(1), false, "This creature deals 1 damage to any target");
    ability.addTarget(new TargetAnyTarget());
    return new AttacksTriggeredAbility(new DoWhenCostPaid(ability, useAttachedCost.copy().setMageObjectReference(source, game), "Sacrifice " + sourceName + "?"), false, "Whenever this creature attacks, you may sacrifice " + sourceName + ". When you do, this creature deals 1 damage to any target.");
}
Also used : DoWhenCostPaid(mage.abilities.effects.common.DoWhenCostPaid) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) AttacksTriggeredAbility(mage.abilities.common.AttacksTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 2 with DoWhenCostPaid

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

the class KappaTechWreckerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterPermanent filter = new FilterArtifactOrEnchantmentPermanent("artifact or enchantment that player controls");
    filter.add(new ControllerIdPredicate(getTargetPointer().getFirst(game, source)));
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ExileTargetEffect(), false);
    ability.addTarget(new TargetPermanent(filter));
    return new DoWhenCostPaid(ability, new RemoveCountersSourceCost(CounterType.DEATHTOUCH.createInstance()), "Remove a deathtouch counter?").apply(game, source);
}
Also used : FilterPermanent(mage.filter.FilterPermanent) RemoveCountersSourceCost(mage.abilities.costs.common.RemoveCountersSourceCost) DoWhenCostPaid(mage.abilities.effects.common.DoWhenCostPaid) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetPermanent(mage.target.TargetPermanent) FilterArtifactOrEnchantmentPermanent(mage.filter.common.FilterArtifactOrEnchantmentPermanent) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 3 with DoWhenCostPaid

use of mage.abilities.effects.common.DoWhenCostPaid 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)

Aggregations

ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)3 DoWhenCostPaid (mage.abilities.effects.common.DoWhenCostPaid)3 FilterPermanent (mage.filter.FilterPermanent)2 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)2 AttacksTriggeredAbility (mage.abilities.common.AttacksTriggeredAbility)1 DiscardTargetCost (mage.abilities.costs.common.DiscardTargetCost)1 RemoveCountersSourceCost (mage.abilities.costs.common.RemoveCountersSourceCost)1 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)1 DestroyTargetEffect (mage.abilities.effects.common.DestroyTargetEffect)1 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)1 FilterArtifactOrEnchantmentPermanent (mage.filter.common.FilterArtifactOrEnchantmentPermanent)1 FilterCreatureOrPlaneswalkerPermanent (mage.filter.common.FilterCreatureOrPlaneswalkerPermanent)1 DamagedEvent (mage.game.events.DamagedEvent)1 Player (mage.players.Player)1 TargetPermanent (mage.target.TargetPermanent)1 TargetAnyTarget (mage.target.common.TargetAnyTarget)1 TargetCardInHand (mage.target.common.TargetCardInHand)1