From 5469facdd6ddd2d4eceaa6050290d2116b5cb235 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 2 Oct 2016 16:15:04 +0200 Subject: [PATCH] Added a test. --- .../shardsofalara/EtherswornCanonist.java | 6 +-- .../mage/test/cards/rules/CantCastTest.java | 42 +++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Mage.Sets/src/mage/sets/shardsofalara/EtherswornCanonist.java b/Mage.Sets/src/mage/sets/shardsofalara/EtherswornCanonist.java index fdb474cb7e..744c00008e 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/EtherswornCanonist.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/EtherswornCanonist.java @@ -145,10 +145,10 @@ class EtherswornCanonistReplacementEffect extends ContinuousRuleModifyingEffectI @Override public boolean applies(GameEvent event, Ability source, Game game) { - EtherswornCanonistWatcher watcher = (EtherswornCanonistWatcher) game.getState().getWatchers().get(EtherswornCanonistWatcher.class.getName()); Card card = game.getCard(event.getSourceId()); - if (card != null && !card.getCardType().contains(CardType.ARTIFACT) && watcher.castNonArtifactSpell(event.getPlayerId())) { - return true; + if (card != null && !card.getCardType().contains(CardType.ARTIFACT)) { + EtherswornCanonistWatcher watcher = (EtherswornCanonistWatcher) game.getState().getWatchers().get(EtherswornCanonistWatcher.class.getName()); + return watcher != null && watcher.castNonArtifactSpell(event.getPlayerId()); } return false; } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/rules/CantCastTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/rules/CantCastTest.java index d4a3aa7d07..7c031f75f4 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/rules/CantCastTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/rules/CantCastTest.java @@ -29,6 +29,7 @@ package org.mage.test.cards.rules; import mage.constants.PhaseStep; import mage.constants.Zone; +import mage.counters.CounterType; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -194,4 +195,45 @@ public class CantCastTest extends CardTestPlayerBase { } + /** + * I "Aether Vialed" (Aether Vial) an Ethersworn Canonist into the + * battlefield in response to a colored spell(an Elf). The Canonist entered + * the battlefield. Then, my oponente used Abrupt Decay to destroy it and + * continue to play spells normaly. Ethersworn Canonist effect should + * imediately effect the game as it entered the battlefield, and still count + * spells cast earlier in the turn. In other words, my oponent shouldn't be + * able to cast anymore colored spells. + */ + @Test + public void testEtherswornCanonist() { + // Each player who has cast a nonartifact spell this turn can't cast additional nonartifact spells. + addCard(Zone.HAND, playerA, "Ethersworn Canonist", 4); // Creaturre - {1}{W} + + // At the beginning of your upkeep, you may put a charge counter on Aether Vial. + // {T}: You may put a creature card with converted mana cost equal to the number of charge counters on Aether Vial from your hand onto the battlefield. + addCard(Zone.BATTLEFIELD, playerA, "Aether Vial", 1); + // addCounters(1, PhaseStep.UPKEEP, playerA, "Aether Vial", CounterType.CHARGE, 1); + + addCard(Zone.HAND, playerB, "Llanowar Elves", 1); // Creature {G} + addCard(Zone.BATTLEFIELD, playerB, "Swamp", 1); + addCard(Zone.BATTLEFIELD, playerB, "Forest", 2); + // Abrupt Decay can't be countered by spells or abilities. + // Destroy target nonland permanent with converted mana cost 3 or less. + addCard(Zone.HAND, playerB, "Abrupt Decay", 1); // {B}{G} + + castSpell(4, PhaseStep.PRECOMBAT_MAIN, playerB, "Llanowar Elves"); + activateAbility(4, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: You"); + setChoice(playerB, "Ethersworn Canonist"); + castSpell(4, PhaseStep.POSTCOMBAT_MAIN, playerB, "Abrupt Decay", "Ethersworn Canonist"); + setStopAt(4, PhaseStep.END_TURN); + execute(); + + assertCounterCount(playerA, "Aether Vial", CounterType.CHARGE, 2); + assertPermanentCount(playerB, "Llanowar Elves", 1); + + assertPermanentCount(playerA, "Ethersworn Canonist", 1); + assertHandCount(playerB, "Abrupt Decay", 1); + + } + }