From b26a5730fad9b6fd672f316697e5c7884a247130 Mon Sep 17 00:00:00 2001 From: "ludwig.hirth" Date: Thu, 29 Dec 2016 16:18:52 +0100 Subject: [PATCH] * Mage Slayer - Fixed that the correct damage source was assigned for the additional damage. --- Mage.Sets/src/mage/cards/m/MageSlayer.java | 17 ++++++++++------- .../common/AttacksAttachedTriggeredAbility.java | 11 ++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Mage.Sets/src/mage/cards/m/MageSlayer.java b/Mage.Sets/src/mage/cards/m/MageSlayer.java index 2b35ae009b0..a433610ca56 100644 --- a/Mage.Sets/src/mage/cards/m/MageSlayer.java +++ b/Mage.Sets/src/mage/cards/m/MageSlayer.java @@ -39,6 +39,7 @@ import mage.constants.CardType; import mage.constants.Outcome; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.players.Player; import mage.target.common.TargetControlledCreaturePermanent; /** @@ -48,12 +49,9 @@ import mage.target.common.TargetControlledCreaturePermanent; public class MageSlayer extends CardImpl { public MageSlayer(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}{R}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}{R}{G}"); this.subtype.add("Equipment"); - - - // Whenever equipped creature attacks, it deals damage equal to its power to defending player. this.addAbility(new AttacksAttachedTriggeredAbility(new MageSlayerEffect(), false)); @@ -94,10 +92,15 @@ class MageSlayerEffect extends OneShotEffect { if (equipment != null && equipment.getAttachedTo() != null) { int power = game.getPermanent(equipment.getAttachedTo()).getPower().getValue(); UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(equipment.getAttachedTo(), game); - if (defendingPlayerId != null) { - game.getPlayer(defendingPlayerId).damage(power, source.getSourceId(), game, false, true); - return true; + if (power > 0 && defendingPlayerId != null) { + Player defendingPlayer = game.getPlayer(defendingPlayerId); + + UUID sourceId = (UUID) this.getValue("sourceId"); + if (sourceId != null && defendingPlayer != null) { + defendingPlayer.damage(power, source.getSourceId(), game, false, true); + } } + return true; } return false; } diff --git a/Mage/src/main/java/mage/abilities/common/AttacksAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksAttachedTriggeredAbility.java index 4e05f44cac3..97c5d2ac800 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksAttachedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksAttachedTriggeredAbility.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.common; import mage.abilities.TriggeredAbilityImpl; @@ -41,11 +40,10 @@ import mage.game.permanent.Permanent; * * @author LevelX2 */ - public class AttacksAttachedTriggeredAbility extends TriggeredAbilityImpl { - + private AttachmentType attachmentType; - + public AttacksAttachedTriggeredAbility(Effect effect) { this(effect, false); } @@ -58,7 +56,7 @@ public class AttacksAttachedTriggeredAbility extends TriggeredAbilityImpl { super(Zone.BATTLEFIELD, effect, optional); this.attachmentType = attachmentType; } - + public AttacksAttachedTriggeredAbility(final AttacksAttachedTriggeredAbility abiltity) { super(abiltity); this.attachmentType = abiltity.attachmentType; @@ -79,6 +77,9 @@ public class AttacksAttachedTriggeredAbility extends TriggeredAbilityImpl { Permanent equipment = game.getPermanent(this.sourceId); if (equipment != null && equipment.getAttachedTo() != null && event.getSourceId().equals(equipment.getAttachedTo())) { + for (Effect effect : this.getEffects()) { + effect.setValue("sourceId", event.getSourceId()); + } return true; } return false;