From 03100a932ea1e5023dfaa64f83f5dc57f2367624 Mon Sep 17 00:00:00 2001 From: xenohedron <12538125+xenohedron@users.noreply.github.com> Date: Sun, 9 Nov 2025 23:47:44 -0500 Subject: [PATCH] new DamageTargetAndTargetControllerEffect --- .../src/mage/cards/c/ChandrasOutrage.java | 14 ++-- ...DamageTargetAndTargetControllerEffect.java | 65 +++++++++++++++++++ 2 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 Mage/src/main/java/mage/abilities/effects/common/DamageTargetAndTargetControllerEffect.java diff --git a/Mage.Sets/src/mage/cards/c/ChandrasOutrage.java b/Mage.Sets/src/mage/cards/c/ChandrasOutrage.java index ddaaed5fe15..e3517234cdf 100644 --- a/Mage.Sets/src/mage/cards/c/ChandrasOutrage.java +++ b/Mage.Sets/src/mage/cards/c/ChandrasOutrage.java @@ -1,16 +1,13 @@ - - package mage.cards.c; -import java.util.UUID; -import mage.abilities.effects.Effect; -import mage.abilities.effects.common.DamageTargetControllerEffect; -import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.DamageTargetAndTargetControllerEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -21,10 +18,7 @@ public final class ChandrasOutrage extends CardImpl { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{R}{R}"); // Chandra's Outrage deals 4 damage to target creature and 2 damage to that creature's controller. - this.getSpellAbility().addEffect(new DamageTargetEffect(4)); - Effect effect = new DamageTargetControllerEffect(2); - effect.setText("and 2 damage to that creature's controller"); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(new DamageTargetAndTargetControllerEffect(4, 2)); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageTargetAndTargetControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageTargetAndTargetControllerEffect.java new file mode 100644 index 00000000000..de20b0cb6aa --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageTargetAndTargetControllerEffect.java @@ -0,0 +1,65 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author xenohedron + */ +public class DamageTargetAndTargetControllerEffect extends OneShotEffect { + + private final int firstAmount; + private final int secondAmount; + + /** + * Deals simultaneous damage to the target and to the controller of the target + */ + public DamageTargetAndTargetControllerEffect(int firstAmount, int secondAmount) { + super(Outcome.Damage); + this.firstAmount = firstAmount; + this.secondAmount = secondAmount; + } + + protected DamageTargetAndTargetControllerEffect(final DamageTargetAndTargetControllerEffect effect) { + super(effect); + this.firstAmount = effect.firstAmount; + this.secondAmount = effect.secondAmount; + } + + @Override + public DamageTargetAndTargetControllerEffect copy() { + return new DamageTargetAndTargetControllerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + for (UUID targetId : this.getTargetPointer().getTargets(game, source)) { + Permanent permanent = game.getPermanent(targetId); + if (permanent != null) { + permanent.damage(firstAmount, source.getSourceId(), source, game); + Player player = game.getPlayer(permanent.getControllerId()); + if (player != null) { + player.damage(secondAmount, source.getSourceId(), source, game); + } + } + } + return true; + } + + @Override + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + return "{this} deals " + firstAmount + "damage to " + + getTargetPointer().describeTargets(mode.getTargets(), "that creature") + + " and " + secondAmount + "damage to that creature's controller"; + } +}