diff --git a/Mage.Sets/src/mage/cards/a/AccursedWitch.java b/Mage.Sets/src/mage/cards/a/AccursedWitch.java index b6f4bc05f0..bcde8821e6 100644 --- a/Mage.Sets/src/mage/cards/a/AccursedWitch.java +++ b/Mage.Sets/src/mage/cards/a/AccursedWitch.java @@ -18,6 +18,7 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.Target; +import mage.target.common.TargetOpponent; import mage.util.CardUtil; import java.util.UUID; @@ -41,7 +42,9 @@ public final class AccursedWitch extends CardImpl { this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AccursedWitchSpellsCostReductionEffect())); // When Accursed Witch dies, return it to the battlefield transformed under your control attached to target opponent. this.addAbility(new TransformAbility()); - this.addAbility(new DiesTriggeredAbility(new AccursedWitchReturnTransformedEffect())); + Ability ability = new DiesTriggeredAbility(new AccursedWitchReturnTransformedEffect()); + ability.addTarget(new TargetOpponent()); + this.addAbility(ability); } private AccursedWitch(final AccursedWitch card) { @@ -58,7 +61,7 @@ class AccursedWitchReturnTransformedEffect extends OneShotEffect { AccursedWitchReturnTransformedEffect() { super(Outcome.PutCardInPlay); - this.staticText = "Put {this} from your graveyard onto the battlefield transformed"; + this.staticText = "Put {this} from your graveyard onto the battlefield transformed under your control attached to target opponent"; } private AccursedWitchReturnTransformedEffect(final AccursedWitchReturnTransformedEffect effect) { @@ -73,14 +76,19 @@ class AccursedWitchReturnTransformedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller == null || !(game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD)) { + Player attachTo = game.getPlayer(targetPointer.getFirst(game, source)); + if (controller == null || !(game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) || attachTo == null) { return false; } game.getState().setValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + source.getSourceId(), Boolean.TRUE); + UUID secondFaceId = game.getCard(source.getSourceId()).getSecondCardFace().getId(); + game.getState().setValue("attachTo:" + secondFaceId, attachTo.getId()); //note: should check for null after game.getCard Card card = game.getCard(source.getSourceId()); if (card != null) { - controller.moveCards(card, Zone.BATTLEFIELD, source, game); + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { + attachTo.addAttachment(card.getId(), game); + } } return true; } diff --git a/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java b/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java index 790b95f3e6..2369835049 100644 --- a/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java @@ -64,7 +64,9 @@ public class AuraReplacementEffect extends ReplacementEffectImpl { return false; } + Card firstCardFace = null; if (game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()) != null) { + firstCardFace = card; card = card.getSecondCardFace(); if (!card.isEnchantment() || !card.hasSubtype(SubType.AURA, game)) { return false; @@ -129,7 +131,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl { enchantCardInGraveyard = target instanceof TargetCardInGraveyard; if (target != null) { target.setNotTarget(true); // always not target because this way it's not handled targeted - target.clearChosen(); // neccessary if e.g. aura is blinked multiple times + target.clearChosen(); // necessary if e.g. aura is blinked multiple times } if (event.getPlayerId() != null) { @@ -152,7 +154,12 @@ public class AuraReplacementEffect extends ReplacementEffectImpl { } Player targetPlayer = game.getPlayer(targetId); if (targetCard != null || targetPermanent != null || targetPlayer != null) { - card.removeFromZone(game, fromZone, sourceId); + if (firstCardFace != null) { + // transforming card. remove first face (original card) from old zone + firstCardFace.removeFromZone(game, fromZone, sourceId); + } else { + card.removeFromZone(game, fromZone, sourceId); + } PermanentCard permanent = new PermanentCard(card, (controllingPlayer == null ? card.getOwnerId() : controllingPlayer.getId()), game); ZoneChangeEvent zoneChangeEvent = new ZoneChangeEvent(permanent, controllerId, fromZone, Zone.BATTLEFIELD); permanent.updateZoneChangeCounter(game, zoneChangeEvent); diff --git a/Mage/src/main/java/mage/abilities/keyword/TransformAbility.java b/Mage/src/main/java/mage/abilities/keyword/TransformAbility.java index e616e86298..8408cd0fc3 100644 --- a/Mage/src/main/java/mage/abilities/keyword/TransformAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/TransformAbility.java @@ -18,7 +18,7 @@ public class TransformAbility extends SimpleStaticAbility { public static final String NO_SPELLS_TRANSFORM_RULE = "At the beginning of each upkeep, if no spells were cast last turn, transform {this}."; public static final String TWO_OR_MORE_SPELLS_TRANSFORM_RULE = "At the beginning of each upkeep, if a player cast two or more spells last turn, transform {this}."; - // this state value controlls if a permanent enters the battlefield already transformed + // this state value controls if a permanent enters the battlefield already transformed public static final String VALUE_KEY_ENTER_TRANSFORMED = "EnterTransformed"; public TransformAbility() {