diff --git a/Mage.Sets/src/mage/cards/b/BitterheartWitch.java b/Mage.Sets/src/mage/cards/b/BitterheartWitch.java index 20bcf385b0..b0a4fac32d 100644 --- a/Mage.Sets/src/mage/cards/b/BitterheartWitch.java +++ b/Mage.Sets/src/mage/cards/b/BitterheartWitch.java @@ -98,21 +98,21 @@ class BitterheartWitchEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(source.getFirstTarget()); - if (player != null && targetPlayer != null) { + if (controller != null && targetPlayer != null) { TargetCardInLibrary targetCard = new TargetCardInLibrary(filter); - if (player.searchLibrary(targetCard, game)) { + if (controller.searchLibrary(targetCard, game)) { Card card = game.getCard(targetCard.getFirstTarget()); if (card != null) { game.getState().setValue("attachTo:" + card.getId(), targetPlayer.getId()); - card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId()); - targetPlayer.addAttachment(card.getId(), game); + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { + targetPlayer.addAttachment(card.getId(), game); + } } - player.shuffleLibrary(source, game); - return true; } - player.shuffleLibrary(source, game); + controller.shuffleLibrary(source, game); + return true; } return false; } diff --git a/Mage.Sets/src/mage/cards/c/CurseOfMisfortunes.java b/Mage.Sets/src/mage/cards/c/CurseOfMisfortunes.java index 05bb4b8fa4..4d128d2c0d 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfMisfortunes.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfMisfortunes.java @@ -27,6 +27,7 @@ */ package mage.cards.c; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.OnEventTriggeredAbility; import mage.abilities.effects.OneShotEffect; @@ -51,8 +52,6 @@ import mage.target.TargetPlayer; import mage.target.common.TargetCardInLibrary; import mage.target.targetpointer.FixedTarget; -import java.util.UUID; - /** * * @author BetaSteward @@ -97,13 +96,14 @@ class CurseOfMisfortunesEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - FilterCard filter = new FilterCard("Curse card that doesn't have the same name as a Curse attached to enchanted player"); - filter.add(new SubtypePredicate(SubType.CURSE)); + Player controller = game.getPlayer(source.getControllerId()); Permanent enchantment = game.getPermanent(source.getSourceId()); - if (enchantment != null && enchantment.getAttachedTo() != null) { + if (controller != null && enchantment != null && enchantment.getAttachedTo() != null) { Player targetPlayer = game.getPlayer(enchantment.getAttachedTo()); Player player = game.getPlayer(source.getControllerId()); if (player != null && targetPlayer != null) { + FilterCard filter = new FilterCard("Curse card that doesn't have the same name as a Curse attached to enchanted player"); + filter.add(new SubtypePredicate(SubType.CURSE)); // get the names of attached Curses for (UUID attachmentId: targetPlayer.getAttachments()) { Permanent attachment = game.getPermanent(attachmentId); @@ -111,19 +111,20 @@ class CurseOfMisfortunesEffect extends OneShotEffect { filter.add(Predicates.not(new NamePredicate(attachment.getName()))); } } - TargetCardInLibrary targetCard = new TargetCardInLibrary(filter); if (player.searchLibrary(targetCard, game)) { Card card = game.getCard(targetCard.getFirstTarget()); if (card != null) { this.setTargetPointer(new FixedTarget(targetPlayer.getId())); game.getState().setValue("attachTo:" + card.getId(), targetPlayer.getId()); - player.shuffleLibrary(source, game); - return card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId()); + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { + targetPlayer.addAttachment(card.getId(), game); + } } } player.shuffleLibrary(source, game); } + return true; } return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java b/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java index 60e5c3af96..873e81e5a5 100644 --- a/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java @@ -27,6 +27,7 @@ */ package mage.abilities.effects; +import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.SpellAbility; @@ -44,8 +45,6 @@ import mage.players.Player; import mage.target.Target; import mage.target.common.TargetCardInGraveyard; -import java.util.UUID; - /** * Cards with the Aura subtype don't change the zone they are in, if there is no * valid target on the battlefield. Also, when entering the battlefield and it @@ -98,19 +97,23 @@ public class AuraReplacementEffect extends ReplacementEffectImpl { } // Aura enters the battlefield attached Object object = game.getState().getValue("attachTo:" + card.getId()); - if (object != null && object instanceof PermanentCard) { - return false; + if (object != null) { + if (object instanceof PermanentCard) { + // Aura is attached to a permanent on the battlefield + return false; + } + if (object instanceof UUID) { + Player player = game.getPlayer((UUID) object); + if (player != null) { + // Aura is attached to a player + return false; + } + } } UUID targetId = null; MageObject sourceObject = game.getObject(sourceId); boolean enchantCardInGraveyard = false; -// if (sourceObject instanceof Spell) { -// if (fromZone.equals(Zone.EXILED)) { -// // cast from exile (e.g. Neightveil Spector) -> no replacement -// return false; -// } -// } if (sourceObject instanceof StackAbility) { StackAbility stackAbility = (StackAbility) sourceObject; if (!stackAbility.getEffects().isEmpty()) {