diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java index 3950fa971b1..5427cb84607 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java @@ -7,7 +7,6 @@ import mage.constants.SubType; import mage.constants.Zone; import mage.game.permanent.Permanent; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -162,7 +161,6 @@ public class BestowTest extends CardTestPlayerBase { * Bestowed creature can be used to sacrifice a creature for the Away part. * http://www.mtgsalvation.com/forums/magic-fundamentals/magic-rulings/magic-rulings-archives/513828-bestow-far-away */ - @Ignore // TODO: make fused targeting support @Test public void bestowWithFusedSpell() { addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index 20f6284b9b9..1d73eb4ca42 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -1987,7 +1987,8 @@ public abstract class GameImpl implements Game, Serializable { if (card != null && card.isCreature()) { UUID wasAttachedTo = perm.getAttachedTo(); perm.attachTo(null, this); - BestowAbility.becomeCreature(perm, this); + //moved to mage.game.permanent.PermanentImpl::detachAllAttachments + //BestowAbility.becomeCreature(perm, this); fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED, wasAttachedTo, perm.getId(), perm.getControllerId())); } else if (movePermanentToGraveyardWithInfo(perm)) { somethingHappened = true; diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index 74739b25a37..776f0b775dd 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -1437,6 +1437,24 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { return color; } + //20180810 - 701.3d + //If an object leaves the zone it's in, all attached permanents become unattached + //note that this code doesn't actually detach anything, and is a bit of a bandaid + public void detachAllAttachments(Game game) { + for(UUID attachmentId : getAttachments()) { + Permanent attachment = game.getPermanent(attachmentId); + Card attachmentCard = game.getCard(attachmentId); + if(attachment != null && attachmentCard != null) { + //make bestow cards and licids into creatures + //aura test to stop bludgeon brawl shenanigans from using this code + //consider adding code to handle that case? + if(attachment.hasSubtype(SubType.AURA, game) && attachmentCard.isCreature()) { + BestowAbility.becomeCreature(attachment, game); + } + } + } + } + @Override public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, List appliedEffects) { Zone fromZone = game.getState().getZone(objectId); @@ -1449,7 +1467,10 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } else { zoneChangeInfo = new ZoneChangeInfo(event); } - return ZonesHandler.moveCard(zoneChangeInfo, game); + boolean successfullyMoved = ZonesHandler.moveCard(zoneChangeInfo, game); + //20180810 - 701.3d + detachAllAttachments(game); + return successfullyMoved; } return false; } @@ -1459,7 +1480,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { Zone fromZone = game.getState().getZone(objectId); ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, ownerId, fromZone, Zone.EXILED, appliedEffects); ZoneChangeInfo.Exile info = new ZoneChangeInfo.Exile(event, exileId, name); - return ZonesHandler.moveCard(info, game); + + boolean successfullyMoved = ZonesHandler.moveCard(info, game); + //20180810 - 701.3d + detachAllAttachments(game); + return successfullyMoved; } }