remove custom multitarget handling from DamageTargetEffect

This commit is contained in:
xenohedron 2025-11-10 01:52:30 -05:00
parent 1a1f7ec588
commit 0ae2c2b86e
16 changed files with 19 additions and 62 deletions

View file

@ -65,7 +65,7 @@ public final class AvalancheOfSector7 extends CardImpl {
class AvalancheOfSector7TriggeredAbility extends TriggeredAbilityImpl { class AvalancheOfSector7TriggeredAbility extends TriggeredAbilityImpl {
AvalancheOfSector7TriggeredAbility() { AvalancheOfSector7TriggeredAbility() {
super(Zone.BATTLEFIELD, new DamageTargetEffect(1, true, "that player", true)); super(Zone.BATTLEFIELD, new DamageTargetEffect(1, true, "that player"));
setTriggerPhrase("Whenever an opponent activates an ability of an artifact they control, "); setTriggerPhrase("Whenever an opponent activates an ability of an artifact they control, ");
} }

View file

@ -49,7 +49,7 @@ public final class BarretWallace extends CardImpl {
// Whenever Barret Wallace attacks, it deals damage equal to the number of equipped creatures you control to defending player. // Whenever Barret Wallace attacks, it deals damage equal to the number of equipped creatures you control to defending player.
this.addAbility(new AttacksTriggeredAbility( this.addAbility(new AttacksTriggeredAbility(
new DamageTargetEffect(xValue, true, "it", true) new DamageTargetEffect(xValue, true, "it")
.setText("it deals damage equal to the number of equipped creatures you control to defending player"), .setText("it deals damage equal to the number of equipped creatures you control to defending player"),
false, null, SetTargetPointer.PLAYER false, null, SetTargetPointer.PLAYER
).withRuleTextReplacement(true).addHint(hint)); ).withRuleTextReplacement(true).addHint(hint));

View file

@ -1,7 +1,6 @@
package mage.cards.b; package mage.cards.b;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
@ -75,9 +74,9 @@ class BedazzleEffect extends OneShotEffect {
if (permanent != null) { if (permanent != null) {
permanent.destroy(source, game, false); permanent.destroy(source, game, false);
} }
Effect effect = new DamageTargetEffect(StaticValue.get(2), true, "", true); Effect effect = new DamageTargetEffect(2);
effect.setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget(), game)); effect.setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget(), game));
effect.apply(game, source); effect.apply(game, source);
return true; return true;
} }
} }

View file

