* Amplify abilities - fixed that it allows reveal itself when put onto battlefield from hand (#6776);

This commit is contained in:
Oleg Agafonov 2020-07-06 15:29:53 +04:00
parent 4168e2714a
commit 49f4e54aaa
2 changed files with 33 additions and 13 deletions

View file

@ -18,7 +18,7 @@ public class AmplifyTest extends CardTestPlayerBase {
* Tests if +1/+1 counters are added * Tests if +1/+1 counters are added
*/ */
@Test @Test
public void testAmplifyOneCard() { public void test_Amplify_OneCard() {
// Creature Dragon - Dragon 5/5 {5}{R}{R} // 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.) // 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 // {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"); setChoice(playerA, "Yes");
addTarget(playerA, "Kilnmouth Dragon"); addTarget(playerA, "Kilnmouth Dragon");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT); setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute(); execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Kilnmouth Dragon", 1); assertPermanentCount(playerA, "Kilnmouth Dragon", 1);
assertPowerToughness(playerA, "Kilnmouth Dragon", 8,8); // 5 + 3 from Amplify 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 * Tests if +1/+1 counters are added
*/ */
@Test @Test
public void testAmplifyTwoCards() { public void test_Amplify_TwoCards() {
// Creature Dragon - Dragon 5/5 {5}{R}{R} // 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.) // 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 // {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"); setChoice(playerA, "Yes");
addTarget(playerA, "Kilnmouth Dragon^Phantasmal Dragon"); addTarget(playerA, "Kilnmouth Dragon^Phantasmal Dragon");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT); setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute(); execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Kilnmouth Dragon", 1); assertPermanentCount(playerA, "Kilnmouth Dragon", 1);
assertPowerToughness(playerA, "Kilnmouth Dragon", 11,11); // 5 + 6 from Amplify 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 * Tests that it works for Clone
*/ */
@Test @Test
public void testAmplifyWithClone() { public void test_Amplify_WithClone() {
// Creature Dragon - Dragon 5/5 {5}{R}{R} // 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.) // 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 // {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"); addTarget(playerA, "Kilnmouth Dragon");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Clone"); castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Clone");
setChoice(playerB, "Kilnmouth Dragon"); setChoice(playerB, "Yes"); // use clone
setChoice(playerB, "Yes"); setChoice(playerB, "Kilnmouth Dragon"); // what clone
addTarget(playerB, "Phantasmal Dragon"); setChoice(playerB, "Yes"); // use amplify
addTarget(playerB, "Phantasmal Dragon"); // reveal
setStrictChooseMode(true);
setStopAt(2, PhaseStep.BEGIN_COMBAT); setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute(); execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Kilnmouth Dragon", 1); assertPermanentCount(playerA, "Kilnmouth Dragon", 1);
assertPowerToughness(playerA, "Kilnmouth Dragon", 8,8); // 5 + 3 from Amplify 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 * Tests if a creature with Amplify is able to select itself if it's put
* onto the battlefield from hand (without casting). * onto the battlefield from hand (without casting).
* * https://github.com/magefree/mage/issues/6776
* TODO: Remove @Ignore when https://github.com/magefree/mage/issues/6776 is fixed.
*/ */
@Test @Test
@Ignore public void test_Amplify_PutOntoBattlefieldFromHand() {
public void testAmplifyPutOntoBattlefieldFromHand() {
// Creature Dragon - Dragon 5/5 {5}{R}{R} // 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.) // 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 // {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); 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.HAND, playerA, "Through the Breach", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5); addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Through the Breach"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Through the Breach");
setChoice(playerA, "Yes"); // Put a creature into play with Through the Breach? setChoice(playerA, "Yes"); // Put a creature into play with Through the Breach?
addTarget(playerA, "Kilnmouth Dragon"); setChoice(playerA, "Kilnmouth Dragon");
setChoice(playerA, "Yes"); // Reveal cards to Amplify? //setChoice(playerA, "Yes"); // no reveal request cause no cards to show
addTarget(playerA, "Kilnmouth Dragon"); //addTarget(playerA, "Kilnmouth Dragon");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT); setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute(); execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Kilnmouth Dragon", 1); assertPermanentCount(playerA, "Kilnmouth Dragon", 1);
assertPowerToughness(playerA, "Kilnmouth Dragon", 5,5); // 5 + 0 from Amplify assertPowerToughness(playerA, "Kilnmouth Dragon", 5,5); // 5 + 0 from Amplify

View file

@ -8,6 +8,7 @@ package mage.abilities.effects.common;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.constants.Duration; import mage.constants.Duration;
@ -16,6 +17,7 @@ import mage.constants.SubType;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent; import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
@ -108,6 +110,14 @@ public class AmplifyEffect extends ReplacementEffectImpl {
} else if (filterSubtypes.size() == 1) { } else if (filterSubtypes.size() == 1) {
filter.add(filterSubtypes.get(0)); filter.add(filterSubtypes.get(0));
} }
// You cant 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.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
if (controller.chooseUse(outcome, "Reveal cards to Amplify?", source, game)) { if (controller.chooseUse(outcome, "Reveal cards to Amplify?", source, game)) {
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter); TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);