From 0e4de763d87e8b4e5858c1fef49a3c15c64c0f5f Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 8 Jan 2016 15:07:41 +0100 Subject: [PATCH] * Splinter Twin - Fixed that no token was created if the enchnated permanent left battlefield meanwhile (fixes #1429). --- .../test/cards/copy/SplinterTwinTest.java | 69 +++++++++++++++++++ ...tTokenOntoBattlefieldCopyTargetEffect.java | 9 ++- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/copy/SplinterTwinTest.java diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/copy/SplinterTwinTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/copy/SplinterTwinTest.java new file mode 100644 index 00000000000..c8c45bbd385 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/copy/SplinterTwinTest.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package org.mage.test.cards.copy; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class SplinterTwinTest extends CardTestPlayerBase { + + @Test + public void testCopyCreature() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4); + // Enchant creature + // Enchanted creature has "{T}: Put a token that's a copy of this creature onto the battlefield. That token has haste. Exile it at the beginning of the next end step." + addCard(Zone.HAND, playerA, "Splinter Twin"); // {2}{R}{R} + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); + + addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1); + addCard(Zone.HAND, playerB, "Lightning Bolt"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Splinter Twin", "Silvercoat Lion"); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Put a token"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", "Silvercoat Lion", "{T}: Put a token"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertHandCount(playerB, "Lightning Bolt", 0); + assertGraveyardCount(playerB, "Lightning Bolt", 1); + + assertGraveyardCount(playerA, "Silvercoat Lion", 1); + assertGraveyardCount(playerA, "Splinter Twin", 1); + + assertPermanentCount(playerA, "Silvercoat Lion", 1); + } + +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/PutTokenOntoBattlefieldCopyTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PutTokenOntoBattlefieldCopyTargetEffect.java index 61f433d298f..3c98f5d5c8a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PutTokenOntoBattlefieldCopyTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PutTokenOntoBattlefieldCopyTargetEffect.java @@ -42,6 +42,7 @@ import mage.constants.Outcome; import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.permanent.token.EmptyToken; +import mage.target.targetpointer.FixedTarget; import mage.util.CardUtil; import mage.util.functions.ApplyToPermanent; import mage.util.functions.EmptyApplyToPermanent; @@ -125,7 +126,13 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + UUID targetId; + if (getTargetPointer() instanceof FixedTarget) { + targetId = ((FixedTarget) getTargetPointer()).getTarget(); + } else { + targetId = getTargetPointer().getFirst(game, source); + } + Permanent permanent = game.getPermanentOrLKIBattlefield(targetId); Card copyFrom; ApplyToPermanent applier = new EmptyApplyToPermanent(); if (permanent != null) {