Fixed possible npe, added some tests.

This commit is contained in:
LevelX2 2015-06-18 22:42:13 +02:00
parent 8caa3087bd
commit 42cf7f1f4e
5 changed files with 117 additions and 6 deletions

View file

@ -51,6 +51,7 @@ public class BlackSunsZenith extends CardImpl {
super(ownerId, 39, "Black Sun's Zenith", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{B}{B}");
this.expansionSetCode = "MBS";
// Put X -1/-1 counters on each creature. Shuffle Black Sun's Zenith into its owner's library.
this.getSpellAbility().addEffect(new BlackSunsZenithEffect());
this.getSpellAbility().addEffect(ShuffleSpellEffect.getInstance());
}

View file

@ -47,6 +47,7 @@ public class BlueSunsZenith extends CardImpl {
super(ownerId, 20, "Blue Sun's Zenith", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{X}{U}{U}{U}");
this.expansionSetCode = "MBS";
// Target player draws X cards. Shuffle Blue Sun's Zenith into its owner's library.
this.getSpellAbility().addEffect(new DrawCardTargetEffect(new ManacostVariableValue()));
this.getSpellAbility().addEffect(ShuffleSpellEffect.getInstance());
this.getSpellAbility().addTarget(new TargetPlayer());

View file

@ -0,0 +1,64 @@
/*
* 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.AI.basic;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBaseAI;
/**
*
* @author LevelX2
*/
public class CostModificationTest extends CardTestPlayerBaseAI {
/**
* There seems to be a problem when playing Fluctuator against Computer.
* Once played, I am stuck at "Waiting for Computer" forever...
*/
@Test
public void testFluctuator() {
addCard(Zone.HAND, playerA, "Silvercoat Lion");
// Destroy all artifacts, creatures, and enchantments.
// Cycling ({3}, Discard this card: Draw a card.)
addCard(Zone.HAND, playerA, "Akroma's Vengeance");
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
// Cycling abilities you activate cost you up to {2} less to activate.
addCard(Zone.BATTLEFIELD, playerA, "Fluctuator");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Akroma's Vengeance", 1);
assertPermanentCount(playerA, "Silvercoat Lion", 1);
}
}

View file

@ -113,4 +113,45 @@ public class SpellskiteTest extends CardTestPlayerBase {
}
/**
* Spellskite fails to redirect Cryptic Command on itself
*/
@Test
public void testSpellskite() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
// Choose two -
// Counter target spell;
// or return target permanent to its owner's hand;
// or tap all creatures your opponents control;
// or draw a card.
addCard(Zone.HAND, playerA, "Cryptic Command");
addCard(Zone.BATTLEFIELD, playerB, "Spellskite", 1);
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
addCard(Zone.BATTLEFIELD, playerB, "Island", 1);
addCard(Zone.HAND, playerB, "Lightning Bolt", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", playerA);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cryptic Command", "mode=1Lightning Bolt^mode=2Silvercoat Lion", "Lightning Bolt");
setModeChoice(playerA, "1"); // Counter target spell
setModeChoice(playerA, "2"); // return target permanent to its owner's hand
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{UP}: Change a target of target spell or ability to {this}.", "Cryptic Command");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerB, "Lightning Bolt", 1);
assertGraveyardCount(playerA, "Cryptic Command", 1);
assertHandCount(playerB, "Spellskite", 1);
assertPermanentCount(playerB, "Silvercoat Lion", 1);
assertLife(playerA, 20);
assertLife(playerB, 20);
}
}

View file

@ -35,6 +35,7 @@ import mage.cards.Card;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
/**
@ -58,12 +59,15 @@ public class ShuffleSpellEffect extends OneShotEffect implements MageSingleton {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
if (spellCard != null) {
Player owner = game.getPlayer(spellCard.getOwnerId());
if (owner != null) {
controller.moveCardToLibraryWithInfo(spellCard, source.getSourceId(), game, Zone.STACK, true, true);
owner.shuffleLibrary(game);
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {
Card spellCard = spell.getCard();
if (spellCard != null) {
Player owner = game.getPlayer(spellCard.getOwnerId());
if (owner != null) {
controller.moveCardToLibraryWithInfo(spellCard, source.getSourceId(), game, Zone.STACK, true, true);
owner.shuffleLibrary(game);
}
}
}
return true;