new m21 tests, tests failing for Conspicuous Snoop and Chandras Magmutt. New testmethods: assertTopCardRevealed and assertAbilityCount that can check on a ability class

This commit is contained in:
Ingmar Goudt 2020-07-28 21:22:26 +02:00
parent 307d4a6283
commit 51af4e7e1d
14 changed files with 548 additions and 0 deletions

View file

@ -0,0 +1,32 @@
package org.mage.test.cards.single.m21;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class CagedZombieTest extends CardTestPlayerBase {
@Test
public void loseLife(){
// {1}{B}, {T}: Each opponent loses 2 life. Activate this ability only if a creature died this turn.
addCard(Zone.BATTLEFIELD, playerA, "Caged Zombie");
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears");
// Destroy target nonartifact, nonblack creature. It can't be regenerated.
addCard(Zone.HAND, playerA, "Terror");
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Terror", "Grizzly Bears");
waitStackResolved(3, PhaseStep.PRECOMBAT_MAIN);
activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{B}");
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertLife(playerA, 20);
assertLife(playerB, 18);
}
}

View file

@ -0,0 +1,30 @@
package org.mage.test.cards.single.m21;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class CancelTest extends CardTestPlayerBase {
@Test
public void counterTargetSpell(){
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
// {1}{U}{U} Counter target spell
addCard(Zone.HAND, playerA, "Cancel");
addCard(Zone.BATTLEFIELD, playerB, "Forest", 2);
addCard(Zone.HAND, playerB, "Grizzly Bears");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Grizzly Bears");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, "Cancel", "Grizzly Bears");
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerB, "Grizzly Bears", 1);
assertGraveyardCount(playerA, "Cancel", 1);
}
}

View file

@ -0,0 +1,49 @@
package org.mage.test.cards.single.m21;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.combat.MustBeBlockedByAtLeastOneSourceEffect;
import mage.constants.Duration;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class CanopyStalkerTest extends CardTestPlayerBase {
@Test
public void testMustBeBlocked(){
// 4/2
// Canopy Stalker must be blocked if able.
// When Canopy Stalker dies, you gain 1 life for each creature that died this turn.
addCard(Zone.BATTLEFIELD, playerA, "Canopy Stalker");
// 1/1 Flying
addCard(Zone.BATTLEFIELD, playerB, "Scryb Sprites");
attack(3, playerA, "Canopy Stalker");
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerB, "Scryb Sprites", 1);
}
@Test
public void testDiesEvent(){
// 4/2
// Canopy Stalker must be blocked if able.
// When Canopy Stalker dies, you gain 1 life for each creature that died this turn.
addCard(Zone.BATTLEFIELD, playerA, "Canopy Stalker");
// 2/2 Vanilla
addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears");
attack(3, playerA, "Canopy Stalker");
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertLife(playerA, 22);
}
}

View file

@ -0,0 +1,29 @@
package org.mage.test.cards.single.m21;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class CaptureSphereTest extends CardTestPlayerBase {
@Test
public void testDontUntap(){
// Flash
// Enchant creature
// When Capture Sphere enters the battlefield, tap enchanted creature.
// Enchanted creature doesn't untap during its controller's untap step.
addCard(Zone.HAND, playerA, "Capture Sphere");
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA,"Capture Sphere", "Grizzly Bears");
setStrictChooseMode(true);
setStopAt(4, PhaseStep.PRECOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertTapped("Grizzly Bears", true);
}
}

View file

@ -0,0 +1,43 @@
package org.mage.test.cards.single.m21;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class CarrionGrubTest extends CardTestPlayerBase {
@Test
public void etbTrigger() {
// Carrion Grub gets +X/+0, where X is the greatest power among creature cards in your graveyard.
// When Carrion Grub enters the battlefield, mill four cards.
addCard(Zone.HAND, playerA, "Carrion Grub");
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
addCard(Zone.LIBRARY, playerA, "Forest", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Carrion Grub");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerA , 4);
}
@Test
public void boostPower() {
// Carrion Grub gets +X/+0, where X is the greatest power among creature cards in your graveyard.
// When Carrion Grub enters the battlefield, mill four cards.
addCard(Zone.BATTLEFIELD, playerA, "Carrion Grub");
addCard(Zone.GRAVEYARD, playerA, "Serra Angel");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertPowerToughness(playerA, "Carrion Grub", 4, 5);
}
}

View file

@ -0,0 +1,25 @@
package org.mage.test.cards.single.m21;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class CelestialEnforcerTest extends CardTestPlayerBase {
@Test
public void controlFlyingCreature(){
// {1}{W}, {T}: Tap target creature. Activate this ability only if you control a creature with flying.
addCard(Zone.BATTLEFIELD, playerA, "Celestial Enforcer");
addCard(Zone.BATTLEFIELD, playerA, "Serra Angel");
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears");
activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W}", "Grizzly Bears");
setStrictChooseMode(true);
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertTapped("Grizzly Bears", true);
}
}

