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;
}
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);
}
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.");
}
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;
}
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;
}
Aggregations