Added a test.

This commit is contained in:
LevelX2 2016-10-02 16:15:04 +02:00
parent 98db0fa21b
commit 5469facdd6
2 changed files with 45 additions and 3 deletions

View file

@ -145,10 +145,10 @@ class EtherswornCanonistReplacementEffect extends ContinuousRuleModifyingEffectI
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { 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()); Card card = game.getCard(event.getSourceId());
if (card != null && !card.getCardType().contains(CardType.ARTIFACT) && watcher.castNonArtifactSpell(event.getPlayerId())) { if (card != null && !card.getCardType().contains(CardType.ARTIFACT)) {
return true; EtherswornCanonistWatcher watcher = (EtherswornCanonistWatcher) game.getState().getWatchers().get(EtherswornCanonistWatcher.class.getName());
return watcher != null && watcher.castNonArtifactSpell(event.getPlayerId());
} }
return false; return false;
} }

View file

@ -29,6 +29,7 @@ package org.mage.test.cards.rules;
import mage.constants.PhaseStep; import mage.constants.PhaseStep;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Test; import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase; 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);
}
} }