From 484a4fe0f6f6207f7030f8b4d7650d694aeb2df2 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 14 Aug 2014 12:48:41 +0200 Subject: [PATCH] * Leyline of Anticipation - Fixed that it only worked for creatures instead of all nonland permanents. --- .../sets/magic2011/LeylineOfAnticipation.java | 10 ++- .../asthough/LeylineOfAnticipationTest.java | 67 +++++++++++++++++++ .../test/combat/DamageDistributionTest.java | 1 + .../CastAsThoughItHadFlashEffect.java | 16 ++--- 4 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/asthough/LeylineOfAnticipationTest.java diff --git a/Mage.Sets/src/mage/sets/magic2011/LeylineOfAnticipation.java b/Mage.Sets/src/mage/sets/magic2011/LeylineOfAnticipation.java index d284961de30..298d503ec14 100644 --- a/Mage.Sets/src/mage/sets/magic2011/LeylineOfAnticipation.java +++ b/Mage.Sets/src/mage/sets/magic2011/LeylineOfAnticipation.java @@ -37,7 +37,7 @@ import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Rarity; import mage.constants.Zone; -import mage.filter.common.FilterCreatureCard; +import mage.filter.FilterCard; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardTypePredicate; @@ -47,7 +47,8 @@ import mage.filter.predicate.mageobject.CardTypePredicate; */ public class LeylineOfAnticipation extends CardImpl { - private static final FilterCreatureCard filter = new FilterCreatureCard("nonland cards"); + private static final FilterCard filter = new FilterCard("nonland cards"); + static { filter.add(Predicates.not(new CardTypePredicate(CardType.LAND))); } @@ -55,8 +56,13 @@ public class LeylineOfAnticipation extends CardImpl { public LeylineOfAnticipation(UUID ownerId) { super(ownerId, 61, "Leyline of Anticipation", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}{U}"); this.expansionSetCode = "M11"; + this.color.setBlue(true); + + // If Leyline of Anticipation is in your opening hand, you may begin the game with it on the battlefield. this.addAbility(LeylineAbility.getInstance()); + + // You may cast nonland cards as though they had flash. (You may cast them any time you could cast an instant.) this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CastAsThoughItHadFlashEffect(Duration.WhileOnBattlefield, filter))); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/asthough/LeylineOfAnticipationTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/asthough/LeylineOfAnticipationTest.java new file mode 100644 index 00000000000..98280991b68 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/asthough/LeylineOfAnticipationTest.java @@ -0,0 +1,67 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package org.mage.test.cards.asthough; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ + +public class LeylineOfAnticipationTest extends CardTestPlayerBase { + + @Test + public void testCastAsThoughHasFlashDuringCombat() { + addCard(Zone.BATTLEFIELD, playerA, "Plains",2); + + addCard(Zone.HAND, playerA, "Leyline of Anticipation"); + addCard(Zone.HAND, playerA, "Silvercoat Lion"); + setChoice(playerA, "Yes"); + castSpell(2, PhaseStep.DRAW, playerA, "Silvercoat Lion"); + + setStopAt(2, PhaseStep.END_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + assertPermanentCount(playerA, "Leyline of Anticipation", 1); + assertPermanentCount(playerA, "Silvercoat Lion", 1); + + } + + /** + * Tests playing card with flash from graveyard with Yawgmoth's Agenda in play works also + */ + @Test + public void testNoCastPossibleOnOpponentsTurn() { + addCard(Zone.BATTLEFIELD, playerA, "Plains",2); + addCard(Zone.BATTLEFIELD, playerA, "Yawgmoth's Agenda",1); + + addCard(Zone.HAND, playerA, "Leyline of Anticipation"); + setChoice(playerA, "Yes"); + + addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion"); + + castSpell(2, PhaseStep.DRAW, playerA, "Silvercoat Lion"); + + setStopAt(2, PhaseStep.END_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + assertPermanentCount(playerA, "Leyline of Anticipation", 1); + assertGraveyardCount(playerA, "Silvercoat Lion", 0); + assertPermanentCount(playerA, "Silvercoat Lion", 1); + } + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/combat/DamageDistributionTest.java b/Mage.Tests/src/test/java/org/mage/test/combat/DamageDistributionTest.java index d96a226eb0a..53efa803920 100644 --- a/Mage.Tests/src/test/java/org/mage/test/combat/DamageDistributionTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/combat/DamageDistributionTest.java @@ -136,6 +136,7 @@ public class DamageDistributionTest extends CardTestPlayerBase { assertLife(playerA, 14); assertLife(playerB, 20); + assertPermanentCount(playerA, "Leyline of Sanctity", 1); assertPermanentCount(playerB, "Battle Mastery", 1); // no creatures dies assertPermanentCount(playerA, "Heliod, God of the Sun", 1); diff --git a/Mage/src/mage/abilities/effects/common/continious/CastAsThoughItHadFlashEffect.java b/Mage/src/mage/abilities/effects/common/continious/CastAsThoughItHadFlashEffect.java index 5ccfaaddd6f..c330d4cfe6b 100644 --- a/Mage/src/mage/abilities/effects/common/continious/CastAsThoughItHadFlashEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/CastAsThoughItHadFlashEffect.java @@ -37,7 +37,6 @@ import mage.constants.Duration; import mage.constants.Outcome; import mage.filter.FilterCard; import mage.game.Game; -import mage.players.Player; /** * @@ -77,17 +76,10 @@ public class CastAsThoughItHadFlashEffect extends AsThoughEffectImpl { } @Override - public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { - Card card = game.getCard(sourceId); - if (card != null && filter.match(card, game) && card.getSpellAbility().isInUseableZone(game, card, false)) { - if (anyPlayer) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - return controller.getInRange().contains(card.getOwnerId()); - } - } else { - return card.getOwnerId().equals(source.getControllerId()); - } + public boolean applies(UUID affectedSpellId, Ability source, UUID affectedControllerId, Game game) { + if (anyPlayer || source.getControllerId().equals(affectedControllerId)) { + Card card = game.getCard(affectedSpellId); + return card != null && filter.match(card, game); } return false; }