View file

@ -0,0 +1,32 @@
package org.mage.test.cards.single.m21;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class ChandrasIncineratorTest extends CardTestPlayerBase {
@Test
public void testCostReduction(){
// {5}{R}
// This spell costs {X} less to cast,
// where X is the total amount of noncombat damage dealt to your opponents this turn.
addCard(Zone.HAND, playerA, "Chandra's Incinerator");
// deal 3 damage to any target
addCard(Zone.HAND, playerA, "Lightning Bolt");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Chandra's Incinerator");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
// {R} lightning bolt + {2}{R} Chandra's Incinerator
assertTappedCount("Mountain", true, 4);
}
}

View file

@ -0,0 +1,38 @@
package org.mage.test.cards.single.m21;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class ChandrasMagmuttTest extends CardTestPlayerBase {
@Test
public void pingPlayer(){
addCard(Zone.BATTLEFIELD, playerA, "Chandra's Magmutt");
activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Chandra's Magmutt", playerB);
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertLife(playerB, 19);
}
@Test
public void pingPlanesWalker(){
addCard(Zone.BATTLEFIELD, playerA, "Chandra's Magmutt");
addCard(Zone.BATTLEFIELD, playerB, "Basri Ket");
activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Chandra's Magmutt", "Basri Ket");
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertCounterCount("Basri Ket", CounterType.LOYALTY, 2);
}
}

View file

@ -0,0 +1,29 @@
package org.mage.test.cards.single.m21;
import mage.abilities.keyword.DoubleStrikeAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class ChandrasPyrelingTest extends CardTestPlayerBase {
@Test
public void boostAndGetDoubleStrike(){
// Whenever a source you control deals noncombat damage to an opponent,
// Chandra's Pyreling gets +1/+0 and gains double strike until end of turn.
addCard(Zone.BATTLEFIELD, playerA, "Chandra's Pyreling");
addCard(Zone.HAND, playerA, "Shock");
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Shock", playerB);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertAbility(playerA, "Chandra's Pyreling", DoubleStrikeAbility.getInstance(), true);
assertPowerToughness(playerA, "Chandra's Pyreling", 2, 3);
}
}

View file

@ -0,0 +1,44 @@
package org.mage.test.cards.single.m21;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class ChromaticOrreryTest extends CardTestPlayerBase {
@Test
public void testSpendManyAsThoughAnyColor(){
// You may spend mana as though it were mana of any color.
addCard(Zone.BATTLEFIELD, playerA, "Chromatic Orrery");
// {W}{U}{B}{R}{G}
addCard(Zone.HAND, playerA, "Sliver Overlord");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sliver Overlord");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Sliver Overlord", 1);
}
@Test
public void testDrawCards(){
// {5}, {T}: Draw a card for each color among permanents you control.
addCard(Zone.BATTLEFIELD, playerA, "Chromatic Orrery");
// {W}{U}{B}{R}{G}
addCard(Zone.BATTLEFIELD, playerA, "Sliver Overlord");
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
addCard(Zone.LIBRARY, playerA, "Swamp",5);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{5}");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertHandCount(playerA, 5);
}
}

View file

