Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
theelk801 committed Sep 13, 2024
1 parent 1f456f3 commit a27aa82
Showing 1 changed file with 166 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.mage.test.cards.abilities.keywords;

import mage.abilities.keyword.ImpendingAbility;
import mage.constants.CardType;
import mage.constants.PhaseStep;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.permanent.Permanent;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;

Expand All @@ -15,6 +18,14 @@ public class ImpendingTest extends CardTestPlayerBase {

private static final String hauntwoods = "Overlord of the Hauntwoods";

public void assertHasImpending(String name, boolean hasAbility) {
Permanent permanent = getPermanent(hauntwoods);
Assert.assertEquals(
"Should" + (hasAbility ? "" : "n't") + " have Impending ability",
hasAbility, permanent.getAbilities(currentGame).containsClass(ImpendingAbility.class)
);
}

@Test
public void testCastRegular() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
Expand All @@ -34,6 +45,7 @@ public void testCastRegular() {
assertSubtype(hauntwoods, SubType.HORROR);
assertCounterCount(playerA, hauntwoods, CounterType.TIME, 0);
assertPowerToughness(playerA, hauntwoods, 6, 5);
assertHasImpending(hauntwoods, true);

assertPermanentCount(playerA, "Everywhere", 1);
}
Expand All @@ -54,6 +66,160 @@ public void testCastImpending() {
assertType(hauntwoods, CardType.ENCHANTMENT, true);
assertType(hauntwoods, CardType.CREATURE, false);
assertCounterCount(playerA, hauntwoods, CounterType.TIME, 4);
assertHasImpending(hauntwoods, true);

assertPermanentCount(playerA, "Everywhere", 1);
}

@Test
public void testImpendingRemoveCounter() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.HAND, playerA, hauntwoods);

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, hauntwoods);
setChoice(playerA, "Cast with Impending");

setStrictChooseMode(true);
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();

assertPermanentCount(playerA, hauntwoods, 1);
assertType(hauntwoods, CardType.ENCHANTMENT, true);
assertType(hauntwoods, CardType.CREATURE, false);
assertCounterCount(playerA, hauntwoods, CounterType.TIME, 4 - 1);
assertHasImpending(hauntwoods, true);

assertPermanentCount(playerA, "Everywhere", 1);
}

@Test
public void testCastImpendingRemoveAllCounters() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.HAND, playerA, hauntwoods);

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, hauntwoods);
setChoice(playerA, "Cast with Impending");

setStrictChooseMode(true);
setStopAt(8, PhaseStep.POSTCOMBAT_MAIN);
execute();

assertPermanentCount(playerA, hauntwoods, 1);
assertType(hauntwoods, CardType.ENCHANTMENT, true);
assertType(hauntwoods, CardType.CREATURE, true);
assertSubtype(hauntwoods, SubType.AVATAR);
assertSubtype(hauntwoods, SubType.HORROR);
assertCounterCount(playerA, hauntwoods, CounterType.TIME, 0);
assertPowerToughness(playerA, hauntwoods, 6, 5);
assertHasImpending(hauntwoods, false);

assertPermanentCount(playerA, "Everywhere", 1);
}

private static final String hexmage = "Vampire Hexmage";

@Test
public void testCastImpendingHexmage() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.BATTLEFIELD, playerA, hexmage);
addCard(Zone.HAND, playerA, hauntwoods);

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, hauntwoods);
setChoice(playerA, "Cast with Impending");

activateAbility(1, PhaseStep.BEGIN_COMBAT, playerA, "Sacrifice", hauntwoods);

setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();

assertPermanentCount(playerA, hauntwoods, 1);
assertType(hauntwoods, CardType.ENCHANTMENT, true);
assertType(hauntwoods, CardType.CREATURE, true);
assertSubtype(hauntwoods, SubType.AVATAR);
assertSubtype(hauntwoods, SubType.HORROR);
assertCounterCount(playerA, hauntwoods, CounterType.TIME, 0);
assertPowerToughness(playerA, hauntwoods, 6, 5);
assertHasImpending(hauntwoods, true);

assertPermanentCount(playerA, "Everywhere", 1);
}

@Test
public void testCastImpendingHexmageNextTurn() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.BATTLEFIELD, playerA, hexmage);
addCard(Zone.HAND, playerA, hauntwoods);

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, hauntwoods);
setChoice(playerA, "Cast with Impending");

activateAbility(1, PhaseStep.BEGIN_COMBAT, playerA, "Sacrifice", hauntwoods);

setStrictChooseMode(true);
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();

assertPermanentCount(playerA, hauntwoods, 1);
assertType(hauntwoods, CardType.ENCHANTMENT, true);
assertType(hauntwoods, CardType.CREATURE, true);
assertSubtype(hauntwoods, SubType.AVATAR);
assertSubtype(hauntwoods, SubType.HORROR);
assertCounterCount(playerA, hauntwoods, CounterType.TIME, 0);
assertPowerToughness(playerA, hauntwoods, 6, 5);
assertHasImpending(hauntwoods, false);

assertPermanentCount(playerA, "Everywhere", 1);
}

private static final String solemnity = "Solemnity";

@Test
public void testCastImpendingSolemnity() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.BATTLEFIELD, playerA, solemnity);
addCard(Zone.HAND, playerA, hauntwoods);

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, hauntwoods);
setChoice(playerA, "Cast with Impending");

setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();

assertPermanentCount(playerA, hauntwoods, 1);
assertType(hauntwoods, CardType.ENCHANTMENT, true);
assertType(hauntwoods, CardType.CREATURE, true);
assertSubtype(hauntwoods, SubType.AVATAR);
assertSubtype(hauntwoods, SubType.HORROR);
assertCounterCount(playerA, hauntwoods, CounterType.TIME, 0);
assertPowerToughness(playerA, hauntwoods, 6, 5);
assertHasImpending(hauntwoods, true);

assertPermanentCount(playerA, "Everywhere", 1);
}

@Test
public void testCastImpendingSolemnityNextTurn() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.BATTLEFIELD, playerA, solemnity);
addCard(Zone.HAND, playerA, hauntwoods);

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, hauntwoods);
setChoice(playerA, "Cast with Impending");

setStrictChooseMode(true);
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();

assertPermanentCount(playerA, hauntwoods, 1);
assertType(hauntwoods, CardType.ENCHANTMENT, true);
assertType(hauntwoods, CardType.CREATURE, true);
assertSubtype(hauntwoods, SubType.AVATAR);
assertSubtype(hauntwoods, SubType.HORROR);
assertCounterCount(playerA, hauntwoods, CounterType.TIME, 0);
assertPowerToughness(playerA, hauntwoods, 6, 5);
assertHasImpending(hauntwoods, false);

assertPermanentCount(playerA, "Everywhere", 1);
}
Expand Down

0 comments on commit a27aa82

Please sign in to comment.