From 49f4e54aaa2853e9ee7d15528883e37b818301e8 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Mon, 6 Jul 2020 15:29:53 +0400 Subject: [PATCH] * Amplify abilities - fixed that it allows reveal itself when put onto battlefield from hand (#6776); --- .../cards/abilities/keywords/AmplifyTest.java | 36 ++++++++++++------- .../effects/common/AmplifyEffect.java | 10 ++++++ 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/AmplifyTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/AmplifyTest.java index a7a43f781b..7fb7acf7da 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/AmplifyTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/AmplifyTest.java @@ -18,7 +18,7 @@ public class AmplifyTest extends CardTestPlayerBase { * Tests if +1/+1 counters are added */ @Test - public void testAmplifyOneCard() { + public void test_Amplify_OneCard() { // Creature — Dragon - Dragon 5/5 {5}{R}{R} // Amplify 3 (As this creature enters the battlefield, put three +1/+1 counters on it for each Dragon card you reveal in your hand.) // {T}: Kilnmouth Dragon deals damage equal to the number of +1/+1 counters on it to any target @@ -29,8 +29,10 @@ public class AmplifyTest extends CardTestPlayerBase { setChoice(playerA, "Yes"); addTarget(playerA, "Kilnmouth Dragon"); + setStrictChooseMode(true); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); + assertAllCommandsUsed(); assertPermanentCount(playerA, "Kilnmouth Dragon", 1); assertPowerToughness(playerA, "Kilnmouth Dragon", 8,8); // 5 + 3 from Amplify @@ -39,7 +41,7 @@ public class AmplifyTest extends CardTestPlayerBase { * Tests if +1/+1 counters are added */ @Test - public void testAmplifyTwoCards() { + public void test_Amplify_TwoCards() { // Creature — Dragon - Dragon 5/5 {5}{R}{R} // Amplify 3 (As this creature enters the battlefield, put three +1/+1 counters on it for each Dragon card you reveal in your hand.) // {T}: Kilnmouth Dragon deals damage equal to the number of +1/+1 counters on it to any target @@ -51,8 +53,10 @@ public class AmplifyTest extends CardTestPlayerBase { setChoice(playerA, "Yes"); addTarget(playerA, "Kilnmouth Dragon^Phantasmal Dragon"); + setStrictChooseMode(true); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); + assertAllCommandsUsed(); assertPermanentCount(playerA, "Kilnmouth Dragon", 1); assertPowerToughness(playerA, "Kilnmouth Dragon", 11,11); // 5 + 6 from Amplify @@ -61,7 +65,7 @@ public class AmplifyTest extends CardTestPlayerBase { * Tests that it works for Clone */ @Test - public void testAmplifyWithClone() { + public void test_Amplify_WithClone() { // Creature — Dragon - Dragon 5/5 {5}{R}{R} // Amplify 3 (As this creature enters the battlefield, put three +1/+1 counters on it for each Dragon card you reveal in your hand.) // {T}: Kilnmouth Dragon deals damage equal to the number of +1/+1 counters on it to any target @@ -77,12 +81,15 @@ public class AmplifyTest extends CardTestPlayerBase { addTarget(playerA, "Kilnmouth Dragon"); castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Clone"); - setChoice(playerB, "Kilnmouth Dragon"); - setChoice(playerB, "Yes"); - addTarget(playerB, "Phantasmal Dragon"); + setChoice(playerB, "Yes"); // use clone + setChoice(playerB, "Kilnmouth Dragon"); // what clone + setChoice(playerB, "Yes"); // use amplify + addTarget(playerB, "Phantasmal Dragon"); // reveal + setStrictChooseMode(true); setStopAt(2, PhaseStep.BEGIN_COMBAT); execute(); + assertAllCommandsUsed(); assertPermanentCount(playerA, "Kilnmouth Dragon", 1); assertPowerToughness(playerA, "Kilnmouth Dragon", 8,8); // 5 + 3 from Amplify @@ -94,27 +101,30 @@ public class AmplifyTest extends CardTestPlayerBase { /** * Tests if a creature with Amplify is able to select itself if it's put * onto the battlefield from hand (without casting). - * - * TODO: Remove @Ignore when https://github.com/magefree/mage/issues/6776 is fixed. + * https://github.com/magefree/mage/issues/6776 */ @Test - @Ignore - public void testAmplifyPutOntoBattlefieldFromHand() { + public void test_Amplify_PutOntoBattlefieldFromHand() { // Creature — Dragon - Dragon 5/5 {5}{R}{R} // Amplify 3 (As this creature enters the battlefield, put three +1/+1 counters on it for each Dragon card you reveal in your hand.) // {T}: Kilnmouth Dragon deals damage equal to the number of +1/+1 counters on it to any target addCard(Zone.HAND, playerA, "Kilnmouth Dragon", 1); + // + // {4}{R} + // You may put a creature card from your hand onto the battlefield. That creature gains haste. Sacrifice that creature at the beginning of the next end step. addCard(Zone.HAND, playerA, "Through the Breach", 1); addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Through the Breach"); setChoice(playerA, "Yes"); // Put a creature into play with Through the Breach? - addTarget(playerA, "Kilnmouth Dragon"); - setChoice(playerA, "Yes"); // Reveal cards to Amplify? - addTarget(playerA, "Kilnmouth Dragon"); + setChoice(playerA, "Kilnmouth Dragon"); + //setChoice(playerA, "Yes"); // no reveal request cause no cards to show + //addTarget(playerA, "Kilnmouth Dragon"); + setStrictChooseMode(true); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); + assertAllCommandsUsed(); assertPermanentCount(playerA, "Kilnmouth Dragon", 1); assertPowerToughness(playerA, "Kilnmouth Dragon", 5,5); // 5 + 0 from Amplify diff --git a/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java index 81eab7e767..59dc9f1430 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java @@ -8,6 +8,7 @@ package mage.abilities.effects.common; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.effects.ReplacementEffectImpl; +import mage.cards.Card; import mage.cards.Cards; import mage.cards.CardsImpl; import mage.constants.Duration; @@ -16,6 +17,7 @@ import mage.constants.SubType; import mage.counters.CounterType; import mage.filter.common.FilterCreatureCard; import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardIdPredicate; import mage.game.Game; import mage.game.events.EntersTheBattlefieldEvent; import mage.game.events.GameEvent; @@ -108,6 +110,14 @@ public class AmplifyEffect extends ReplacementEffectImpl { } else if (filterSubtypes.size() == 1) { filter.add(filterSubtypes.get(0)); } + + // You can’t reveal this card or any other cards that are entering the battlefield at the same time as this card. + filter.add(Predicates.not(new CardIdPredicate(source.getSourceId()))); + for (Permanent enteringPermanent : game.getPermanentsEntering().values()) { + Card card = game.getCard(enteringPermanent.getId()); + filter.add(Predicates.not(new CardIdPredicate(enteringPermanent.getId()))); + } + if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) { if (controller.chooseUse(outcome, "Reveal cards to Amplify?", source, game)) { TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);