@ -46,7 +46,7 @@ public final class BurningTreeShaman extends CardImpl {
class BurningTreeShamanTriggeredAbility extends TriggeredAbilityImpl { class BurningTreeShamanTriggeredAbility extends TriggeredAbilityImpl {
BurningTreeShamanTriggeredAbility() { BurningTreeShamanTriggeredAbility() {
super(Zone.BATTLEFIELD, new DamageTargetEffect(StaticValue.get(1), true, "that player", true)); super(Zone.BATTLEFIELD, new DamageTargetEffect(StaticValue.get(1), true, "that player"));
} }
private BurningTreeShamanTriggeredAbility(final BurningTreeShamanTriggeredAbility ability) { private BurningTreeShamanTriggeredAbility(final BurningTreeShamanTriggeredAbility ability) {

View file

@ -22,11 +22,7 @@ public final class CutIn extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{R}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{R}");
// Cut In deals 4 damage to target creature. // Cut In deals 4 damage to target creature.
this.getSpellAbility().addEffect( this.getSpellAbility().addEffect(new DamageTargetEffect(4));
new DamageTargetEffect(4)
.setUseOnlyTargetPointer(true)
.setTargetPointer(new FirstTargetPointer())
);
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
// Create a Young Hero Role token attached to up to one target creature you control. // Create a Young Hero Role token attached to up to one target creature you control.

View file

@ -1,7 +1,6 @@
package mage.cards.e; package mage.cards.e;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CopyTargetStackObjectEffect; import mage.abilities.effects.common.CopyTargetStackObjectEffect;
@ -82,7 +81,7 @@ class ExplosionEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int xValue = CardUtil.getSourceCostsTag(game, source, "X", 0); int xValue = CardUtil.getSourceCostsTag(game, source, "X", 0);
Effect effect = new DamageTargetEffect(StaticValue.get(xValue), true, "", true); Effect effect = new DamageTargetEffect(xValue);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game)); effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
effect.apply(game, source); effect.apply(game, source);
Player player = game.getPlayer(source.getTargets().get(1).getFirstTarget()); Player player = game.getPlayer(source.getTargets().get(1).getFirstTarget());

View file

@ -37,7 +37,7 @@ public final class FieryAnnihilation extends CardImpl {
// Fiery Annihilation deals 5 damage to target creature. Exile up to one target Equipment attached to that creature. If that creature would die this turn, exile it instead. // Fiery Annihilation deals 5 damage to target creature. Exile up to one target Equipment attached to that creature. If that creature would die this turn, exile it instead.
this.getSpellAbility().addEffect(new DamageTargetEffect( this.getSpellAbility().addEffect(new DamageTargetEffect(
5, true, "target creature", true 5, true, "target creature"
)); ));
this.getSpellAbility().addEffect(new ExileTargetEffect() this.getSpellAbility().addEffect(new ExileTargetEffect()
.setTargetPointer(new SecondTargetPointer()) .setTargetPointer(new SecondTargetPointer())

View file

@ -73,7 +73,7 @@ public final class FlamescrollCelebrant extends ModalDoubleFacedCard {
class FlamescrollCelebrantTriggeredAbility extends TriggeredAbilityImpl { class FlamescrollCelebrantTriggeredAbility extends TriggeredAbilityImpl {
FlamescrollCelebrantTriggeredAbility() { FlamescrollCelebrantTriggeredAbility() {
super(Zone.BATTLEFIELD, new DamageTargetEffect(StaticValue.get(1), true, "that player", true)); super(Zone.BATTLEFIELD, new DamageTargetEffect(StaticValue.get(1), true, "that player"));
} }
private FlamescrollCelebrantTriggeredAbility(final FlamescrollCelebrantTriggeredAbility ability) { private FlamescrollCelebrantTriggeredAbility(final FlamescrollCelebrantTriggeredAbility ability) {

View file

@ -48,7 +48,7 @@ public final class HarshMentor extends CardImpl {
class HarshMentorTriggeredAbility extends TriggeredAbilityImpl { class HarshMentorTriggeredAbility extends TriggeredAbilityImpl {
HarshMentorTriggeredAbility() { HarshMentorTriggeredAbility() {
super(Zone.BATTLEFIELD, new DamageTargetEffect(StaticValue.get(2), true, "that player", true)); super(Zone.BATTLEFIELD, new DamageTargetEffect(StaticValue.get(2), true, "that player"));
} }
private HarshMentorTriggeredAbility(final HarshMentorTriggeredAbility ability) { private HarshMentorTriggeredAbility(final HarshMentorTriggeredAbility ability) {

View file

@ -1,4 +1,3 @@
package mage.cards.i; package mage.cards.i;
import java.util.HashMap; import java.util.HashMap;
@ -50,8 +49,8 @@ public final class IchneumonDruid extends CardImpl {
class IchneumonDruidAbility extends TriggeredAbilityImpl { class IchneumonDruidAbility extends TriggeredAbilityImpl {
public IchneumonDruidAbility() { IchneumonDruidAbility() {
super(Zone.BATTLEFIELD, new DamageTargetEffect(StaticValue.get(4), false, "that player", true)); super(Zone.BATTLEFIELD, new DamageTargetEffect(StaticValue.get(4), false, "that player"));
} }
private IchneumonDruidAbility(final IchneumonDruidAbility ability) { private IchneumonDruidAbility(final IchneumonDruidAbility ability) {
@ -95,7 +94,7 @@ class IchneumonDruidWatcher extends Watcher {
private final Map<UUID, Integer> playerInstantCount = new HashMap<>(); private final Map<UUID, Integer> playerInstantCount = new HashMap<>();
public IchneumonDruidWatcher() { IchneumonDruidWatcher() {
super(WatcherScope.GAME); super(WatcherScope.GAME);
} }

View file

@ -67,7 +67,7 @@ public final class ImmolationShaman extends CardImpl {
class ImmolationShamanTriggeredAbility extends TriggeredAbilityImpl { class ImmolationShamanTriggeredAbility extends TriggeredAbilityImpl {
ImmolationShamanTriggeredAbility() { ImmolationShamanTriggeredAbility() {
super(Zone.BATTLEFIELD, new DamageTargetEffect(StaticValue.get(1), true, "that player", true)); super(Zone.BATTLEFIELD, new DamageTargetEffect(StaticValue.get(1), true, "that player"));
setTriggerPhrase("Whenever an opponent activates an ability of an artifact, creature, or land that isn't a mana ability, "); setTriggerPhrase("Whenever an opponent activates an ability of an artifact, creature, or land that isn't a mana ability, ");
} }

View file

@ -23,7 +23,7 @@ public final class JeskaiRevelation extends CardImpl {
this.getSpellAbility().addEffect(new ReturnToHandTargetEffect()); this.getSpellAbility().addEffect(new ReturnToHandTargetEffect());
this.getSpellAbility().addTarget(new TargetSpellOrPermanent()); this.getSpellAbility().addTarget(new TargetSpellOrPermanent());
this.getSpellAbility().addEffect(new DamageTargetEffect( this.getSpellAbility().addEffect(new DamageTargetEffect(
4, true, "any target", true 4, true, "any target"
).setTargetPointer(new SecondTargetPointer())); ).setTargetPointer(new SecondTargetPointer()));
this.getSpellAbility().addTarget(new TargetAnyTarget()); this.getSpellAbility().addTarget(new TargetAnyTarget());
this.getSpellAbility().addEffect(new CreateTokenEffect(new MonasteryMentorToken(), 2)); this.getSpellAbility().addEffect(new CreateTokenEffect(new MonasteryMentorToken(), 2));

View file

@ -1,11 +1,9 @@
package mage.cards.m; package mage.cards.m;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect; import mage.abilities.effects.common.counter.AddCountersTargetEffect;
@ -37,7 +35,7 @@ public final class ManticoreOfTheGauntlet extends CardImpl {
counters.setText("put a -1/-1 counter on target creature you control"); counters.setText("put a -1/-1 counter on target creature you control");
counters.setTargetPointer(new FirstTargetPointer()); counters.setTargetPointer(new FirstTargetPointer());
Effect damage = new DamageTargetEffect(StaticValue.get(3), true, "", true); Effect damage = new DamageTargetEffect(3);
damage.setText("{this} deals 3 damage to target opponent or planeswalker."); damage.setText("{this} deals 3 damage to target opponent or planeswalker.");
damage.setTargetPointer(new SecondTargetPointer()); damage.setTargetPointer(new SecondTargetPointer());

View file

@ -52,7 +52,6 @@ public final class NivMizzetGuildpact extends CardImpl {
// Whenever Niv-Mizzet, Guildpact deals combat damage to a player, it deals X damage to any target, target player draws X cards, and you gain X life, where X is the number of different color pairs among permanents you control that are exactly two colors. // Whenever Niv-Mizzet, Guildpact deals combat damage to a player, it deals X damage to any target, target player draws X cards, and you gain X life, where X is the number of different color pairs among permanents you control that are exactly two colors.
Ability ability = new DealsCombatDamageToAPlayerTriggeredAbility( Ability ability = new DealsCombatDamageToAPlayerTriggeredAbility(
new DamageTargetEffect(NivMizzetGuildpactCount.instance) new DamageTargetEffect(NivMizzetGuildpactCount.instance)
.setUseOnlyTargetPointer(true)
.setText("it deals X damage to any target"), false); .setText("it deals X damage to any target"), false);
ability.addTarget(new TargetAnyTarget()); ability.addTarget(new TargetAnyTarget());
ability.addEffect(new DrawCardTargetEffect(NivMizzetGuildpactCount.instance) ability.addEffect(new DrawCardTargetEffect(NivMizzetGuildpactCount.instance)

View file

@ -1,4 +1,3 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID; import java.util.UUID;
@ -27,7 +26,7 @@ public final class Simulacrum extends CardImpl {
// You gain life equal to the damage dealt to you this turn. Simulacrum deals damage to target creature you control equal to the damage dealt to you this turn. // You gain life equal to the damage dealt to you this turn. Simulacrum deals damage to target creature you control equal to the damage dealt to you this turn.
this.getSpellAbility().addEffect(new GainLifeEffect(new SimulacrumAmount(), "You gain life equal to the damage dealt to you this turn.")); this.getSpellAbility().addEffect(new GainLifeEffect(new SimulacrumAmount(), "You gain life equal to the damage dealt to you this turn."));
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
Effect effect = new DamageTargetEffect(new SimulacrumAmount(), true, "target creature you control", true); Effect effect = new DamageTargetEffect(new SimulacrumAmount(), true, "target creature you control");
effect.setText(" {this} deals damage to target creature you control equal to the damage dealt to you this turn."); effect.setText(" {this} deals damage to target creature you control equal to the damage dealt to you this turn.");
this.getSpellAbility().addEffect(effect); this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addWatcher(new AmountOfDamageAPlayerReceivedThisTurnWatcher()); this.getSpellAbility().addWatcher(new AmountOfDamageAPlayerReceivedThisTurnWatcher());

View file

@ -4,7 +4,6 @@ import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.game.Game; import mage.game.Game;
@ -24,7 +23,6 @@ public class DamageTargetEffect extends OneShotEffect {
protected DynamicValue amount; protected DynamicValue amount;
protected boolean preventable; protected boolean preventable;
protected String targetDescription; protected String targetDescription;
protected boolean useOnlyTargetPointer; // TODO: investigate why do we ignore targetPointer by default??
protected String sourceName = "{this}"; protected String sourceName = "{this}";
public DamageTargetEffect(int amount) { public DamageTargetEffect(int amount) {
@ -44,10 +42,6 @@ public class DamageTargetEffect extends OneShotEffect {
this(StaticValue.get(amount), preventable, targetDescription); this(StaticValue.get(amount), preventable, targetDescription);
} }
public DamageTargetEffect(int amount, boolean preventable, String targetDescription, boolean useOnlyTargetPointer) {
this(StaticValue.get(amount), preventable, targetDescription, useOnlyTargetPointer);
}
public DamageTargetEffect(int amount, boolean preventable, String targetDescription, String whoDealDamageName) { public DamageTargetEffect(int amount, boolean preventable, String targetDescription, String whoDealDamageName) {
this(StaticValue.get(amount), preventable, targetDescription); this(StaticValue.get(amount), preventable, targetDescription);
this.sourceName = whoDealDamageName; this.sourceName = whoDealDamageName;
@ -67,15 +61,10 @@ public class DamageTargetEffect extends OneShotEffect {
} }
public DamageTargetEffect(DynamicValue amount, boolean preventable, String targetDescription) { public DamageTargetEffect(DynamicValue amount, boolean preventable, String targetDescription) {
this(amount, preventable, targetDescription, false);
}
public DamageTargetEffect(DynamicValue amount, boolean preventable, String targetDescription, boolean useOnlyTargetPointer) {
super(Outcome.Damage); super(Outcome.Damage);
this.amount = amount; this.amount = amount;
this.preventable = preventable; this.preventable = preventable;
this.targetDescription = targetDescription; this.targetDescription = targetDescription;
this.useOnlyTargetPointer = useOnlyTargetPointer;
} }
public int getAmount() { public int getAmount() {
@ -95,21 +84,15 @@ public class DamageTargetEffect extends OneShotEffect {
this.amount = effect.amount.copy(); this.amount = effect.amount.copy();
this.preventable = effect.preventable; this.preventable = effect.preventable;
this.targetDescription = effect.targetDescription; this.targetDescription = effect.targetDescription;
this.useOnlyTargetPointer = effect.useOnlyTargetPointer;
this.sourceName = effect.sourceName; this.sourceName = effect.sourceName;
} }
@Override
public DamageTargetEffect withTargetDescription(String targetDescription) { public DamageTargetEffect withTargetDescription(String targetDescription) {
this.targetDescription = targetDescription; this.targetDescription = targetDescription;
return this; return this;
} }
// TODO: this should most likely be refactored to not be needed and always use target pointer.
public Effect setUseOnlyTargetPointer(boolean useOnlyTargetPointer) {
this.useOnlyTargetPointer = useOnlyTargetPointer;
return this;
}
@Override @Override
public DamageTargetEffect copy() { public DamageTargetEffect copy() {
return new DamageTargetEffect(this); return new DamageTargetEffect(this);
@ -117,21 +100,6 @@ public class DamageTargetEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
if (!useOnlyTargetPointer && source.getTargets().size() > 1) {
for (Target target : source.getTargets()) {
for (UUID targetId : target.getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
permanent.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, preventable);
}
Player player = game.getPlayer(targetId);
if (player != null) {
player.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, preventable);
}
}
}
return true;
}
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) { for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
Permanent permanent = game.getPermanent(targetId); Permanent permanent = game.getPermanent(targetId);
if (permanent != null) { if (permanent != null) {
@ -154,7 +122,7 @@ public class DamageTargetEffect extends OneShotEffect {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String message = amount.getMessage(); String message = amount.getMessage();
sb.append(this.sourceName).append(" deals "); sb.append(this.sourceName).append(" deals ");
if (message.isEmpty() || !message.equals("1")) { if (!message.equals("1")) {
sb.append(amount); sb.append(amount);
} }
if (!sb.toString().endsWith(" ")) { if (!sb.toString().endsWith(" ")) {