Added some tests.

This commit is contained in:
LevelX2 2015-06-26 12:10:17 +02:00
parent 7a8e1f11c7
commit 5b7d57aec9
3 changed files with 132 additions and 30 deletions

View file

@ -25,18 +25,16 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -48,14 +46,15 @@ import mage.game.permanent.token.Token;
*/
public class PhyrexianRebirth extends CardImpl {
public PhyrexianRebirth (UUID ownerId) {
public PhyrexianRebirth(UUID ownerId) {
super(ownerId, 15, "Phyrexian Rebirth", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{4}{W}{W}");
this.expansionSetCode = "MBS";
// Destroy all creatures, then put an X/X colorless Horror artifact creature token onto the battlefield, where X is the number of creatures destroyed this way.
this.getSpellAbility().addEffect(new PhyrexianRebirthEffect());
}
public PhyrexianRebirth (final PhyrexianRebirth card) {
public PhyrexianRebirth(final PhyrexianRebirth card) {
super(card);
}
@ -78,7 +77,7 @@ public class PhyrexianRebirth extends CardImpl {
@Override
public boolean apply(Game game, Ability source) {
int count = 0;
for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) {
count += permanent.destroy(source.getSourceId(), game, false) ? 1 : 0;
}
HorrorToken horrorToken = new HorrorToken();
@ -95,14 +94,15 @@ public class PhyrexianRebirth extends CardImpl {
}
class HorrorToken extends Token {
public HorrorToken() {
super("Horror", "X/X colorless Horror artifact creature token");
cardType.add(CardType.ARTIFACT);
cardType.add(CardType.CREATURE);
subtype.add("Horror");
power = new MageInt(0);
toughness = new MageInt(0);
class HorrorToken extends Token {
public HorrorToken() {
super("Horror", "X/X colorless Horror artifact creature token");
cardType.add(CardType.ARTIFACT);
cardType.add(CardType.CREATURE);
subtype.add("Horror");
power = new MageInt(0);
toughness = new MageInt(0);
}
}
}
}

View file

@ -29,6 +29,7 @@ package org.mage.test.cards.restriction;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -36,18 +37,18 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
*
* @author LevelX2
*/
public class CantAttackTest extends CardTestPlayerBase {
/**
* Tests "If all other elves get the Forestwalk ability and can't be blockt from creatures whose controler has a forest in game"
* Tests "If all other elves get the Forestwalk ability and can't be blockt
* from creatures whose controler has a forest in game"
*/
@Test
public void testAttack() {
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); // 2/2
addCard(Zone.BATTLEFIELD, playerA, "Myr Enforcer"); // 4/4
// Except for creatures named Akron Legionnaire and artifact creatures, creatures you control can't attack.
addCard(Zone.BATTLEFIELD, playerB, "Akron Legionnaire"); // 8/4
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); // 2/2
addCard(Zone.BATTLEFIELD, playerB, "Myr Enforcer"); // 4/4
@ -64,20 +65,21 @@ public class CantAttackTest extends CardTestPlayerBase {
assertLife(playerA, 8); // 8 + 4
assertLife(playerB, 14); // 4 + 2
}
@Test
@Test
public void testAttackHarborSerpent() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); // 2/2
// Islandwalk (This creature is unblockable as long as defending player controls an Island.)
// Harbor Serpent can't attack unless there are five or more Islands on the battlefield.
addCard(Zone.BATTLEFIELD, playerA, "Harbor Serpent"); // 5/5
addCard(Zone.HAND, playerA, "Island");
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); // 2/2
addCard(Zone.BATTLEFIELD, playerB, "Harbor Serpent"); // 5/5
attack(2, playerB, "Harbor Serpent");
attack(2, playerB, "Silvercoat Lion");
@ -88,9 +90,32 @@ public class CantAttackTest extends CardTestPlayerBase {
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerB, 13);
assertLife(playerA, 18);
assertLife(playerB, 13);
assertLife(playerA, 18);
}
}
@Test
public void testBlazingArchon() {
// Flying
// Creatures can't attack you.
addCard(Zone.BATTLEFIELD, playerA, "Blazing Archon");
addCard(Zone.BATTLEFIELD, playerA, "Ajani Goldmane"); // Planeswalker 4 loyality counter
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); // 2/2
addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox"); // 2/4
attack(2, playerB, "Pillarfield Ox", "Ajani Goldmane");
attack(2, playerB, "Silvercoat Lion", playerA);
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerA, 20);
assertTapped("Silvercoat Lion", false);
assertTapped("Pillarfield Ox", true);
assertCounterCount("Ajani Goldmane", CounterType.LOYALTY, 2);
}
}

View file

@ -0,0 +1,77 @@
/*
* 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.commander.duel;
import java.io.FileNotFoundException;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.GameException;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestCommanderDuelBase;
/**
* This tests checks for problems that could arise from the possible commander
* returns to the command zone option.
*
* @author LevelX2
*/
public class CommanderReplaceEffectTest extends CardTestCommanderDuelBase {
@Override
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
setDecknamePlayerA("CommanderDuel_UW.dck"); // Commander = Daxos of Meletis
setDecknamePlayerB("CommanderDuel_UW.dck"); // Commander = Daxos of Meletis
return super.createNewGameAndPlayers();
}
@Test
public void castCommanderWithFlash() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
addCard(Zone.BATTLEFIELD, playerB, "Plains", 6);
addCard(Zone.HAND, playerB, "Phyrexian Rebirth", 1);
// Daxos of Meletis can't be blocked by creatures with power 3 or greater.
// Whenever Daxos of Meletis deals combat damage to a player, exile the top card of that player's library. You gain life equal to that card's converted mana cost. Until end of turn, you may cast that card and you may spend mana as though it were mana of any color to cast it.
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Daxos of Meletis");
// Destroy all creatures, then put an X/X colorless Horror artifact creature token onto the battlefield, where X is the number of creatures destroyed this way.
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Phyrexian Rebirth");
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Daxos of Meletis", 0);
assertGraveyardCount(playerA, "Daxos of Meletis", 0);
assertPermanentCount(playerB, "Horror", 1);
assertPowerToughness(playerB, "Horror", 1, 1);
}
}