* Tests - Added a damage distribution test and fixed a bug of test target handling that caused the CrypticCommandTest to fail.

This commit is contained in:
LevelX2 2014-07-14 23:02:27 +02:00
parent de47dbad43
commit d989131980
3 changed files with 127 additions and 2 deletions

View file

@ -49,6 +49,8 @@ public class CrypticCommandTest extends CardTestPlayerBase {
@Test
public void testCommand() {
addCard(Zone.HAND, playerA, "Thoughtseize");
// Counter target spell. If that spell is countered this way, put it into its owner's hand instead of into that player's graveyard.
// Draw a card.
addCard(Zone.HAND, playerA, "Remand");
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
@ -70,10 +72,12 @@ public class CrypticCommandTest extends CardTestPlayerBase {
assertLife(playerA, 20);
assertLife(playerB, 20);
assertHandCount(playerA, 2);
assertGraveyardCount(playerA, "Remand", 1);
assertGraveyardCount(playerA, 1);
assertHandCount(playerB, 0); // Because Cryptic Command has no legal target playerB does not draw a card and has 0 cards in hand
assertGraveyardCount(playerB, "Cryptic Command", 1);
assertGraveyardCount(playerB, 1);
assertHandCount(playerA, 2); // Thoughtsize + card drawn from Remand
assertHandCount(playerB, 0); // Because Cryptic Command has no legal target playerB does not draw a card and has 0 cards in hand
}

View file

@ -3,6 +3,7 @@ package org.mage.test.combat;
import junit.framework.Assert;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.permanent.Permanent;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -66,4 +67,121 @@ public class DamageDistributionTest extends CardTestPlayerBase {
assertLife(playerB, 4);
}
@Test
public void testDoubleStrikeTrampleVersusIndestructible() {
addCard(Zone.BATTLEFIELD, playerA, "Darksteel Gargoyle");
addCard(Zone.BATTLEFIELD, playerB, "Drogskol Reaver");
addCard(Zone.BATTLEFIELD, playerB, "Primal Rage");
attack(2, playerB, "Drogskol Reaver");
block(2,playerA,"Darksteel Gargoyle","Drogskol Reaver");
setStopAt(2, PhaseStep.END_TURN);
execute();
// no creatures dies
assertPermanentCount(playerA, "Darksteel Gargoyle", 1);
assertPermanentCount(playerB, "Drogskol Reaver", 1);
// creature is blocked
// blocker does not die and second strike can trample through for 3
assertLife(playerA, 17);
assertLife(playerB, 26);
}
/**
*
*/
@Test
//@Ignore
public void testDoubleStrikeTrampleVersusIndestructibleGod() {
/**
* Heliod, God of the Sun
* Legendary Enchantment Creature God 5/6, 3W
* Indestructible
* As long as your devotion to white is less than five, Heliod isn't a creature. (Each {W} in the mana costs of permanents you control counts toward your devotion to white.)
* Other creatures you control have vigilance.
* {2}{W}{W}: Put a 2/1 white Cleric enchantment creature token onto the battlefield.
*/
addCard(Zone.BATTLEFIELD, playerA, "Heliod, God of the Sun");
addCard(Zone.BATTLEFIELD, playerA, "Terra Eternal"); // only for devotion
addCard(Zone.BATTLEFIELD, playerA, "Terra Eternal"); // only for devotion
/* Primeval Titan
* Creature Giant 6/6, 4GG
* Trample
* Whenever Primeval Titan enters the battlefield or attacks, you may search your library for up to two land cards, put them onto the battlefield tapped, then shuffle your library.
*/
addCard(Zone.BATTLEFIELD, playerB, "Primeval Titan");
addCard(Zone.BATTLEFIELD, playerB, "Plains", 3);
// {W}{W}{2}
// If Leyline of Sanctity is in your opening hand, you may begin the game with it on the battlefield.
// You have hexproof.
addCard(Zone.HAND, playerA, "Leyline of Sanctity", 1);
// Enchantment - Aura {W}{2}
// Enchant creature
// Enchanted creature has double strike.
addCard(Zone.HAND, playerB, "Battle Mastery");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Battle Mastery","Primeval Titan");
attack(2, playerB, "Primeval Titan");
block(2,playerA,"Heliod, God of the Sun","Primeval Titan");
setStopAt(2, PhaseStep.END_TURN);
execute();
// creature is blocked
// blocker does not die and second strike can trample through for 6
assertLife(playerA, 14);
assertLife(playerB, 20);
assertPermanentCount(playerB, "Battle Mastery", 1);
// no creatures dies
assertPermanentCount(playerA, "Heliod, God of the Sun", 1);
assertPowerToughness(playerA, "Heliod, God of the Sun", 5, 6);
assertPermanentCount(playerB, "Primeval Titan", 1);
assertPowerToughness(playerB, "Primeval Titan", 6,6);
}
/**
* Damage of one combat phase
*/
@Test
public void testCombatDamagePhyrexianUnlife() {
addCard(Zone.HAND, playerA, "Lightning Bolt",6);
addCard(Zone.BATTLEFIELD, playerA, "Mountain",6);
/**
* Phyrexian Unlife {2}{W}
* Enchantment
*
* You don't lose the game for having 0 or less life.
* As long as you have 0 or less life, all damage is dealt to you as though its source had infect.
*/
addCard(Zone.BATTLEFIELD, playerA, "Phyrexian Unlife");
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion",2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt","targetPlayer=PlayerA");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt","targetPlayer=PlayerA");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt","targetPlayer=PlayerA");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt","targetPlayer=PlayerA");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt","targetPlayer=PlayerA");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt","targetPlayer=PlayerA");
attack(2, playerB, "Silvercoat Lion");
attack(2, playerB, "Silvercoat Lion");
setStopAt(2, PhaseStep.END_TURN);
execute();
// No poison counter yet
assertCounterCount(playerA, CounterType.POISON, 0);
assertPermanentCount(playerB, "Silvercoat Lion", 2);
// 4 damage from attack must be dealt as damage (not as poison counter)
assertLife(playerA, -2);
assertLife(playerB, 20);
}
}

View file

@ -344,6 +344,9 @@ public class TestPlayer extends ComputerPlayer {
boolean result = true;
for (int i = 1; i < groups.length; i++) {
String group = groups[i];
if (group.startsWith("spellOnStack")) {
break;
}
if (ability instanceof SpellAbility && ((SpellAbility) ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
if (group.contains("FuseLeft-")) {
result = handleTargetString(group.substring(group.indexOf("FuseLeft-") + 9), ability, game);