Added some tests.

This commit is contained in:
LevelX2 2015-05-30 15:16:12 +02:00
parent 726fc48e49
commit 02aaf150db
4 changed files with 135 additions and 16 deletions

View file

@ -27,6 +27,7 @@
*/
package mage.sets.khansoftarkir;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
@ -101,18 +102,16 @@ class NarsetEnlightenedMasterExileEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null && sourceObject != null) {
for (int i = 0; i < 4; i++) {
if (player.getLibrary().size() > 0) {
Card card = player.getLibrary().getFromTop(game);
if (card != null) {
player.moveCardToExileWithInfo(card, CardUtil.getCardExileZoneId(game, source), sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
if (!card.getCardType().contains(CardType.CREATURE) && !card.getCardType().contains(CardType.LAND)) {
ContinuousEffect effect = new NarsetEnlightenedMasterCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
}
}
List<Card> cards = player.getLibrary().getTopCards(game, 4);
player.moveCards(cards, Zone.LIBRARY, Zone.EXILED, source, game);
for (Card card : cards) {
if (game.getState().getZone(card.getId()) == Zone.EXILED &&
!card.getCardType().contains(CardType.CREATURE) &&
!card.getCardType().contains(CardType.LAND)) {
ContinuousEffect effect = new NarsetEnlightenedMasterCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
}
return true;
}
@ -150,10 +149,12 @@ class NarsetEnlightenedMasterCastFromExileEffect extends AsThoughEffectImpl {
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (objectId.equals(getTargetPointer().getFirst(game, source)) && affectedControllerId.equals(source.getControllerId())) {
Card card = game.getCard(objectId);
if (card != null && game.getState().getZone(objectId) == Zone.EXILED) {
if (card != null) {
Player player = game.getPlayer(affectedControllerId);
player.setCastSourceIdWithAlternateMana(objectId, null);
return true;
if (player != null) {
player.setCastSourceIdWithAlternateMana(objectId, null);
return true;
}
}
}
return false;

View file

@ -58,7 +58,6 @@ public class OrdealOfHeliod extends CardImpl {
this.expansionSetCode = "THS";
this.subtype.add("Aura");
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);

View file

@ -79,4 +79,49 @@ public class PlayFromNonHandZoneTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Worldheart Phoenix", 1);
}
@Test
public void testNarsetEnlightenedMaster() {
// First strike
// Hexproof
// Whenever Narset, Enlightented Master attacks, exile the top four cards of your library. Until end of turn, you may cast noncreature cards exiled with Narset this turn without paying their mana costs.
addCard(Zone.BATTLEFIELD, playerB, "Narset, Enlightened Master", 1);
skipInitShuffling();
addCard(Zone.LIBRARY, playerB, "Silvercoat Lion");
addCard(Zone.LIBRARY, playerB, "Abzan Banner");
// Ferocious - If you control a creature with power 4 or greater, you may cast Dragon Grip as though it had flash. (You may cast it any time you could cast an instant.)
// Enchant creature
// Enchanted creature gets +2/+0 and has first strike.
addCard(Zone.LIBRARY, playerB, "Dragon Grip");
// You gain 2 life for each creature you control.
addCard(Zone.LIBRARY, playerB, "Peach Garden Oath");
addCard(Zone.LIBRARY, playerB, "Plains");
attack(2, playerB, "Narset, Enlightened Master");
castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Silvercoat Lion"); // can't be cast from exile
castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Abzan Banner"); // can be cast from exile
castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Dragon Grip", "Narset, Enlightened Master"); // can be cast from exile
castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Peach Garden Oath"); // can be cast from exile
setStopAt(2, PhaseStep.END_TURN);
execute();
assertExileCount("Silvercoat Lion", 1);
assertPermanentCount(playerB, "Abzan Banner", 1);
assertPermanentCount(playerB, "Dragon Grip", 1);
assertGraveyardCount(playerB, "Peach Garden Oath", 1);
assertPowerToughness(playerB, "Narset, Enlightened Master", 5, 2);
assertHandCount(playerB, "Plains", 1);
assertLife(playerA, 17);
assertLife(playerB, 22);
}
}

View file

@ -0,0 +1,74 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.test.cards.single.ths;
import mage.constants.CardType;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.permanent.Permanent;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class OrdealEnchantmentsTest extends CardTestPlayerBase {
@Test
public void testOrdealofHeliod() {
addCard(Zone.BATTLEFIELD, playerB, "Plains", 2);
// Enchant creature
// Whenever enchanted creature attacks, put a +1/+1 counter on it. Then if it has three or more +1/+1 counters on it, sacrifice Ordeal of Heliod.
// When you sacrifice Ordeal of Heliod, you gain 10 life.
addCard(Zone.HAND, playerB, "Ordeal of Heliod");
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Ordeal of Heliod", "Silvercoat Lion");
attack(2, playerB, "Silvercoat Lion");
attack(4, playerB, "Silvercoat Lion");
attack(6, playerB, "Silvercoat Lion");
setStopAt(6, PhaseStep.END_COMBAT);
execute();
assertLife(playerA, 8); // 3 + 4 + 5 = 12
assertLife(playerB, 30);
assertGraveyardCount(playerB, "Ordeal of Heliod", 1);
assertPermanentCount(playerB, "Silvercoat Lion", 1);
assertPowerToughness(playerB, "Silvercoat Lion", 5,5);
}
}