From 0a31a8b4791aa4ec71cbc41e4945a4c74bdb1e83 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 7 Mar 2016 17:34:03 +0100 Subject: [PATCH] Fixed a problem with Tokens of the CopyEffect (e.g. with Essence of the Wild and Back from the Bring in play). --- .../mage/sets/innistrad/BackFromTheBrink.java | 2 +- .../test/cards/copy/EssenceOfTheWildtest.java | 32 +++++++++++++++++++ .../abilities/effects/common/CopyEffect.java | 8 +++-- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Mage.Sets/src/mage/sets/innistrad/BackFromTheBrink.java b/Mage.Sets/src/mage/sets/innistrad/BackFromTheBrink.java index d78a21eb103..24bbd88d2d6 100644 --- a/Mage.Sets/src/mage/sets/innistrad/BackFromTheBrink.java +++ b/Mage.Sets/src/mage/sets/innistrad/BackFromTheBrink.java @@ -103,7 +103,7 @@ class BackFromTheBrinkCost extends CostImpl { Player controller = game.getPlayer(controllerId); if (controller != null) { Card card = controller.getGraveyard().get(targets.getFirstTarget(), game); - if (card != null && controller.moveCards(card, null, Zone.EXILED, ability, game)) { + if (card != null && controller.moveCards(card, Zone.EXILED, ability, game)) { ability.getEffects().get(0).setTargetPointer(new FixedTarget(card.getId())); paid = card.getManaCost().pay(ability, game, sourceId, controllerId, noMana); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/copy/EssenceOfTheWildtest.java b/Mage.Tests/src/test/java/org/mage/test/cards/copy/EssenceOfTheWildtest.java index 0a48f56c920..6ad7508a79c 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/copy/EssenceOfTheWildtest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/copy/EssenceOfTheWildtest.java @@ -68,4 +68,36 @@ public class EssenceOfTheWildtest extends CardTestPlayerBase { } + /** + * I control Essence of the Wild and Back from the Brink on the battlefield, + * and start using Back from the Brink on the creatures in my graveyard. The + * creature tokens don't enter the battlefield as copies of Essence of the + * Wild. + * + * Since it's an unusual situation, I checked around if there's something in + * the rules that would prevent this combo from working. Found this link and + * they confirmed that it should work, the tokens should come into play as + * 6/6s. + */ + @Test + public void testWithBackFromTheBrink() { + addCard(Zone.BATTLEFIELD, playerA, "Plains", 2); + // Creatures you control enter the battlefield as a copy of Essence of the Wild. + addCard(Zone.BATTLEFIELD, playerA, "Essence of the Wild"); // 6/6 + // Exile a creature card from your graveyard and pay its mana cost: Put a token onto the battlefield that's a copy of that card. Activate this ability only any time you could cast a sorcery. + addCard(Zone.BATTLEFIELD, playerA, "Back from the Brink"); // Enchantment + + addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion"); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Exile a creature card"); + setChoice(playerA, "Silvercoat Lion"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertExileCount("Silvercoat Lion", 1); + assertPermanentCount(playerA, "Essence of the Wild", 2); + assertPowerToughness(playerA, "Essence of the Wild", 6, 6, Filter.ComparisonScope.All); + + } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/CopyEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CopyEffect.java index 9b6becb7198..3bc7c897547 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CopyEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CopyEffect.java @@ -92,8 +92,12 @@ public class CopyEffect extends ContinuousEffectImpl { permanent = game.getPermanentEntering(copyToObjectId); if (permanent != null) { copyToPermanent(permanent, game, source); - // set reference to the permanent later on the battlefield so we have to add already one to the zone change counter - affectedObjectList.add(new MageObjectReference(permanent.getId(), game.getState().getZoneChangeCounter(copyToObjectId) + 1, game)); + // set reference to the permanent later on the battlefield so we have to add already one (if no token) to the zone change counter + int ZCCDiff = 1; + if (permanent instanceof PermanentToken) { + ZCCDiff = 0; + } + affectedObjectList.add(new MageObjectReference(permanent.getId(), game.getState().getZoneChangeCounter(copyToObjectId) + ZCCDiff, game)); } } }