diff --git a/Mage.Sets/src/mage/sets/commander2014/FeldonOfTheThirdPath.java b/Mage.Sets/src/mage/sets/commander2014/FeldonOfTheThirdPath.java index b40d8764384..bb2e726042f 100644 --- a/Mage.Sets/src/mage/sets/commander2014/FeldonOfTheThirdPath.java +++ b/Mage.Sets/src/mage/sets/commander2014/FeldonOfTheThirdPath.java @@ -106,6 +106,7 @@ class FeldonOfTheThirdPathEffect extends OneShotEffect { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { EmptyToken token = new EmptyToken(); + // This fails if a card will be copied, that uses adjustTargets() method. CardUtil.copyTo(token).from(card); token.addAbility(HasteAbility.getInstance()); diff --git a/Mage.Sets/src/mage/sets/magic2011/NecroticPlague.java b/Mage.Sets/src/mage/sets/magic2011/NecroticPlague.java index 0b1688bec15..7d539be800d 100644 --- a/Mage.Sets/src/mage/sets/magic2011/NecroticPlague.java +++ b/Mage.Sets/src/mage/sets/magic2011/NecroticPlague.java @@ -102,7 +102,7 @@ public class NecroticPlague extends CardImpl { if (creatureController != null) { ability.setControllerId(creatureController.getId()); ability.getTargets().clear(); - TargetCreaturePermanent target = new TargetCreaturePermanent(filter); + TargetPermanent target = new TargetPermanent(filter); ability.getTargets().add(target); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/enters/SepulchralPrimordialTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/enters/SepulchralPrimordialTest.java new file mode 100644 index 00000000000..db20603ab8a --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/enters/SepulchralPrimordialTest.java @@ -0,0 +1,62 @@ +/* + * 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.abilities.enters; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class SepulchralPrimordialTest extends CardTestPlayerBase { + + @Test + public void testETB2Effect() { + // When Sepulchral Primordial enters the battlefield, for each opponent, you may put up to one + // target creature card from that player's graveyard onto the battlefield under your control. + addCard(Zone.HAND, playerA, "Sepulchral Primordial", 1); + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 7); + + addCard(Zone.GRAVEYARD, playerB, "Silvercoat Lion", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sepulchral Primordial"); + addTarget(playerA, "Silvercoat Lion"); // target for ETB Sepulchral Primordial + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Sepulchral Primordial", 1); + assertPermanentCount(playerA, "Silvercoat Lion", 1); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/copy/FeldonOfTheThirdPathTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/copy/FeldonOfTheThirdPathTest.java new file mode 100644 index 00000000000..3642074bd43 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/copy/FeldonOfTheThirdPathTest.java @@ -0,0 +1,99 @@ + +/* + * 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; + +/** + * Test the funtions of Feldon of the Third Path - {1}{R}{R} Legendary Creature + * - Human Artificer 2/3 {2}{R}, {T} : Put a token onto the battlefield that's a + * copy of target creature card in your graveyard, except it's an artifact in + * addition to its other types. It gains haste. Sacrifice it at the beginning of + * the next end step. + * +* + * @author LevelX2 + */ +public class FeldonOfTheThirdPathTest extends CardTestPlayerBase { + + /** + * Checking that enters the battlefield abilities of the copied creature + * card works. + * + */ + @Test + public void testETBEffect() { + // When Highway Robber enters the battlefield, target opponent loses 2 life and you gain 2 life. + addCard(Zone.GRAVEYARD, playerA, "Highway Robber", 1); + addCard(Zone.BATTLEFIELD, playerA, "Feldon of the Third Path", 1); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); + + activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, + "{2}{R},{T}: Put a token onto the battlefield that's a copy of target creature card in your graveyard, except it's an artifact in addition to its other types. It gains haste. Sacrifice it at the beginning of the next end step.", + "Highway Robber"); + setStopAt(2, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + assertPermanentCount(playerA, "Highway Robber", 1); + assertPermanentCount(playerA, "Feldon of the Third Path", 1); + + assertLife(playerA, 22); // +2 from Robber + assertLife(playerB, 18); // -2 from Robber + + } + + @Test + public void testETB2Effect() { + // When Sepulchral Primordial enters the battlefield, for each opponent, you may put up to one + // target creature card from that player's graveyard onto the battlefield under your control. + addCard(Zone.GRAVEYARD, playerA, "Sepulchral Primordial", 1); + addCard(Zone.BATTLEFIELD, playerA, "Feldon of the Third Path", 1); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); + + addCard(Zone.GRAVEYARD, playerB, "Silvercoat Lion", 1); + + activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, + "{2}{R},{T}: Put a token onto the battlefield that's a copy of target creature card in your graveyard, except it's an artifact in addition to its other types. It gains haste. Sacrifice it at the beginning of the next end step.", + "Sepulchral Primordial"); + addTarget(playerA, "Silvercoat Lion"); // target for ETB Sepulchral Primordial + setStopAt(2, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + assertPermanentCount(playerA, "Feldon of the Third Path", 1); + assertPermanentCount(playerA, "Sepulchral Primordial", 1); + assertPermanentCount(playerA, "Silvercoat Lion", 1); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + } +} diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index 4af4e36e101..5a5543667b6 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -277,7 +277,7 @@ public abstract class AbilityImpl implements Ability { // and/or zones become the target of a spell trigger at this point; they'll wait to be put on // the stack until the spell has finished being cast.) - if (sourceObject != null) { + if (sourceObject != null && !this.getAbilityType().equals(AbilityType.TRIGGERED)) { // triggered abilities check this already TriggeredAbilities.checkTriggers() sourceObject.adjustTargets(this, game); } if (getTargets().size() > 0 && getTargets().chooseTargets(getEffects().get(0).getOutcome(), this.controllerId, this, game) == false) { diff --git a/Mage/src/mage/abilities/TriggeredAbilities.java b/Mage/src/mage/abilities/TriggeredAbilities.java index 90977d65fdf..ae0106a3eba 100644 --- a/Mage/src/mage/abilities/TriggeredAbilities.java +++ b/Mage/src/mage/abilities/TriggeredAbilities.java @@ -44,7 +44,6 @@ import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.game.permanent.PermanentCard; -import org.apache.log4j.Logger; /** * @@ -86,7 +85,7 @@ public class TriggeredAbilities extends ConcurrentHashMap adjustedCost = new ManaCostsImpl(); + ManaCosts adjustedCost = new ManaCostsImpl<>(); boolean updated = false; Iterator it = impl.iterator(); while (it.hasNext()) { diff --git a/Mage/src/mage/util/functions/CopyTokenFunction.java b/Mage/src/mage/util/functions/CopyTokenFunction.java index c747825d18f..fc34cdb03d6 100644 --- a/Mage/src/mage/util/functions/CopyTokenFunction.java +++ b/Mage/src/mage/util/functions/CopyTokenFunction.java @@ -62,13 +62,18 @@ public class CopyTokenFunction implements Function { // to show the source image, the original values have to be used target.setOriginalExpansionSetCode(((Token)sourceObj).getOriginalExpansionSetCode()); target.setOriginalCardNumber(((Token)sourceObj).getOriginalCardNumber()); + target.setCopySourceCard(((PermanentToken)source).getToken().getCopySourceCard()); } else if (source instanceof PermanentCard) { sourceObj = ((PermanentCard) source).getCard(); target.setOriginalExpansionSetCode(source.getExpansionSetCode()); target.setOriginalCardNumber(source.getCardNumber()); + target.setCopySourceCard((Card)sourceObj); } else { target.setOriginalExpansionSetCode(source.getExpansionSetCode()); target.setOriginalCardNumber(source.getCardNumber()); + if (source instanceof Card) { + target.setCopySourceCard((Card)source); + } } target.setName(sourceObj.getName());