From 6d90539b7b43d6a5e90ebda7a36b3fc8ea68c800 Mon Sep 17 00:00:00 2001 From: LoneFox Date: Tue, 29 Sep 2015 12:19:50 +0300 Subject: [PATCH] Fix DealsDamageToOpponentTriggeredAbility unconditionally overwriting the targets of any effects added to it. This fixes at least Charnelhoard Wurm, and possibly other similar abilities. --- .../mage/sets/apocalypse/FungalShambler.java | 2 +- .../mage/sets/commander/HydraOmnivore.java | 2 +- .../src/mage/sets/legends/NicolBolas.java | 2 +- .../mage/sets/magic2010/HypnoticSpecter.java | 2 +- .../portalthreekingdoms/WeiNightRaiders.java | 2 +- .../ZhangLiaoHeroOfHefei.java | 2 +- ...DealsDamageToOpponentTriggeredAbility.java | 20 +++++++++++++------ 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Mage.Sets/src/mage/sets/apocalypse/FungalShambler.java b/Mage.Sets/src/mage/sets/apocalypse/FungalShambler.java index 385de243c2..b9f0b5e9ec 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/FungalShambler.java +++ b/Mage.Sets/src/mage/sets/apocalypse/FungalShambler.java @@ -58,7 +58,7 @@ public class FungalShambler extends CardImpl { // Whenever Fungal Shambler deals damage to an opponent, you draw a card and that opponent discards a card. Effect effect = new DrawCardSourceControllerEffect(1); effect.setText("you draw a card"); - Ability ability = new DealsDamageToOpponentTriggeredAbility(effect, false); + Ability ability = new DealsDamageToOpponentTriggeredAbility(effect, false, false, true); effect = new DiscardTargetEffect(1); effect.setText("and that opponent discards a card"); ability.addEffect(effect); diff --git a/Mage.Sets/src/mage/sets/commander/HydraOmnivore.java b/Mage.Sets/src/mage/sets/commander/HydraOmnivore.java index fea88abc3d..2f56264ff0 100644 --- a/Mage.Sets/src/mage/sets/commander/HydraOmnivore.java +++ b/Mage.Sets/src/mage/sets/commander/HydraOmnivore.java @@ -55,7 +55,7 @@ public class HydraOmnivore extends CardImpl { this.toughness = new MageInt(8); // Whenever Hydra Omnivore deals combat damage to an opponent, it deals that much damage to each other opponent. - this.addAbility(new DealsDamageToOpponentTriggeredAbility(new HydraOmnivoreEffect(), false, true)); + this.addAbility(new DealsDamageToOpponentTriggeredAbility(new HydraOmnivoreEffect(), false, true, true)); } public HydraOmnivore(final HydraOmnivore card) { diff --git a/Mage.Sets/src/mage/sets/legends/NicolBolas.java b/Mage.Sets/src/mage/sets/legends/NicolBolas.java index 8bf534631e..b53d646381 100644 --- a/Mage.Sets/src/mage/sets/legends/NicolBolas.java +++ b/Mage.Sets/src/mage/sets/legends/NicolBolas.java @@ -62,7 +62,7 @@ public class NicolBolas extends CardImpl { this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceUnlessPaysEffect(new ManaCostsImpl("{U}{B}{R}")), TargetController.YOU, false)); // Whenever Nicol Bolas deals damage to an opponent, that player discards his or her hand. - this.addAbility(new DealsDamageToOpponentTriggeredAbility(new DiscardHandTargetEffect("that player"), false)); + this.addAbility(new DealsDamageToOpponentTriggeredAbility(new DiscardHandTargetEffect("that player"), false, false, true)); } public NicolBolas(final NicolBolas card) { diff --git a/Mage.Sets/src/mage/sets/magic2010/HypnoticSpecter.java b/Mage.Sets/src/mage/sets/magic2010/HypnoticSpecter.java index e120011e38..7dcc9eda4e 100644 --- a/Mage.Sets/src/mage/sets/magic2010/HypnoticSpecter.java +++ b/Mage.Sets/src/mage/sets/magic2010/HypnoticSpecter.java @@ -54,7 +54,7 @@ public class HypnoticSpecter extends CardImpl { this.addAbility(FlyingAbility.getInstance()); // Whenever Hypnotic Specter deals damage to an opponent, that player discards a card at random. - this.addAbility(new DealsDamageToOpponentTriggeredAbility(new DiscardTargetEffect(1, true))); + this.addAbility(new DealsDamageToOpponentTriggeredAbility(new DiscardTargetEffect(1, true), false, false, true)); } public HypnoticSpecter(final HypnoticSpecter card) { diff --git a/Mage.Sets/src/mage/sets/portalthreekingdoms/WeiNightRaiders.java b/Mage.Sets/src/mage/sets/portalthreekingdoms/WeiNightRaiders.java index 5b20e8e973..4d3b709a32 100644 --- a/Mage.Sets/src/mage/sets/portalthreekingdoms/WeiNightRaiders.java +++ b/Mage.Sets/src/mage/sets/portalthreekingdoms/WeiNightRaiders.java @@ -53,7 +53,7 @@ public class WeiNightRaiders extends CardImpl { // Horsemanship this.addAbility(HorsemanshipAbility.getInstance()); // Whenever Wei Night Raiders deals damage to an opponent, that player discards a card. - this.addAbility(new DealsDamageToOpponentTriggeredAbility(new DiscardTargetEffect(1), false)); + this.addAbility(new DealsDamageToOpponentTriggeredAbility(new DiscardTargetEffect(1), false, false, true)); } public WeiNightRaiders(final WeiNightRaiders card) { diff --git a/Mage.Sets/src/mage/sets/portalthreekingdoms/ZhangLiaoHeroOfHefei.java b/Mage.Sets/src/mage/sets/portalthreekingdoms/ZhangLiaoHeroOfHefei.java index 7d3cd94740..da66b3b4b9 100644 --- a/Mage.Sets/src/mage/sets/portalthreekingdoms/ZhangLiaoHeroOfHefei.java +++ b/Mage.Sets/src/mage/sets/portalthreekingdoms/ZhangLiaoHeroOfHefei.java @@ -51,7 +51,7 @@ public class ZhangLiaoHeroOfHefei extends CardImpl { this.toughness = new MageInt(3); // Whenever Zhang Liao, Hero of Hefei deals damage to an opponent, that opponent discards a card. - this.addAbility(new DealsDamageToOpponentTriggeredAbility(new DiscardTargetEffect(1), false)); + this.addAbility(new DealsDamageToOpponentTriggeredAbility(new DiscardTargetEffect(1), false, false, true)); } public ZhangLiaoHeroOfHefei(final ZhangLiaoHeroOfHefei card) { diff --git a/Mage/src/mage/abilities/common/DealsDamageToOpponentTriggeredAbility.java b/Mage/src/mage/abilities/common/DealsDamageToOpponentTriggeredAbility.java index 811b091401..3f9f5d30f0 100644 --- a/Mage/src/mage/abilities/common/DealsDamageToOpponentTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/DealsDamageToOpponentTriggeredAbility.java @@ -40,24 +40,30 @@ import mage.target.targetpointer.FixedTarget; */ public class DealsDamageToOpponentTriggeredAbility extends TriggeredAbilityImpl { - boolean onlyCombat; + private final boolean onlyCombat, setTargetPointer; public DealsDamageToOpponentTriggeredAbility(Effect effect) { - this(effect, false, false); + this(effect, false, false, false); } public DealsDamageToOpponentTriggeredAbility(Effect effect, boolean optional) { - this(effect, optional, false); + this(effect, optional, false, false); } public DealsDamageToOpponentTriggeredAbility(Effect effect, boolean optional, boolean onlyCombat) { + this(effect, optional, onlyCombat, false); + } + + public DealsDamageToOpponentTriggeredAbility(Effect effect, boolean optional, boolean onlyCombat, boolean setTargetPointer) { super(Zone.BATTLEFIELD, effect, optional); this.onlyCombat = onlyCombat; + this.setTargetPointer = setTargetPointer; } public DealsDamageToOpponentTriggeredAbility(final DealsDamageToOpponentTriggeredAbility ability) { super(ability); this.onlyCombat = ability.onlyCombat; + this.setTargetPointer = ability.setTargetPointer; } @Override @@ -80,9 +86,11 @@ public class DealsDamageToOpponentTriggeredAbility extends TriggeredAbilityImpl return false; } } - for (Effect effect : getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getTargetId())); - effect.setValue("damage", event.getAmount()); + if(setTargetPointer) { + for (Effect effect : getEffects()) { + effect.setTargetPointer(new FixedTarget(event.getTargetId())); + effect.setValue("damage", event.getAmount()); + } } return true; }