* 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
*/
@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

View file

@ -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 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.chooseUse(outcome, "Reveal cards to Amplify?", source, game)) {
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);