Added test for Aura cards cast with Disturb. Closes #9360.

This commit is contained in:
Alex Vasile 2022-08-12 23:46:46 -04:00
parent 3cf9be30cf
commit 89466d0f8f

View file

@ -14,6 +14,13 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
*/
public class DisturbTest extends CardTestPlayerBase {
/**
* Relevant ruling:
* - When you cast a spell using a card's disturb ability, the card is put onto the stack with its
* back face up. The resulting spell has all the characteristics of that face.
* - The mana value of a spell cast using disturb is determined by the mana cost on the
* front face of the card, no matter what the total cost to cast the spell was.
*/
@Test
public void test_SpellAttributesOnStack() {
// Disturb {1}{U}
@ -32,9 +39,6 @@ public class DisturbTest extends CardTestPlayerBase {
checkStackObject("on stack", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Hook-Haunt Drifter with Disturb", 1);
runCode("check stack", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
// Stack must contain another card side, so spell/card characteristics must be diff from main side (only mana value is same)
// rules:
// When you cast a spell using a card's disturb ability, the card is put onto the stack with its
// back face up. The resulting spell has all the characteristics of that face.
Spell spell = (Spell) game.getStack().getFirst();
Assert.assertEquals("Hook-Haunt Drifter", spell.getName());
Assert.assertEquals(1, spell.getCardType(game).size());
@ -45,9 +49,6 @@ public class DisturbTest extends CardTestPlayerBase {
Assert.assertEquals(2, spell.getToughness().getValue());
Assert.assertEquals("U", spell.getColor(game).toString());
// rules:
// The mana value of a spell cast using disturb is determined by the mana cost on the
// front face of the card, no matter what the total cost to cast the spell was.
Assert.assertEquals(2, spell.getManaValue()); // {1}{U}
Assert.assertEquals("{1}{U}", spell.getSpellAbility().getManaCosts().getText());
@ -71,21 +72,25 @@ public class DisturbTest extends CardTestPlayerBase {
assertAllCommandsUsed();
}
/**
* Relevant ruling:
* To determine the total cost of a spell, start with the mana cost or alternative cost
* (such as a disturb cost) you're paying, add any cost increases, then apply any cost
* reductions. The mana value of a spell cast using disturb is determined by the mana cost on
* the front face of the card, no matter what the total cost to cast the spell was. (This is
* a special rule that applies only to transforming double faced-cards, including ones with
* disturb.)
*/
@Test
public void test_CostModification_CanPlay() {
// rules:
// To determine the total cost of a spell, start with the mana cost or alternative cost
// (such as a disturb cost) you're paying, add any cost increases, then apply any cost
// reductions. The mana value of a spell cast using disturb is determined by the mana cost on
// the front face of the card, no matter what the total cost to cast the spell was. (This is
// a special rule that applies only to transforming double faced-cards, including ones with
// disturb.)
// Disturb {1}{U}
// Hook-Haunt Drifter
addCard(Zone.GRAVEYARD, playerA, "Baithook Angler", 1); // {1}{U}
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
//
addCustomEffect_SpellCostModification(playerA, -1);
checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Hook-Haunt Drifter with Disturb", true);
@ -106,6 +111,9 @@ public class DisturbTest extends CardTestPlayerBase {
assertAllCommandsUsed();
}
/**
* Check that a cost modification effect that increases the cost of an spell cast properly effects Disturb.
*/
@Test
public void test_CostModification_CanNotPlay() {
// Disturb {1}{U}
@ -123,17 +131,18 @@ public class DisturbTest extends CardTestPlayerBase {
assertAllCommandsUsed();
}
/**
* Relevant rule:
* If you copy a permanent spell cast this way (perhaps with a card like Double Major), the copy becomes
* a token that's a copy of the card's back face, even though it isn't itself a double-faced card.
*/
@Test
public void test_CopySpell() {
// rules:
// If you copy a permanent spell cast this way (perhaps with a card like Double Major), the copy becomes
// a token that's a copy of the card's back face, even though it isn't itself a double-faced card.
// Disturb {1}{U}
// Hook-Haunt Drifter
addCard(Zone.GRAVEYARD, playerA, "Baithook Angler", 1); // {1}{U}
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
//
// Copy target creature spell you control, except it isn't legendary if the spell is legendary.
addCard(Zone.HAND, playerA, "Double Major", 1); // {G}{U}
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
@ -158,19 +167,20 @@ public class DisturbTest extends CardTestPlayerBase {
assertAllCommandsUsed();
}
/**
* Relevant ruling:
* The back face of each card with disturb has an ability that instructs its controller to exile
* if it would be put into a graveyard from anywhere. This includes going to the graveyard from the
* stack, so if the spell is countered after you cast it using the disturb ability, it will
* be put into exile.
*/
@Test
public void test_Counter() {
// rules:
// The back face of each card with disturb has an ability that instructs its controller to exile
// if it would be put into a graveyard from anywhere. This includes going to the graveyard from the
// stack, so if the spell is countered after you cast it using the disturb ability, it will
// be put into exile.
// Disturb {1}{U}
// Hook-Haunt Drifter
addCard(Zone.GRAVEYARD, playerA, "Baithook Angler", 1); // {1}{U}
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
//
// Counter target spell.
addCard(Zone.HAND, playerA, "Counterspell", 1); // {U}{U}
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
@ -191,4 +201,35 @@ public class DisturbTest extends CardTestPlayerBase {
execute();
assertAllCommandsUsed();
}
/**
* Reported bug: https://github.com/magefree/mage/issues/8572
* Casting an aura using its disturb ability causes it to be immediately exiled.
*/
@Test
public void testDisturbAura() {
String mirrorhallMimic = "Mirrorhall Mimic";
String ghastlyMimictry = "Ghastly Mimicry";
String lightningBolt = "Lightning Bolt";
addCard(Zone.GRAVEYARD, playerA, mirrorhallMimic);
addCard(Zone.BATTLEFIELD, playerA, "Alloy Myr");
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
addCard(Zone.HAND, playerA, lightningBolt);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast " + ghastlyMimictry + " with Disturb");
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, ghastlyMimictry, 1);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, lightningBolt, "Alloy Myr");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertExileCount(mirrorhallMimic, 1);
}
}