mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
test for #7912
This commit is contained in:
parent
fed7c2b288
commit
e10da89463
2 changed files with 86 additions and 19 deletions
|
@ -0,0 +1,48 @@
|
||||||
|
package org.mage.test.cards.abilities.enters;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
public class BronzehideLionTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
private final String lion = "Bronzehide Lion";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
When Bronzehide Lion dies, return it to the battlefield.
|
||||||
|
It's an Aura enchantment with enchant creature you control and
|
||||||
|
"{G}{W}: Enchanted creature gains indestructible until end of turn," and it loses all other abilities.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void returnAsAura(){
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, lion);
|
||||||
|
addCard(Zone.HAND, playerA, "Terror");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 10);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears");
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Terror", lion);
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
assertGraveyardCount(playerA, lion, 0);
|
||||||
|
assertIsAttachedTo(playerA, lion, "Grizzly Bears");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void stayInGraveyard(){
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, lion);
|
||||||
|
addCard(Zone.HAND, playerA, "Terror");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 10);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Terror", lion);
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
assertGraveyardCount(playerA, lion, 1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,6 +43,8 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API for test initialization and asserting the test results.
|
* API for test initialization and asserting the test results.
|
||||||
*
|
*
|
||||||
|
@ -84,8 +86,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// cards can be played/casted by activate ability command too
|
// cards can be played/casted by activate ability command too
|
||||||
Assert.assertTrue("musts contains activate ability part", ACTIVATE_PLAY.startsWith(ACTIVATE_ABILITY));
|
assertTrue("musts contains activate ability part", ACTIVATE_PLAY.startsWith(ACTIVATE_ABILITY));
|
||||||
Assert.assertTrue("musts contains activate ability part", ACTIVATE_CAST.startsWith(ACTIVATE_ABILITY));
|
assertTrue("musts contains activate ability part", ACTIVATE_CAST.startsWith(ACTIVATE_ABILITY));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add target player param to commands
|
// TODO: add target player param to commands
|
||||||
|
@ -289,7 +291,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
if (player instanceof TestPlayer) {
|
if (player instanceof TestPlayer) {
|
||||||
TestPlayer testPlayer = (TestPlayer) player;
|
TestPlayer testPlayer = (TestPlayer) player;
|
||||||
for (PlayerAction action : testPlayer.getActions()) {
|
for (PlayerAction action : testPlayer.getActions()) {
|
||||||
Assert.assertTrue("Wrong turn in action " + action.getTurnNum(), action.getTurnNum() >= 1);
|
assertTrue("Wrong turn in action " + action.getTurnNum(), action.getTurnNum() >= 1);
|
||||||
int curTurn = action.getTurnNum();
|
int curTurn = action.getTurnNum();
|
||||||
int curPhase = action.getStep().getIndex();
|
int curPhase = action.getStep().getIndex();
|
||||||
if ((curTurn > maxTurn) || (curTurn == maxTurn && curPhase > maxPhase)) {
|
if ((curTurn > maxTurn) || (curTurn == maxTurn && curPhase > maxPhase)) {
|
||||||
|
@ -704,7 +706,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlane(Player player, Planes plane) {
|
public void addPlane(Player player, Planes plane) {
|
||||||
Assert.assertTrue("Can't put plane to game: " + plane.getClassName(), SystemUtil.putPlaneToGame(currentGame, player, plane.getClassName()));
|
assertTrue("Can't put plane to game: " + plane.getClassName(), SystemUtil.putPlaneToGame(currentGame, player, plane.getClassName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -761,7 +763,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setStopAt(int turn, PhaseStep step) {
|
public void setStopAt(int turn, PhaseStep step) {
|
||||||
Assert.assertTrue("Wrong turn " + turn, turn >= 1);
|
assertTrue("Wrong turn " + turn, turn >= 1);
|
||||||
stopOnTurn = turn;
|
stopOnTurn = turn;
|
||||||
stopAtStep = step;
|
stopAtStep = step;
|
||||||
}
|
}
|
||||||
|
@ -867,11 +869,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertTrue("There is no such permanent under player's control, player=" + player.getName()
|
assertTrue("There is no such permanent under player's control, player=" + player.getName()
|
||||||
+ ", cardName=" + cardName, count > 0);
|
+ ", cardName=" + cardName, count > 0);
|
||||||
|
|
||||||
if (scope == Filter.ComparisonScope.Any) {
|
if (scope == Filter.ComparisonScope.Any) {
|
||||||
Assert.assertTrue("There is no such creature under player's control with specified p/t of " + power + '/' + toughness + ", player=" + player.getName()
|
assertTrue("There is no such creature under player's control with specified p/t of " + power + '/' + toughness + ", player=" + player.getName()
|
||||||
+ ", cardName=" + cardName + " (found similar: " + found + ", one of them: power=" + foundPower + " toughness=" + foundToughness + ')', fit > 0);
|
+ ", cardName=" + cardName + " (found similar: " + found + ", one of them: power=" + foundPower + " toughness=" + foundToughness + ')', fit > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -908,11 +910,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
Assert.assertNotNull("There is no such permanent under player's control, player=" + player.getName()
|
Assert.assertNotNull("There is no such permanent under player's control, player=" + player.getName()
|
||||||
+ ", cardName=" + cardName, found);
|
+ ", cardName=" + cardName, found);
|
||||||
|
|
||||||
Assert.assertTrue("There is more than one such permanent under player's control, player=" + player.getName()
|
assertTrue("There is more than one such permanent under player's control, player=" + player.getName()
|
||||||
+ ", cardName=" + cardName, count == 1);
|
+ ", cardName=" + cardName, count == 1);
|
||||||
|
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
Assert.assertTrue("No such ability=" + ability.toString() + ", player=" + player.getName()
|
assertTrue("No such ability=" + ability.toString() + ", player=" + player.getName()
|
||||||
+ ", cardName" + cardName, found.getAbilities().contains(ability));
|
+ ", cardName" + cardName, found.getAbilities().contains(ability));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -944,11 +946,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
Assert.assertNotNull("There is no such permanent under player's control, player=" + player.getName()
|
Assert.assertNotNull("There is no such permanent under player's control, player=" + player.getName()
|
||||||
+ ", cardName=" + cardName, found);
|
+ ", cardName=" + cardName, found);
|
||||||
|
|
||||||
Assert.assertTrue("There is another number (" + foundCount + ") as defined (" + count + ") of such permanents under player's control, player=" + player.getName()
|
assertTrue("There is another number (" + foundCount + ") as defined (" + count + ") of such permanents under player's control, player=" + player.getName()
|
||||||
+ ", cardName=" + cardName, count == foundCount);
|
+ ", cardName=" + cardName, count == foundCount);
|
||||||
|
|
||||||
if (mustHave) {
|
if (mustHave) {
|
||||||
Assert.assertTrue("No such ability=" + ability.toString() + ", player=" + player.getName()
|
assertTrue("No such ability=" + ability.toString() + ", player=" + player.getName()
|
||||||
+ ", cardName" + cardName, found.getAbilities(currentGame).containsRule(ability));
|
+ ", cardName" + cardName, found.getAbilities(currentGame).containsRule(ability));
|
||||||
} else {
|
} else {
|
||||||
Assert.assertFalse("Card shouldn't have such ability=" + ability.toString() + ", player=" + player.getName()
|
Assert.assertFalse("Card shouldn't have such ability=" + ability.toString() + ", player=" + player.getName()
|
||||||
|
@ -1118,7 +1120,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
|
|
||||||
Assert.assertNotNull("There is no such permanent on the battlefield, cardName=" + cardName, found);
|
Assert.assertNotNull("There is no such permanent on the battlefield, cardName=" + cardName, found);
|
||||||
|
|
||||||
Assert.assertTrue("(Battlefield) card type " + (mustHave ? "not " : "")
|
assertTrue("(Battlefield) card type " + (mustHave ? "not " : "")
|
||||||
+ "found (" + cardName + ':' + type + ')', (found.getCardType(currentGame).contains(type) == mustHave));
|
+ "found (" + cardName + ':' + type + ')', (found.getCardType(currentGame).contains(type) == mustHave));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1133,9 +1135,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
public void assertType(String cardName, CardType type, SubType subType) throws AssertionError {
|
public void assertType(String cardName, CardType type, SubType subType) throws AssertionError {
|
||||||
//Assert.assertNotEquals("", cardName);
|
//Assert.assertNotEquals("", cardName);
|
||||||
Permanent found = getPermanent(cardName);
|
Permanent found = getPermanent(cardName);
|
||||||
Assert.assertTrue("(Battlefield) card type not found (" + cardName + ':' + type + ')', found.getCardType(currentGame).contains(type));
|
assertTrue("(Battlefield) card type not found (" + cardName + ':' + type + ')', found.getCardType(currentGame).contains(type));
|
||||||
if (subType != null) {
|
if (subType != null) {
|
||||||
Assert.assertTrue("(Battlefield) card sub-type not equal (" + cardName + ':' + subType.getDescription() + ')', found.hasSubtype(subType, currentGame));
|
assertTrue("(Battlefield) card sub-type not equal (" + cardName + ':' + subType.getDescription() + ')', found.hasSubtype(subType, currentGame));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1175,7 +1177,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
//Assert.assertNotEquals("", cardName);
|
//Assert.assertNotEquals("", cardName);
|
||||||
Permanent found = getPermanent(cardName);
|
Permanent found = getPermanent(cardName);
|
||||||
if (subType != null) {
|
if (subType != null) {
|
||||||
Assert.assertTrue("(Battlefield) card sub-type equal (" + cardName + ':' + subType.getDescription() + ')', found.hasSubtype(subType, currentGame));
|
assertTrue("(Battlefield) card sub-type equal (" + cardName + ':' + subType.getDescription() + ')', found.hasSubtype(subType, currentGame));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1375,7 +1377,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertTrue("There is no card named " + cardName + " found in exile, with subtype " + subType, found);
|
assertTrue("There is no card named " + cardName + " found in exile, with subtype " + subType, found);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1536,6 +1538,23 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
Assert.assertEquals(isRevealed, player.isTopCardRevealed());
|
Assert.assertEquals(isRevealed, player.isTopCardRevealed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void assertIsAttachedTo(TestPlayer thePlayer, String theAttachment, String thePermanent) {
|
||||||
|
|
||||||
|
List<Permanent> permanents = currentGame.getBattlefield().getAllActivePermanents().stream()
|
||||||
|
.filter(permanent -> permanent.isControlledBy(thePlayer.getId()))
|
||||||
|
.filter(permanent -> permanent.getName().equals(thePermanent))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
assertTrue(theAttachment + " was not attached to " + thePermanent,
|
||||||
|
permanents.stream()
|
||||||
|
.anyMatch(permanent -> permanent.getAttachments()
|
||||||
|
.stream()
|
||||||
|
.map(id -> currentGame.getCard(id))
|
||||||
|
.map(MageObject::getName)
|
||||||
|
.collect(Collectors.toList()).contains(theAttachment)));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public Permanent getPermanent(String cardName, UUID controller) {
|
public Permanent getPermanent(String cardName, UUID controller) {
|
||||||
assertAliaseSupportInActivateCommand(cardName, false);
|
assertAliaseSupportInActivateCommand(cardName, false);
|
||||||
Permanent found = null;
|
Permanent found = null;
|
||||||
|
@ -2039,7 +2058,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTargetAmount(TestPlayer player, String target) {
|
public void addTargetAmount(TestPlayer player, String target) {
|
||||||
Assert.assertTrue("Only skip command allows here", target.equals(TestPlayer.TARGET_SKIP));
|
assertTrue("Only skip command allows here", target.equals(TestPlayer.TARGET_SKIP));
|
||||||
addTargetAmount(player, target, 0);
|
addTargetAmount(player, target, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2111,7 +2130,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
|
|
||||||
public void assertWonTheGame(Player player) {
|
public void assertWonTheGame(Player player) {
|
||||||
|
|
||||||
Assert.assertTrue(player.getName() + " has not won the game.", player.hasWon());
|
assertTrue(player.getName() + " has not won the game.", player.hasWon());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertHasNotWonTheGame(Player player) {
|
public void assertHasNotWonTheGame(Player player) {
|
||||||
|
@ -2121,7 +2140,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
|
|
||||||
public void assertLostTheGame(Player player) {
|
public void assertLostTheGame(Player player) {
|
||||||
|
|
||||||
Assert.assertTrue(player.getName() + " has not lost the game.", player.hasLost());
|
assertTrue(player.getName() + " has not lost the game.", player.hasLost());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertHasNotLostTheGame(Player player) {
|
public void assertHasNotLostTheGame(Player player) {
|
||||||
|
|
Loading…
Reference in a new issue