use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.
the class CustomTestCard method addCustomEffect_TargetDamage.
/**
* Add target damage ability that can be called by text: "target damage xxx"
*
* @param controller
* @param damageAmount
*/
protected void addCustomEffect_TargetDamage(TestPlayer controller, int damageAmount) {
Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(damageAmount).setText("target damage " + damageAmount), new ManaCostsImpl(""));
ability.addTarget(new TargetAnyTarget());
addCustomCardWithAbility("target damage " + damageAmount + " for " + controller.getName(), controller, ability);
}
use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.
the class FieryEncoreEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Card card = player.discardOne(false, false, source, game);
player.drawCards(1, source, game);
if (card == null || card.isLand(game)) {
return true;
}
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(card.getManaValue()), false, "when you discard a nonland " + "card this way, {this} deals damage equal to that card's mana value to target creature or planeswalker");
ability.addTarget(new TargetCreatureOrPlaneswalker());
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.
the class LeylineOfCombustionTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
if (sourceObject == null) {
return false;
}
Player targetter = game.getPlayer(event.getPlayerId());
if (targetter == null || !targetter.hasOpponent(this.controllerId, game)) {
return false;
}
if (!event.getTargetId().equals(this.controllerId)) {
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent == null || !permanent.isControlledBy(this.controllerId)) {
return false;
}
}
// If a spell targets you and/or a permanent you control multiple times,
// or if a spell targets you and one or more permanents you control,
// Leyline of Combustion’s triggered ability triggers once.
Set<UUID> sourceObjects = (Set<UUID>) game.getState().getValue("sourceObjects" + this.id);
if (sourceObjects == null) {
sourceObjects = new HashSet<>();
}
if (!sourceObjects.add(sourceObject.getId())) {
return false;
}
game.getState().setValue("sourceObjects" + this.id, sourceObjects);
this.getEffects().clear();
Effect effect = new DamageTargetEffect(2);
effect.setTargetPointer(new FixedTarget(event.getPlayerId(), game));
this.addEffect(effect);
return true;
}
use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.
the class ScorchSpitterTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (this.getSourceId().equals(event.getSourceId())) {
this.getEffects().clear();
Effect effect = new DamageTargetEffect(1);
effect.setTargetPointer(new FixedTarget(game.getCombat().getDefenderId(event.getSourceId()), game));
this.addEffect(effect);
return true;
}
return false;
}
use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.
the class SentinelTowerWatcher method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.isActivePlayer(getControllerId()) && super.checkTrigger(event, game)) {
SentinelTowerWatcher watcher = game.getState().getWatcher(SentinelTowerWatcher.class);
if (watcher == null) {
return false;
}
List<MageObjectReference> spellsCast = watcher.getSpellsThisTurn();
MageObject object = game.getObject(event.getTargetId());
if (object == null || spellsCast == null) {
return false;
}
int damageToDeal = 0;
for (MageObjectReference mor : spellsCast) {
damageToDeal++;
if (mor.refersTo(object, game)) {
break;
}
}
damageInfo = " (<b>" + damageToDeal + " damage</b>)";
for (Effect effect : this.getEffects()) {
if (effect instanceof DamageTargetEffect) {
((DamageTargetEffect) effect).setAmount(StaticValue.get(damageToDeal));
return true;
}
}
}
return false;
}
Aggregations