diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/NecromancyTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/NecromancyTest.java index 54b959bb00b..5b2a9ae2f6c 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/NecromancyTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/NecromancyTest.java @@ -112,8 +112,8 @@ public class NecromancyTest extends CardTestPlayerBase { addCard(Zone.HAND, playerA, "Disenchant"); addCard(Zone.GRAVEYARD, playerA, "Craw Wurm"); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Necromancy"); - castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Disenchant", "Necromancy"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Necromancy"); // enchanting the Craw Wurm + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Disenchant", "Necromancy"); // if Necromancy leaves, the enchanted creature has to leave too setStopAt(1, PhaseStep.END_TURN); execute(); diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index db403a4264f..bdd68d29771 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -2061,7 +2061,7 @@ public abstract class GameImpl implements Game, Serializable { } else { Player attachedToPlayer = getPlayer(perm.getAttachedTo()); if (attachedToPlayer != null) { - attachedToPlayer.removeAttachment(perm.getId(), this); + attachedToPlayer.removeAttachment(perm, this); } } } diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index 0e9adf9bd0e..e6c4338ab32 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -385,7 +385,7 @@ public interface Player extends MageItem, Copyable { void addCounters(Counter counter, Game game); List getAttachments(); boolean addAttachment(UUID permanentId, Game game); - boolean removeAttachment(UUID permanentId, Game game); + boolean removeAttachment(Permanent permanent, Game game); /** * Signals that the player becomes active player in this turn. diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 47e1de7eb57..cc5236331e0 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -771,15 +771,12 @@ public abstract class PlayerImpl implements Player, Serializable { } @Override - public boolean removeAttachment(UUID permanentId, Game game) { - if (this.attachments.contains(permanentId)) { - Permanent aura = game.getPermanent(permanentId); - if (aura != null) { - if (!game.replaceEvent(new GameEvent(GameEvent.EventType.UNATTACH, playerId, permanentId, aura.getControllerId()))) { - this.attachments.remove(permanentId); - aura.attachTo(null, game); - } - game.fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED, playerId, permanentId, aura.getControllerId())); + public boolean removeAttachment(Permanent attachment, Game game) { + if (this.attachments.contains(attachment.getId())) { + if (!game.replaceEvent(new GameEvent(GameEvent.EventType.UNATTACH, playerId, attachment.getId(), attachment.getControllerId()))) { + this.attachments.remove(attachment.getId()); + attachment.attachTo(null, game); + game.fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED, playerId, attachment.getId(), attachment.getControllerId())); return true; } } @@ -789,6 +786,7 @@ public abstract class PlayerImpl implements Player, Serializable { @Override public boolean removeFromBattlefield(Permanent permanent, Game game) { permanent.removeFromCombat(game, false); + game.getBattlefield().removePermanent(permanent.getId()); if (permanent.getAttachedTo() != null) { Permanent attachedTo = game.getPermanent(permanent.getAttachedTo()); if (attachedTo != null) { @@ -796,7 +794,7 @@ public abstract class PlayerImpl implements Player, Serializable { } else { Player attachedToPlayer = game.getPlayer(permanent.getAttachedTo()); if (attachedToPlayer != null) { - attachedToPlayer.removeAttachment(permanent.getId(), game); + attachedToPlayer.removeAttachment(permanent, game); } } @@ -807,7 +805,6 @@ public abstract class PlayerImpl implements Player, Serializable { pairedCard.clearPairedCard(); } } - game.getBattlefield().removePermanent(permanent.getId()); return true; }