diff --git a/Mage.Sets/src/mage/cards/a/ArdentPlea.java b/Mage.Sets/src/mage/cards/a/ArdentPlea.java index 1c6fcc667f9..3375ffb2e03 100644 --- a/Mage.Sets/src/mage/cards/a/ArdentPlea.java +++ b/Mage.Sets/src/mage/cards/a/ArdentPlea.java @@ -25,15 +25,14 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.cards.a; import java.util.UUID; -import mage.constants.CardType; import mage.abilities.keyword.CascadeAbility; import mage.abilities.keyword.ExaltedAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; /** * @@ -41,17 +40,17 @@ import mage.cards.CardSetInfo; */ public class ArdentPlea extends CardImpl { - public ArdentPlea (UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{W}{U}"); - - - + public ArdentPlea(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}{U}"); + // Exalted (Whenever a creature you control attacks alone, that creature gets +1/+1 until end of turn.) this.addAbility(new ExaltedAbility()); + + // Cascade (When you cast this spell, exile cards from the top of your library until you exile a nonland card that costs less. You may cast it without paying its mana cost. Put the exiled cards on the bottom in a random order.) this.addAbility(new CascadeAbility()); } - public ArdentPlea (final ArdentPlea card) { + public ArdentPlea(final ArdentPlea card) { super(card); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/CascadeTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/CascadeTest.java index f5aa2e45108..3618d4230b1 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/CascadeTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/CascadeTest.java @@ -171,27 +171,70 @@ public class CascadeTest extends CardTestPlayerBase { public void testHaveToPayAdditionalCosts() { playerA.getLibrary().clear(); - // Choose one - You draw five cards and you lose 5 life; - // or put an X/X black Demon creature token with flying onto the battlefield, where X is the number of cards in your hand as the token enters the battlefield. + // Choose one - + // - You draw five cards and you lose 5 life; + // - put an X/X black Demon creature token with flying onto the battlefield, where X is the number of cards in your hand as the token enters the battlefield. // Entwine {4} (Choose both if you pay the entwine cost.) addCard(Zone.LIBRARY, playerA, "Promise of Power", 1); - // addCard(Zone.LIBRARY, playerA, "Silvercoat Lion", 2); + addCard(Zone.LIBRARY, playerA, "Mountain", 5); + // addCard(Zone.LIBRARY, playerA, "Silvercoat Lion", 2); addCard(Zone.BATTLEFIELD, playerA, "Plains", 3); addCard(Zone.BATTLEFIELD, playerA, "Forest", 3); - // Cascade + // Cascade (When you cast this spell, exile cards from the top of your library until you exile a nonland card that costs less. + // You may cast it without paying its mana cost. Put the exiled cards on the bottom in a random order.) addCard(Zone.HAND, playerA, "Enlisted Wurm"); // Creature {4}{G}{W} 5/5 castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Enlisted Wurm"); + setChoice(playerA, "Yes"); // Use cascade on Promise of Power + setChoice(playerA, "No"); // Pay no Entwine + setModeChoice(playerA, "1"); - setStopAt(1, PhaseStep.END_TURN); + setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); - assertPermanentCount(playerA, "Enlisted Wurm", 1); assertLife(playerA, 15); assertHandCount(playerA, 5); assertPermanentCount(playerA, "Demon", 0); + assertPermanentCount(playerA, "Enlisted Wurm", 1); } + + /** + * Cascade dont work with split cards. + * + * For example: Ardent Plea + Breaking/Entering + */ + @Test + public void testWithSplitSpell() { + + playerA.getLibrary().clear(); + // Breaking - Target player puts the top eight cards of his or her library into his or her graveyard. + // Entering - Put a creature card from a graveyard onto the battlefield under your control. It gains haste until end of turn. + // Fuse (You may cast one or both halves of this card from your hand.) + addCard(Zone.LIBRARY, playerA, "Breaking // Entering", 1); // Sorcery {U}{B} // {4}{U}{B} + // addCard(Zone.LIBRARY, playerA, "Silvercoat Lion", 2); + + addCard(Zone.BATTLEFIELD, playerA, "Plains", 1); + addCard(Zone.BATTLEFIELD, playerA, "Island", 2); + + // Exalted (Whenever a creature you control attacks alone, that creature gets +1/+1 until end of turn.) + // Cascade (When you cast this spell, exile cards from the top of your library until you exile a nonland card that costs less. You may cast it without paying its mana cost. Put the exiled cards on the bottom in a random order.) + addCard(Zone.HAND, playerA, "Ardent Plea"); // Enchantment {1}{W}{U} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ardent Plea"); + setChoice(playerA, "Yes"); + addTarget(playerA, playerB); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Ardent Plea", 1); + assertGraveyardCount(playerA, "Breaking // Entering", 1); + + assertGraveyardCount(playerB, 8); + + } + } diff --git a/Mage/src/main/java/mage/abilities/keyword/CascadeAbility.java b/Mage/src/main/java/mage/abilities/keyword/CascadeAbility.java index 2cb6ca432ba..d82935d0d78 100644 --- a/Mage/src/main/java/mage/abilities/keyword/CascadeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/CascadeAbility.java @@ -33,6 +33,7 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.Cards; import mage.cards.CardsImpl; +import mage.cards.SplitCard; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; @@ -120,14 +121,13 @@ class CascadeEffect extends OneShotEffect { break; } controller.moveCardsToExile(card, source, game, true, exile.getId(), exile.getName()); - } while (controller.isInGame() && card.getCardType().contains(CardType.LAND) || card.getConvertedManaCost() >= sourceCost); + } while (controller.isInGame() && (card.getCardType().contains(CardType.LAND) || !cardThatCostsLess(sourceCost, card, game))); + controller.getLibrary().reset(); // set back empty draw state if that caused an empty draw if (card != null) { if (controller.chooseUse(outcome, "Use cascade effect on " + card.getLogName() + "?", source, game)) { - if (controller.cast(card.getSpellAbility(), game, true)) { - exile.remove(card.getId()); - } + controller.cast(card.getSpellAbility(), game, true); } } // Move the remaining cards to the buttom of the library in a random order @@ -148,4 +148,12 @@ class CascadeEffect extends OneShotEffect { return new CascadeEffect(this); } + private boolean cardThatCostsLess(int value, Card card, Game game) { + if (card instanceof SplitCard) { + return ((SplitCard) card).getLeftHalfCard().getConvertedManaCost() < value + || ((SplitCard) card).getRightHalfCard().getConvertedManaCost() < value; + } else { + return card.getConvertedManaCost() < value; + } + } }