@ -0,0 +1,65 @@
package org.mage.test.cards.single.m21;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class ChromeReplicatorTest extends CardTestPlayerBase {
@Test
public void controlTwoSameNonTokens(){
// When Chrome Replicator enters the battlefield,
// if you control two or more nonland, nontoken permanents with the same name as one another,
// create a 4/4 colorless Construct artifact creature token.
addCard(Zone.HAND, playerA, "Chrome Replicator");
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 5);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Chrome Replicator");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Construct", 1);
}
@Test
public void controlTwoSameLands(){
// When Chrome Replicator enters the battlefield,
// if you control two or more nonland, nontoken permanents with the same name as one another,
// create a 4/4 colorless Construct artifact creature token.
addCard(Zone.HAND, playerA, "Chrome Replicator");
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 5);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Chrome Replicator");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Construct", 0);
}
@Test
public void controlTwoSameTokens(){
// When Chrome Replicator enters the battlefield,
// if you control two or more nonland, nontoken permanents with the same name as one another,
// create a 4/4 colorless Construct artifact creature token.
addCard(Zone.HAND, playerA, "Chrome Replicator");
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 5);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
// create 2 soldier tokens
addCard(Zone.HAND, playerA, "Raise the Alarm");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Raise the Alarm");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Chrome Replicator");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Construct", 0);
}
}

View file

@ -0,0 +1,53 @@
package org.mage.test.cards.single.m21;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class ConclaveMentorTest extends CardTestPlayerBase {
@Test
public void testIncreaseCounters() {
// If one or more +1/+1 counters would be put on a creature you control,
// that many plus one +1/+1 counters are put on that creature instead.
addCard(Zone.BATTLEFIELD, playerA, "Conclave Mentor");
// When Bond Beetle enters the battlefield, put a +1/+1 counter on target creature.
addCard(Zone.HAND, playerA, "Bond Beetle");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Bond Beetle");
addTarget(playerA, "Conclave Mentor");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertCounterCount(playerA, "Conclave Mentor", CounterType.P1P1, 2);
}
@Test
public void diesTrigger() {
// When Conclave Mentor dies, you gain life equal to its power.
addCard(Zone.BATTLEFIELD, playerA, "Conclave Mentor");
addCard(Zone.HAND, playerA, "Terror");
addCard(Zone.HAND, playerA, "Giant Growth");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Giant Growth","Conclave Mentor");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Terror","Conclave Mentor");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertLife(playerA, 25);
}
}

View file

@ -0,0 +1,58 @@
package org.mage.test.cards.single.m21;
import mage.abilities.ActivatedAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class ConspicuousSnoopTest extends CardTestPlayerBase {
@Test
public void testTopCardLibraryRevealed(){
// Play with the top card of your library revealed.
addCard(Zone.BATTLEFIELD, playerA, "Conspicuous Snoop");
addCard(Zone.LIBRARY, playerA, "Swamp");
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertTopCardRevealed(playerA, true);
}
@Test
public void castGoblinSpellsFromLibrary(){
// You may cast Goblin spells from the top of your library.
addCard(Zone.BATTLEFIELD, playerA, "Conspicuous Snoop");
addCard(Zone.LIBRARY, playerA, "Goblin Lackey");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Goblin Lackey");
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Goblin Lackey", 1);
}
@Test
public void hasActivatedAbilities(){
// As long as the top card of your library is a Goblin card,
// Conspicuous Snoop has all activated abilities of that card.
addCard(Zone.BATTLEFIELD, playerA, "Conspicuous Snoop");
addCard(Zone.LIBRARY, playerA, "Goblin Balloon Brigade");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
assertAbilityCount(playerA, "Conspicuous Snoop", ActivatedAbility.class,5);
}
}

View file

@ -906,6 +906,23 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
}
public void assertAbilityCount(Player player, String cardName, Class<? extends Ability> ability, int amount) {
int foundCount = 0;
Permanent found = null;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
if (isObjectHaveTargetNameOrAlias(player, permanent, cardName)) {
found = permanent;
foundCount++;
}
}
Assert.assertNotNull("There is no such permanent under player's control, player=" + player.getName()
+ ", cardName=" + cardName, found);
Assert.assertEquals(amount, found.getAbilities(currentGame).stream()
.filter(a -> a.getClass().isAssignableFrom(ability)).collect(Collectors.toList()).size());
}
/**
* Assert permanent count under player's control.
*
@ -1434,6 +1451,10 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
Assert.assertEquals("message", currentGame.getState().getActivePlayerId(), player.getId());
}
public void assertTopCardRevealed(TestPlayer player, boolean isRevealed) {
Assert.assertEquals(isRevealed, player.isTopCardRevealed());
}
public Permanent getPermanent(String cardName, UUID controller) {
assertAliaseSupportInActivateCommand(cardName, false);
Permanent found = null;