Search in sources :

Example 1 with DamageTargetEffect

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

the class HeartPiercerManticoreSacrificeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Target target = new TargetControlledCreaturePermanent(1, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true);
    if (!controller.choose(outcome, target, source.getSourceId(), game)) {
        return false;
    }
    Permanent toSacrifice = game.getPermanent(target.getFirstTarget());
    if (toSacrifice == null) {
        return false;
    }
    int power = toSacrifice.getPower().getValue();
    if (!toSacrifice.sacrifice(source, game)) {
        return false;
    }
    ReflexiveTriggeredAbility trigger = new ReflexiveTriggeredAbility(new DamageTargetEffect(power), false, "{this} deals damage equal to that creature's power to any target.");
    trigger.addTarget(new TargetAnyTarget());
    game.fireReflexiveTriggeredAbility(trigger, source);
    return true;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetAnyTarget(mage.target.common.TargetAnyTarget) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 2 with DamageTargetEffect

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

the class ScentOfCinderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter));
    if (!cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    int xValue = cost.getNumberRevealedCards();
    return new DamageTargetEffect(xValue).apply(game, source);
}
Also used : RevealTargetFromHandCost(mage.abilities.costs.common.RevealTargetFromHandCost) TargetCardInHand(mage.target.common.TargetCardInHand) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 3 with DamageTargetEffect

use of mage.abilities.effects.common.DamageTargetEffect 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 4 with DamageTargetEffect

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

the class ExplosionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = source.getManaCostsToPay().getX();
    Effect effect = new DamageTargetEffect(StaticValue.get(xValue), true, "", true);
    effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
    effect.apply(game, source);
    Player player = game.getPlayer(source.getTargets().get(1).getFirstTarget());
    if (player != null) {
        player.drawCards(xValue, source, game);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) CopyTargetSpellEffect(mage.abilities.effects.common.CopyTargetSpellEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 5 with DamageTargetEffect

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

the class LeylineTyrantDamageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
    String manaString;
    if (costX == 0) {
        manaString = "{0}";
    } else {
        manaString = "";
        for (int i = 0; i < costX; i++) {
            manaString += "{R}";
        }
    }
    Cost cost = new ManaCostsImpl<>(manaString);
    cost.clearPaid();
    if (!cost.pay(source, game, source, source.getControllerId(), false)) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(costX), false, "{this} deals " + costX + " damage to any target");
    ability.addTarget(new TargetAnyTarget());
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : Player(mage.players.Player) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Aggregations

DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)50 Player (mage.players.Player)22 TargetAnyTarget (mage.target.common.TargetAnyTarget)20 Permanent (mage.game.permanent.Permanent)17 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)15 Ability (mage.abilities.Ability)12 Effect (mage.abilities.effects.Effect)11 FixedTarget (mage.target.targetpointer.FixedTarget)9 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)8 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)8 Test (org.junit.Test)8 OneShotEffect (mage.abilities.effects.OneShotEffect)7 Card (mage.cards.Card)7 TargetPermanent (mage.target.TargetPermanent)7 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)6 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)5 LeavesBattlefieldTriggeredAbility (mage.abilities.common.LeavesBattlefieldTriggeredAbility)4 GainLifeEffect (mage.abilities.effects.common.GainLifeEffect)4 SimpleManaAbility (mage.abilities.mana.SimpleManaAbility)4 UUID (java.util.UUID)3