forked from External/mage
Updated and added blocking requirements unit tests
This commit is contained in:
parent
354ca1c062
commit
8e028a1c32
4 changed files with 182 additions and 24 deletions
|
|
@ -6,6 +6,7 @@ import org.junit.Test;
|
|||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
|
|
@ -31,9 +32,44 @@ public class TwoHeadedSliverTest extends CardTestPlayerBase {
|
|||
|
||||
try {
|
||||
execute();
|
||||
fail("Expected exception not thrown");
|
||||
} catch (UnsupportedOperationException e) {
|
||||
assertEquals("Two-Headed Sliver is blocked by 1 creature(s). It has to be blocked by 2 or more.", e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCanBeBlockedByTwoEffectAbility() {
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||
// Two-Headed Sliver {1}{R} 1/1
|
||||
// All Sliver creatures have "This creature can't be blocked except by two or more creatures."
|
||||
addCard(Zone.HAND, playerA, "Two-Headed Sliver");
|
||||
|
||||
// Silvercoat Lion {1}{W} 2/2
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
// Coral Barrier {2}{U} 1/3
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Coral Barrier");
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Two-Headed Sliver");
|
||||
|
||||
attack(3, playerA, "Two-Headed Sliver");
|
||||
// Two blocks will succeed
|
||||
block(3, playerB, "Silvercoat Lion", "Two-Headed Sliver");
|
||||
block(3, playerB, "Coral Barrier", "Two-Headed Sliver");
|
||||
|
||||
setStopAt(3, PhaseStep.END_TURN);
|
||||
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
// Two-Headed Sliver died from the block
|
||||
assertPermanentCount(playerA, "Two-Headed Sliver", 0);
|
||||
assertPermanentCount(playerB, "Silvercoat Lion", 1);
|
||||
assertPermanentCount(playerB, "Coral Barrier", 1);
|
||||
assertGraveyardCount(playerA, "Two-Headed Sliver", 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@ import org.junit.Test;
|
|||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -217,6 +218,7 @@ public class BlockRequirementTest extends CardTestPlayerBase {
|
|||
|
||||
try {
|
||||
execute();
|
||||
fail("Expected exception not thrown");
|
||||
} catch (UnsupportedOperationException e) {
|
||||
assertEquals("Breaker of Armies is blocked by 1 creature(s). It has to be blocked by 2 or more.", e.getMessage());
|
||||
}
|
||||
|
|
@ -232,17 +234,17 @@ public class BlockRequirementTest extends CardTestPlayerBase {
|
|||
addCard(Zone.BATTLEFIELD, playerA, "Slayer's Cleaver");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Memnite"); // {1} 1/1
|
||||
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Dimensional Infiltrator"); // 2/1 - Eldrazi
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Llanowar Elves"); // 1/1
|
||||
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip", "Memnite"); // pumps to 4/2
|
||||
attack(1, playerA, "Memnite"); // must be blocked by Dimensional Infiltrator
|
||||
block(1, playerB, "Llanowar Elves", "Memnite"); // should not be allowed as only blocker
|
||||
|
||||
|
||||
setStopAt(1, PhaseStep.END_COMBAT);
|
||||
execute();
|
||||
|
||||
|
||||
assertPermanentCount(playerA, "Slayer's Cleaver", 1);
|
||||
assertLife(playerB, 20);
|
||||
assertGraveyardCount(playerA, "Memnite", 1);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Test restrictions for choosing attackers and blockers.
|
||||
*
|
||||
|
|
@ -38,7 +41,7 @@ public class AttackBlockRestrictionsTest extends CardTestPlayerBase {
|
|||
* Frost
|
||||
*/
|
||||
@Test
|
||||
public void testWallofWrost() {
|
||||
public void testWallofFrost() {
|
||||
// Whenever Wall of Frost blocks a creature, that creature doesn't untap during its controller's next untap step.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Wall of Frost"); // 0/7
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Craw Wurm");
|
||||
|
|
@ -338,36 +341,36 @@ public class AttackBlockRestrictionsTest extends CardTestPlayerBase {
|
|||
*/
|
||||
@Test
|
||||
public void testMustAttackButCannotAttackAlone()
|
||||
{
|
||||
{
|
||||
/* Mogg Flunkies {1}{R} 3/3
|
||||
Creature — Goblin
|
||||
Mogg Flunkies can't attack or block alone.
|
||||
*/
|
||||
String flunkies = "Mogg Flunkies";
|
||||
|
||||
|
||||
/* Goblin Assault {2}{R}
|
||||
* Enchantment
|
||||
* Enchantment
|
||||
At the beginning of your upkeep, create a 1/1 red Goblin creature token with haste.
|
||||
Goblin creatures attack each turn if able.
|
||||
*/
|
||||
String gAssault = "Goblin Assault";
|
||||
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, flunkies);
|
||||
addCard(Zone.BATTLEFIELD, playerB, gAssault);
|
||||
|
||||
|
||||
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
|
||||
assertTapped(flunkies, false);
|
||||
assertLife(playerB, 20);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Reported bug: Tromokratis is unable to be blocked.
|
||||
*/
|
||||
@Test
|
||||
public void tromokratisBlockedByAll() {
|
||||
/*
|
||||
/*
|
||||
Tromokratis {5}{U}{U}
|
||||
Legendary Creature — Kraken 8/8
|
||||
Tromokratis has hexproof unless it's attacking or blocking.
|
||||
|
|
@ -376,30 +379,30 @@ public class AttackBlockRestrictionsTest extends CardTestPlayerBase {
|
|||
String tromokratis = "Tromokratis";
|
||||
String gBears = "Grizzly Bears"; // {1}{G} 2/2
|
||||
String memnite = "Memnite"; // {0} 1/1
|
||||
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, tromokratis);
|
||||
addCard(Zone.BATTLEFIELD, playerB, gBears);
|
||||
addCard(Zone.BATTLEFIELD, playerB, memnite);
|
||||
|
||||
|
||||
attack(1, playerA, tromokratis);
|
||||
block(1, playerB, gBears, tromokratis);
|
||||
block(1, playerB, memnite, tromokratis);
|
||||
|
||||
|
||||
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
|
||||
assertLife(playerB, 20);
|
||||
assertGraveyardCount(playerB, gBears, 1);
|
||||
assertGraveyardCount(playerB, memnite, 1);
|
||||
assertTapped(tromokratis, true);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Reported bug: Tromokratis is unable to be blocked.
|
||||
*/
|
||||
@Test
|
||||
public void tromokratisNotBlockedByAll() {
|
||||
/*
|
||||
/*
|
||||
Tromokratis {5}{U}{U}
|
||||
Legendary Creature — Kraken 8/8
|
||||
Tromokratis has hexproof unless it's attacking or blocking.
|
||||
|
|
@ -409,24 +412,138 @@ public class AttackBlockRestrictionsTest extends CardTestPlayerBase {
|
|||
String gBears = "Grizzly Bears"; // {1}{G} 2/2
|
||||
String memnite = "Memnite"; // {0} 1/1
|
||||
String hGiant = "Hill Giant"; // {3}{R} 3/3
|
||||
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, tromokratis);
|
||||
addCard(Zone.BATTLEFIELD, playerB, gBears);
|
||||
addCard(Zone.BATTLEFIELD, playerB, memnite);
|
||||
addCard(Zone.BATTLEFIELD, playerB, hGiant);
|
||||
|
||||
|
||||
attack(2, playerB, hGiant); // forces a creature to be tapped so unable to block Tromokratis, which means it cannot be blocked at all
|
||||
attack(3, playerA, tromokratis);
|
||||
block(3, playerB, gBears, tromokratis);
|
||||
block(3, playerB, memnite, tromokratis);
|
||||
|
||||
|
||||
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
|
||||
assertLife(playerB, 12); // Hill Giant could not block it, so no other creature could block Tromokratis either
|
||||
assertPermanentCount(playerB, gBears, 1);
|
||||
assertPermanentCount(playerB, memnite, 1);
|
||||
assertTapped(tromokratis, true);
|
||||
assertTapped(hGiant, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void underworldCerberusBlockedByOneTest() {
|
||||
/* Underworld Cerberus {3}{B}{3} 6/6
|
||||
* Underworld Cerberus can't be blocked except by three or more creatures.
|
||||
* Cards in graveyards can't be the targets of spells or abilities.
|
||||
* When Underworld Cerberus dies, exile it and each player returns all creature cards from his or her graveyard to his or her hand.
|
||||
*/
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Underworld Cerberus");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Memnite"); // 1/1
|
||||
|
||||
attack(3, playerA, "Underworld Cerberus");
|
||||
block(3, playerB, "Memnite", "Underworld Cerberus");
|
||||
|
||||
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
|
||||
|
||||
try {
|
||||
execute();
|
||||
fail("Expected exception not thrown");
|
||||
} catch(UnsupportedOperationException e) {
|
||||
assertEquals("Underworld Cerberus is blocked by 1 creature(s). It has to be blocked by 3 or more.", e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void underworldCerberusBlockedByTwoTest() {
|
||||
/* Underworld Cerberus {3}{B}{3} 6/6
|
||||
* Underworld Cerberus can't be blocked except by three or more creatures.
|
||||
* Cards in graveyards can't be the targets of spells or abilities.
|
||||
* When Underworld Cerberus dies, exile it and each player returns all creature cards from his or her graveyard to his or her hand.
|
||||
*/
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Underworld Cerberus");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Memnite", 2); // 1/1
|
||||
|
||||
attack(3, playerA, "Underworld Cerberus");
|
||||
block(3, playerB, "Memnite", "Underworld Cerberus");
|
||||
block(3, playerB, "Memnite", "Underworld Cerberus");
|
||||
|
||||
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
|
||||
|
||||
try {
|
||||
execute();
|
||||
fail("Expected exception not thrown");
|
||||
} catch(UnsupportedOperationException e) {
|
||||
assertEquals("Underworld Cerberus is blocked by 2 creature(s). It has to be blocked by 3 or more.", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void underworldCerberusBlockedByThreeTest() {
|
||||
|
||||
/* Underworld Cerberus {3}{B}{3} 6/6
|
||||
* Underworld Cerberus can't be blocked except by three or more creatures.
|
||||
* Cards in graveyards can't be the targets of spells or abilities.
|
||||
* When Underworld Cerberus dies, exile it and each player returns all creature cards from his or her graveyard to his or her hand.
|
||||
*/
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Underworld Cerberus");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Memnite", 3); // 1/1
|
||||
|
||||
|
||||
// Blocked by 3 creatures - this is acceptable
|
||||
attack(3, playerA, "Underworld Cerberus");
|
||||
block(3, playerB, "Memnite", "Underworld Cerberus");
|
||||
block(3, playerB, "Memnite", "Underworld Cerberus");
|
||||
block(3, playerB, "Memnite", "Underworld Cerberus");
|
||||
|
||||
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
|
||||
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Underworld Cerberus", 1);
|
||||
assertPermanentCount(playerB, "Memnite", 0);
|
||||
assertGraveyardCount(playerB, "Memnite", 3);
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void underworldCerberusBlockedByTenTest() {
|
||||
/* Underworld Cerberus {3}{B}{3} 6/6
|
||||
* Underworld Cerberus can't be blocked except by three or more creatures.
|
||||
* Cards in graveyards can't be the targets of spells or abilities.
|
||||
* When Underworld Cerberus dies, exile it and each player returns all creature cards from his or her graveyard to his or her hand.
|
||||
*/
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Underworld Cerberus");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Memnite", 10); // 1/1
|
||||
|
||||
// Blocked by 10 creatures - this is acceptable as it's >3
|
||||
attack(3, playerA, "Underworld Cerberus");
|
||||
for(int i = 0; i < 10; i++) {
|
||||
block(3, playerB, "Memnite", "Underworld Cerberus");
|
||||
}
|
||||
|
||||
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
|
||||
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Underworld Cerberus", 0);
|
||||
assertPermanentCount(playerB, "Memnite", 4);
|
||||
// Actually exiled when it dies
|
||||
assertGraveyardCount(playerA, "Underworld Cerberus", 0);
|
||||
assertExileCount(playerA, "Underworld Cerberus", 1);
|
||||
// Cards are returned to their owner's hand when Underworld Cerberus dies
|
||||
assertGraveyardCount(playerB, "Memnite", 0);
|
||||
assertHandCount(playerB, "Memnite", 6);
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.junit.Test;
|
|||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -136,6 +137,7 @@ public class CanBlockMultipleCreaturesTest extends CardTestPlayerBase {
|
|||
// Will fail on purpose - we are trying to block too many creatures!
|
||||
try {
|
||||
execute();
|
||||
fail("Expected exception not thrown");
|
||||
} catch(UnsupportedOperationException e) {
|
||||
assertEquals("Hundred-Handed One cannot block Fabled Hero", e.getMessage());
|
||||
}
|
||||
|
|
@ -215,6 +217,7 @@ public class CanBlockMultipleCreaturesTest extends CardTestPlayerBase {
|
|||
// Catch the illegal block
|
||||
try {
|
||||
execute();
|
||||
fail("Expected exception not thrown");
|
||||
} catch(UnsupportedOperationException e) {
|
||||
assertEquals("Embraal Bruiser is blocked by 1 creature(s). It has to be blocked by 2 or more.", e.getMessage());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue