tests: removed and restricted empty commands for choices and targets, improved empty name usages in tests (use EmptyNames.xxx.getTestCommand and EmptyNames.xxx.getObjectName for face down objects)

This commit is contained in:
Oleg Agafonov 2024-10-16 15:19:46 +04:00
parent 06392fecef
commit a16215caed
42 changed files with 391 additions and 264 deletions

View file

@ -77,7 +77,7 @@ public class BlitzTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, decoy + withBlitz);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Double Major",decoy);
setChoice(playerA, ""); //stack triggers
setChoice(playerA, "At the beginning of the next end step"); // x2 triggers
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);

View file

@ -67,7 +67,7 @@ public class DisguiseTest extends CardTestPlayerBase {
});
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPermanentCount("after face down", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Dog Walker", 0);
checkPermanentCount("after face down", 1, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
checkPermanentCount("after face down", 1, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
runCode("after face down", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
// server side
Permanent permanent = currentGame.getBattlefield().getAllPermanents()
@ -76,7 +76,7 @@ public class DisguiseTest extends CardTestPlayerBase {
.findFirst()
.orElse(null);
Assert.assertNotNull("server side: can't find disguised permanent", permanent);
Assert.assertEquals("server side: wrong name", EmptyNames.FACE_DOWN_CREATURE.toString(), permanent.getName());
Assert.assertEquals("server side: wrong name", EmptyNames.FACE_DOWN_CREATURE.getObjectName(), permanent.getName());
Assert.assertEquals("server side: wrong color", "", permanent.getColor(currentGame).toString());
Assert.assertEquals("server side: wrong power", "2", permanent.getPower().toString());
Assert.assertEquals("server side: wrong toughness", "2", permanent.getToughness().toString());
@ -145,7 +145,7 @@ public class DisguiseTest extends CardTestPlayerBase {
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{R/W}{R/W}: Turn");
waitStackResolved(1, PhaseStep.POSTCOMBAT_MAIN, playerA);
checkPermanentCount("after face up", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Dog Walker", 1);
checkPermanentCount("after face up", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
checkPermanentCount("after face up", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
checkPermanentCount("after face up", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Dog Token", 2);
runCode("after face up", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, (info, player, game) -> {
Permanent permanent = currentGame.getBattlefield().getAllPermanents()
@ -193,7 +193,7 @@ public class DisguiseTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
assertLife(playerA, 20);
}

View file

@ -88,8 +88,7 @@ public class EchoTest extends CardTestPlayerBase {
setChoice(playerA, true);
setChoice(playerA, "Deranged Hermit");
setChoice(playerA, ""); //stack triggers
setChoice(playerA, "");
setChoice(playerA, "Echo {3}{G}{G}", 2); // x3 triggers from Deranged Hermit
setChoice(playerA, true); //Pay echo costs
setChoice(playerA, true);

View file

@ -37,7 +37,7 @@ public class ManifestTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@Test
@ -55,7 +55,7 @@ public class ManifestTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@Test
@ -75,8 +75,8 @@ public class ManifestTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@Test
@ -90,32 +90,32 @@ public class ManifestTest extends CardTestPlayerBase {
});
// turn 1
checkPermanentCount("turn 1.A - no face down", 1, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
checkPermanentCount("turn 1.B - no face down", 1, PhaseStep.PRECOMBAT_MAIN, playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
checkPermanentCount("turn 1.A - no face down", 1, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
checkPermanentCount("turn 1.B - no face down", 1, PhaseStep.PRECOMBAT_MAIN, playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
// turn 2
checkPermanentCount("turn 2.A - +1 face down", 2, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
checkPermanentCount("turn 2.B - no face down", 2, PhaseStep.PRECOMBAT_MAIN, playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
checkPermanentCount("turn 2.A - +1 face down", 2, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
checkPermanentCount("turn 2.B - no face down", 2, PhaseStep.PRECOMBAT_MAIN, playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
// turn 3
checkPermanentCount("turn 3.A - +1 face down", 3, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
checkPermanentCount("turn 3.B - no face down", 3, PhaseStep.PRECOMBAT_MAIN, playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
checkPermanentCount("turn 3.A - +1 face down", 3, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
checkPermanentCount("turn 3.B - no face down", 3, PhaseStep.PRECOMBAT_MAIN, playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
// turn 4
checkPermanentCount("turn 4.A - +2 face down", 4, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2);
checkPermanentCount("turn 4.B - no face down", 4, PhaseStep.PRECOMBAT_MAIN, playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
checkPermanentCount("turn 4.A - +2 face down", 4, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2);
checkPermanentCount("turn 4.B - no face down", 4, PhaseStep.PRECOMBAT_MAIN, playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
// turn 5
checkPermanentCount("turn 5.A - +2 face down", 5, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2);
checkPermanentCount("turn 5.B - no face down", 5, PhaseStep.PRECOMBAT_MAIN, playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
checkPermanentCount("turn 5.A - +2 face down", 5, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2);
checkPermanentCount("turn 5.B - no face down", 5, PhaseStep.PRECOMBAT_MAIN, playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
setStrictChooseMode(true);
setStopAt(5, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
Assert.assertEquals("manifested cards must be taken from opponent's library", 2, playerA.getLibrary().size() - playerB.getLibrary().size());
}
@ -137,12 +137,12 @@ public class ManifestTest extends CardTestPlayerBase {
// manifest
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Soul Summons");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPermanentCount("need face down", 1, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
checkPermanentCount("need face down", 1, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
// blink
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cloudshift", EmptyNames.FACE_DOWN_CREATURE.toString());
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cloudshift", EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPermanentCount("need no face down", 1, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
checkPermanentCount("need no face down", 1, PhaseStep.PRECOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
runCode("after blink", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
if (cardAfterBlink == null) {
@ -239,10 +239,10 @@ public class ManifestTest extends CardTestPlayerBase {
assertLife(playerA, 20);
assertLife(playerB, 20);
// a facedown creature is on the battlefield
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
// not tapped
assertTapped(EmptyNames.FACE_DOWN_CREATURE.toString(), false);
assertTapped(EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), false);
}
/**
@ -271,8 +271,8 @@ public class ManifestTest extends CardTestPlayerBase {
assertLife(playerA, 20);
assertLife(playerB, 20);
// a facedown creature is on the battlefield
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
// PlayerB's Silvercoat Lion should not have get -1/-1/
assertPermanentCount(playerB, "Silvercoat Lion", 1);
assertPowerToughness(playerB, "Silvercoat Lion", 2, 2);
@ -308,8 +308,8 @@ public class ManifestTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Reality Shift", 1);
assertExileCount("Silvercoat Lion", 1);
// a facedown creature is on the battlefield
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
// PlayerA's Pillarfield Ox should not have get -1/-1/
assertPermanentCount(playerB, "Pillarfield Ox", 1);
assertPowerToughness(playerB, "Pillarfield Ox", 2, 4);
@ -346,8 +346,8 @@ public class ManifestTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Reality Shift", 1);
assertExileCount("Silvercoat Lion", 1);
// a facedown creature is on the battlefield
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
}
@ -382,8 +382,8 @@ public class ManifestTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Reality Shift", 1);
assertExileCount("Silvercoat Lion", 1);
// a facedown creature is on the battlefield
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
assertPowerToughness(playerA, "Foundry Street Denizen", 1, 1);
}
@ -413,7 +413,7 @@ public class ManifestTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Reality Shift", "Silvercoat Lion");
// showBattlefield("A battle", 1, PhaseStep.POSTCOMBAT_MAIN, playerA);
// showBattlefield("B battle", 1, PhaseStep.POSTCOMBAT_MAIN, playerB);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Silence the Believers", EmptyNames.FACE_DOWN_CREATURE.toString());
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Silence the Believers", EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
setStopAt(1, PhaseStep.END_TURN);
execute();
@ -425,7 +425,7 @@ public class ManifestTest extends CardTestPlayerBase {
assertExileCount("Silvercoat Lion", 1);
assertExileCount("Gore Swine", 1);
// no facedown creature is on the battlefield
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
for (Card card : currentGame.getExile().getAllCards(currentGame)) {
if (card.getName().equals("Gore Swine")) {
@ -464,7 +464,7 @@ public class ManifestTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
// a facedown creature is on the battlefield
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@ -504,7 +504,7 @@ public class ManifestTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
assertPermanentCount(playerB, "Aerie Bowmasters", 1);
assertPowerToughness(playerB, "Aerie Bowmasters", 4, 5); // 3/4 and the +1/+1 counter from Megamorph
Permanent aerie = getPermanent("Aerie Bowmasters", playerB);
@ -542,7 +542,7 @@ public class ManifestTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
assertPermanentCount(playerB, "Aerie Bowmasters", 1);
assertPowerToughness(playerB, "Aerie Bowmasters", 3, 4); // 3/4 without counter (megamorph not used)
Permanent aerie = getPermanent("Aerie Bowmasters", playerB);
@ -582,7 +582,7 @@ public class ManifestTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@ -619,7 +619,7 @@ public class ManifestTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Whisperwood Elemental", 1);
assertGraveyardCount(playerB, "Silvercoat Lion", 2);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 2);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2);
}
@ -653,7 +653,7 @@ public class ManifestTest extends CardTestPlayerBase {
setChoice(playerB, "Silvercoat Lion");
activateAbility(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Sacrifice a creature");
setChoice(playerB, EmptyNames.FACE_DOWN_CREATURE.toString());
setChoice(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
setStrictChooseMode(true);
setStopAt(2, PhaseStep.END_TURN);
@ -704,7 +704,7 @@ public class ManifestTest extends CardTestPlayerBase {
waitStackResolved(2, PhaseStep.PRECOMBAT_MAIN, playerB);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Cloudshift", EmptyNames.FACE_DOWN_CREATURE.toString());
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Cloudshift", EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
setStrictChooseMode(true);
setStopAt(2, PhaseStep.END_TURN);
@ -739,7 +739,7 @@ public class ManifestTest extends CardTestPlayerBase {
.findFirst()
.orElse(null);
Assert.assertNotNull(perm);
Assert.assertEquals("server side face down permanent must have empty name", EmptyNames.FACE_DOWN_CREATURE.toString(), perm.getName());
Assert.assertEquals("server side face down permanent must have empty name", EmptyNames.FACE_DOWN_CREATURE.getObjectName(), perm.getName());
GameView gameView = new GameView(game.getState(), game, viewFromPlayer.getId(), null);
PlayerView playerView = gameView.getPlayers()
.stream()
@ -844,8 +844,8 @@ public class ManifestTest extends CardTestPlayerBase {
execute();
assertGraveyardCount(playerA, excommunicate, 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
assertLife(playerA, 20);
assertLife(playerB, 18);
}

View file

@ -58,8 +58,8 @@ public class MorphTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
}
@ -73,7 +73,7 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pine Walker using Morph");
attack(3, playerA, EmptyNames.FACE_DOWN_CREATURE.toString());
attack(3, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
activateAbility(3, PhaseStep.POSTCOMBAT_MAIN, playerA, "{4}{G}: Turn this face-down permanent face up.");
setStopAt(3, PhaseStep.END_TURN);
@ -81,7 +81,7 @@ public class MorphTest extends CardTestPlayerBase {
assertLife(playerB, 18);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
assertPermanentCount(playerA, "Pine Walker", 1);
assertPowerToughness(playerA, "Pine Walker", 5, 5);
assertTapped("Pine Walker", false);
@ -104,8 +104,8 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pine Walker using Morph");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Icefeather Aven using Morph", TestPlayer.NO_TARGET, "Pine Walker", StackClause.WHILE_NOT_ON_STACK);
attack(3, playerA, EmptyNames.FACE_DOWN_CREATURE.toString());
attack(3, playerA, EmptyNames.FACE_DOWN_CREATURE.toString());
attack(3, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
attack(3, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
activateAbility(3, PhaseStep.DECLARE_BLOCKERS, playerA, "{1}{G}{U}: Turn this face-down permanent face up.");
setChoice(playerA, false); // Don't use return permanent to hand effect
@ -117,7 +117,7 @@ public class MorphTest extends CardTestPlayerBase {
assertHandCount(playerA, "Pine Walker", 0);
assertHandCount(playerA, "Icefeather Aven", 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPermanentCount(playerA, "Icefeather Aven", 1);
assertTapped("Icefeather Aven", true);
@ -148,7 +148,7 @@ public class MorphTest extends CardTestPlayerBase {
assertLife(playerB, 20); // and not 21
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPermanentCount(playerB, "Soldier of the Pantheon", 1);
}
@ -175,10 +175,10 @@ public class MorphTest extends CardTestPlayerBase {
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPowerToughness(playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPowerToughness(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
}
/**
@ -212,7 +212,7 @@ public class MorphTest extends CardTestPlayerBase {
assertHandCount(playerA, "Pine Walker", 0);
assertHandCount(playerB, "Doomwake Giant", 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
assertPermanentCount(playerB, "Doomwake Giant", 1);
assertPermanentCount(playerA, "Pine Walker", 1);
assertPowerToughness(playerA, "Pine Walker", 4, 4);
@ -252,7 +252,7 @@ public class MorphTest extends CardTestPlayerBase {
assertHandCount(playerA, "Ponyback Brigade", 0);
assertHandCount(playerB, "Doomwake Giant", 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
assertPermanentCount(playerA, "Goblin Token", 3);
assertPowerToughness(playerA, "Goblin Token", 1, 1, Filter.ComparisonScope.Any);
assertPermanentCount(playerB, "Doomwake Giant", 1);
@ -323,7 +323,7 @@ public class MorphTest extends CardTestPlayerBase {
assertHandCount(playerA, "Sagu Mauler", 0);
assertHandCount(playerB, "Disdainful Stroke", 1); // can't be cast
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@ -351,7 +351,7 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sagu Mauler using Morph", TestPlayer.NO_TARGET, "Sagu Mauler", StackClause.WHILE_NOT_ON_STACK);
// showBattlefield("A battle", 1, PhaseStep.POSTCOMBAT_MAIN, playerA);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Echoing Decay", EmptyNames.FACE_DOWN_CREATURE.toString());
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Echoing Decay", EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
// showBattlefield("A battle after", 1, PhaseStep.END_TURN, playerA);
setStopAt(1, PhaseStep.END_TURN);
@ -364,7 +364,7 @@ public class MorphTest extends CardTestPlayerBase {
assertHandCount(playerA, "Sagu Mauler", 0);
assertHandCount(playerB, "Echoing Decay", 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertGraveyardCount(playerA, "Sagu Mauler", 1);
}
@ -410,7 +410,7 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Birchlore Rangers using Morph");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Swords to Plowshares", "");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Swords to Plowshares", EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
@ -449,7 +449,7 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ashcloud Phoenix using Morph");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", EmptyNames.FACE_DOWN_CREATURE.toString());
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
@ -489,7 +489,7 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ashcloud Phoenix using Morph");
attack(2, playerB, "Mirri, Cat Warrior");
block(2, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), "Mirri, Cat Warrior");
block(2, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), "Mirri, Cat Warrior");
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
@ -528,7 +528,7 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Akroma, Angel of Fury using Morph");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Supplant Form");
addTarget(playerB, EmptyNames.FACE_DOWN_CREATURE.toString());
addTarget(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
setStopAt(1, PhaseStep.END_TURN);
execute();
@ -536,13 +536,13 @@ public class MorphTest extends CardTestPlayerBase {
assertLife(playerB, 20);
assertHandCount(playerA, "Akroma, Angel of Fury", 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
assertPermanentCount(playerA, "Akroma, Angel of Fury", 0);
assertGraveyardCount(playerB, "Supplant Form", 1);
assertPermanentCount(playerB, "Akroma, Angel of Fury", 0);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_TOKEN.toString(), 1);
assertPowerToughness(playerB, EmptyNames.FACE_DOWN_TOKEN.toString(), 2, 2);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_TOKEN.getTestCommand(), 1);
assertPowerToughness(playerB, EmptyNames.FACE_DOWN_TOKEN.getTestCommand(), 2, 2);
}
/**
@ -567,7 +567,7 @@ public class MorphTest extends CardTestPlayerBase {
assertLife(playerA, 20);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@ -591,7 +591,7 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pine Walker using Morph");
attack(3, playerA, EmptyNames.FACE_DOWN_CREATURE.toString());
attack(3, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
activateAbility(3, PhaseStep.POSTCOMBAT_MAIN, playerA, "{4}{G}: Turn this face-down permanent face up.");
setStopAt(3, PhaseStep.END_TURN);
@ -599,7 +599,7 @@ public class MorphTest extends CardTestPlayerBase {
assertLife(playerB, 18);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
assertPermanentCount(playerA, "Pine Walker", 1);
assertPowerToughness(playerA, "Pine Walker", 5, 5);
assertTapped("Pine Walker", false);
@ -652,7 +652,7 @@ public class MorphTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Reflector Mage", 1);
assertPermanentCount(playerB, "Rattleclaw Mystic", 0);
assertHandCount(playerB, "Rattleclaw Mystic", 1); // can't play
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 0); // don't try as morph
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0); // don't try as morph
}
@Test
@ -685,7 +685,7 @@ public class MorphTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Reflector Mage", 1);
assertPermanentCount(playerB, "Rattleclaw Mystic", 0);
assertHandCount(playerB, "Rattleclaw Mystic", 0); // able cast as morph
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
/**
@ -809,7 +809,7 @@ public class MorphTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Fatal Push", 1);
assertGraveyardCount(playerA, "Pine Walker", 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
}
@ -842,7 +842,7 @@ public class MorphTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertHandCount(playerA, 0);
assertTappedCount("Island", true, 3);
@ -877,7 +877,7 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Quicksilver Dragon using Morph");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", EmptyNames.FACE_DOWN_CREATURE.toString());
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
setStopAt(2, PhaseStep.UPKEEP);
execute();
@ -959,7 +959,7 @@ public class MorphTest extends CardTestPlayerBase {
execute();
assertPermanentCount(playerA, "Zoetic Cavern", 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@Test
@ -984,7 +984,7 @@ public class MorphTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Island", 1);
assertPermanentCount(playerA, "Zoetic Cavern", 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@Test
@ -1007,7 +1007,7 @@ public class MorphTest extends CardTestPlayerBase {
execute();
assertPermanentCount(playerA, "Zoetic Cavern", 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@Test
@ -1048,7 +1048,7 @@ public class MorphTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@Test
@ -1069,7 +1069,7 @@ public class MorphTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@Test
@ -1099,7 +1099,7 @@ public class MorphTest extends CardTestPlayerBase {
setStopAt(3, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@Test
@ -1122,7 +1122,7 @@ public class MorphTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2);
}
@Test
@ -1134,10 +1134,10 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Monastery Flock using Morph");
checkPT("face down", 1, PhaseStep.BEGIN_COMBAT, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 3);
checkPT("face down", 1, PhaseStep.BEGIN_COMBAT, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 3);
checkPlayableAbility("unmorph", 1, PhaseStep.BEGIN_COMBAT, playerA, "{U}: Turn this", true);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Tamiyo's Compleation", EmptyNames.FACE_DOWN_CREATURE.toString());
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Tamiyo's Compleation", EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
checkPlayableAbility("unmorph", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{U}: Turn this", false);
@ -1145,9 +1145,9 @@ public class MorphTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertTapped(EmptyNames.FACE_DOWN_CREATURE.toString(), true);
assertAttachedTo(playerA, "Tamiyo's Compleation", EmptyNames.FACE_DOWN_CREATURE.toString(), true);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 3);
assertTapped(EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), true);
assertAttachedTo(playerA, "Tamiyo's Compleation", EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), true);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 3);
}
@Test
@ -1162,10 +1162,10 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sage-Eye Harrier using Morph");
checkPT("face down", 1, PhaseStep.BEGIN_COMBAT, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
checkPT("face down", 1, PhaseStep.BEGIN_COMBAT, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
checkPlayableAbility("unmorph", 1, PhaseStep.BEGIN_COMBAT, playerA, "{3}{W}: Turn this", true);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Minimus Containment", EmptyNames.FACE_DOWN_CREATURE.toString());
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Minimus Containment", EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
checkPlayableAbility("unmorph", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{3}{W}: Turn this", false);
@ -1175,10 +1175,10 @@ public class MorphTest extends CardTestPlayerBase {
setStopAt(2, PhaseStep.UPKEEP);
execute();
assertSubtype(EmptyNames.FACE_DOWN_CREATURE.toString(), SubType.TREASURE);
assertType(EmptyNames.FACE_DOWN_CREATURE.toString(), CardType.ARTIFACT, true);
assertType(EmptyNames.FACE_DOWN_CREATURE.toString(), CardType.CREATURE, false);
assertAttachedTo(playerA, "Minimus Containment", EmptyNames.FACE_DOWN_CREATURE.toString(), true);
assertSubtype(EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), SubType.TREASURE);
assertType(EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), CardType.ARTIFACT, true);
assertType(EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), CardType.CREATURE, false);
assertAttachedTo(playerA, "Minimus Containment", EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), true);
}
@Test
@ -1190,7 +1190,7 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Monastery Flock using Morph");
checkPT("face down", 1, PhaseStep.BEGIN_COMBAT, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 3);
checkPT("face down", 1, PhaseStep.BEGIN_COMBAT, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 3);
checkPlayableAbility("unmorph", 1, PhaseStep.BEGIN_COMBAT, playerA, "{U}: Turn this", true);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Mycosynth Lattice");
@ -1201,10 +1201,10 @@ public class MorphTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertType(EmptyNames.FACE_DOWN_CREATURE.toString(), CardType.ARTIFACT, true);
assertType(EmptyNames.FACE_DOWN_CREATURE.toString(), CardType.CREATURE, true);
assertNotSubtype(EmptyNames.FACE_DOWN_CREATURE.toString(), SubType.BIRD);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 3);
assertType(EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), CardType.ARTIFACT, true);
assertType(EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), CardType.CREATURE, true);
assertNotSubtype(EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), SubType.BIRD);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 3);
}
@Test
@ -1216,17 +1216,17 @@ public class MorphTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Monastery Flock using Morph");
checkPT("face down", 1, PhaseStep.BEGIN_COMBAT, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 3);
checkPT("face down", 1, PhaseStep.BEGIN_COMBAT, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 3);
checkPlayableAbility("unmorph", 1, PhaseStep.BEGIN_COMBAT, playerA, "{U}: Turn this", true);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertType(EmptyNames.FACE_DOWN_CREATURE.toString(), CardType.ARTIFACT, true);
assertType(EmptyNames.FACE_DOWN_CREATURE.toString(), CardType.CREATURE, true);
assertNotSubtype(EmptyNames.FACE_DOWN_CREATURE.toString(), SubType.BIRD);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 3);
assertType(EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), CardType.ARTIFACT, true);
assertType(EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), CardType.CREATURE, true);
assertNotSubtype(EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), SubType.BIRD);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 3);
}
private void assertMorphedFaceDownColor(String info, String needColor) {
@ -1236,7 +1236,7 @@ public class MorphTest extends CardTestPlayerBase {
.findFirst()
.orElse(null);
Assert.assertNotNull(info + ", server side: can't find morphed permanent", permanent);
Assert.assertEquals(info + ", server side: wrong name", EmptyNames.FACE_DOWN_CREATURE.toString(), permanent.getName());
Assert.assertEquals(info + ", server side: wrong name", EmptyNames.FACE_DOWN_CREATURE.getObjectName(), permanent.getName());
Assert.assertEquals(info + ", server side: wrong color", needColor, permanent.getColor(currentGame).toString());
// client side - controller

View file

@ -128,7 +128,7 @@ public class CastFromGraveyardOnceTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@Test

View file

@ -50,7 +50,7 @@ public class UnboundFlourishingTest extends CardTestPlayerBase {
// cast with X=3, but double it twice
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Endless One");
setChoice(playerA, "X=3");
setChoice(playerA, ""); //stack triggers
setChoice(playerA, "Whenever you cast a permanent spell"); // x2 triggers from Unbound Flourishing
checkPermanentCounters("after", 1, PhaseStep.BEGIN_COMBAT, playerA, "Endless One", CounterType.P1P1, 3 * 2 * 2);
setStrictChooseMode(true);

View file

@ -105,8 +105,8 @@ public class ExileAndReturnUnderYourControl extends CardTestPlayerBase {
assertExileCount("Secret Plans", 0);
assertPermanentCount(playerA, "Secret Plans", 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 3);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 3);
}
/**

View file

@ -225,6 +225,6 @@ public class GontiLordOfLuxuryEffectTest extends CardTestPlayerBase {
setStopAt(4, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
}

View file

@ -72,7 +72,7 @@ public class AlteredEgoTest extends CardTestPlayerBase {
setChoice(playerB, "X=3");
setChoice(playerB, true); // use copy
setChoice(playerB, "Endless One"); // copy target
setChoice(playerB, ""); // Order place counters effects
setChoice(playerB, "Endless One"); // x2 replacement effects from Endless One
setStrictChooseMode(true);
setStopAt(2, PhaseStep.BEGIN_COMBAT);

View file

@ -271,7 +271,7 @@ public class CloneTest extends CardTestPlayerBase {
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Clone");
setChoice(playerA, true);
setChoice(playerA, EmptyNames.FACE_DOWN_CREATURE.toString());
setChoice(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
setStrictChooseMode(true);
setStopAt(3, PhaseStep.BEGIN_COMBAT);
@ -283,8 +283,8 @@ public class CloneTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Ixidron", 1);
assertPowerToughness(playerA, "Ixidron", 1, 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2, Filter.ComparisonScope.All);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2, Filter.ComparisonScope.All);
}
}

View file

@ -63,7 +63,7 @@ public class DefilersTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bear);
setChoice(playerA, true);
setChoice(playerA, true);
setChoice(playerA, "");
setChoice(playerA, "Whenever you cast a green permanent spell"); // x2 triggers from Defiler of Vigor
setStopAt(1, PhaseStep.END_TURN);
setStrictChooseMode(true);
@ -83,7 +83,7 @@ public class DefilersTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, tusker);
setChoice(playerA, true);
setChoice(playerA, true);
setChoice(playerA, "");
setChoice(playerA, "Whenever you cast a green permanent spell"); // x2 triggers from Defiler of Vigor
setStopAt(1, PhaseStep.END_TURN);
setStrictChooseMode(true);
@ -103,7 +103,7 @@ public class DefilersTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, goblin);
setChoice(playerA, true);
setChoice(playerA, true);
setChoice(playerA, "");
setChoice(playerA, "Whenever you cast a green permanent spell"); // x2 triggers from red and green defilers
addTarget(playerA, playerB);
setStopAt(1, PhaseStep.END_TURN);

View file

@ -163,7 +163,7 @@ public class RoleTest extends CardTestPlayerBase {
addTarget(playerA, bear + "^" + wardens);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, become);
setChoice(playerA, ""); // order triggers
setChoice(playerA, "<i>Constellation</i>"); // x2 triggers from Nexus Wardens
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);

View file

@ -51,7 +51,7 @@ public class StarfieldOfNyxTest extends CardTestPlayerBase {
execute();
assertGraveyardCount(playerA, "Thopter Spy Network", 0);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(),
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(),
2, 2, Filter.ComparisonScope.All); // the manifested cards
assertPermanentCount(playerA, "Starfield of Nyx", 1);
assertPowerToughness(playerA, "Thopter Spy Network", 4, 4, Filter.ComparisonScope.All);

View file

@ -38,7 +38,7 @@ public class GhastlyConscriptionTest extends CardTestPlayerBase {
assertLife(playerB, 20);
assertGraveyardCount(playerA, 2);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2);
}

View file

@ -33,7 +33,7 @@ public class ObscuringAetherTest extends CardTestPlayerBase {
assertHandCount(playerA, "Obscuring Aether", 0);
assertGraveyardCount(playerA, "Obscuring Aether", 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
}
}

View file

@ -35,7 +35,7 @@ public class PrimordialMistTest extends CardTestPlayerBase {
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Exile a face-down permanent you control");
setChoice(playerA, EmptyNames.FACE_DOWN_CREATURE.toString());
setChoice(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Brine Elemental");

View file

@ -41,7 +41,7 @@ public class TriggerTest extends CardTestPlayerBase {
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", EmptyNames.FACE_DOWN_CREATURE.toString());
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();

View file

@ -3,6 +3,7 @@ package org.mage.test.cards.replacement.entersBattlefield;
import mage.abilities.keyword.DefenderAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.HasteAbility;
import mage.constants.EmptyNames;
import mage.constants.PhaseStep;
import mage.constants.SubType;
import mage.constants.Zone;
@ -220,7 +221,7 @@ public class PrimalClayTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, aquamorph+" using Morph");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Savage Swipe");
addTarget(playerA, ""); // morph
addTarget(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand()); // morph
addTarget(playerA, "Siege Mastodon");
// 2/2 becomes 4/4, fights 3/5, neither dies
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);

View file

@ -89,7 +89,7 @@ public class MeddlingMageTest extends CardTestPlayerBase {
execute();
assertPermanentCount(playerA, "Meddling Mage", 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertHandCount(playerA, "Meddling Mage", 0);
assertHandCount(playerA, "Ainok Tracker", 0);
}

View file

@ -136,7 +136,7 @@ public class CantCastTest extends CardTestPlayerBase {
}
}
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
assertHandCount(playerA, "Pine Walker", 1);
}

View file

@ -15,6 +15,9 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class NamePredicateTest extends CardTestPlayerBase {
private void assertNamePredicate(String checkName, int needAmount, String needName, boolean ignoreMtgRules) {
//Assert.assertNotEquals("", needName); empty strings also testing here, so no need to assert it
needName = EmptyNames.replaceTestCommandByObjectName(needName);
FilterPermanent filter = new FilterPermanent();
filter.add(new NamePredicate(needName, ignoreMtgRules));
Assert.assertEquals(checkName, needAmount, currentGame.getBattlefield().countAll(filter, playerA.getId(), currentGame));
@ -33,20 +36,20 @@ public class NamePredicateTest extends CardTestPlayerBase {
execute();
assertPermanentCount(playerA, 3 + 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
// use mtg rules for name searching
assertNamePredicate("by rules - empty choice must return zero", 0, "", false);
assertNamePredicate("by rules - face down choice must return zero", 0, EmptyNames.FACE_DOWN_CREATURE.toString(), false);
assertNamePredicate("by rules - face down choice must return zero", 0, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), false);
assertNamePredicate("by rules - non existing name must return zero", 0, "Island", false);
assertNamePredicate("by rules - existing name must work", 3, "Forest", false);
// use inner engine for name searching (e.g. must find face down permanents with empty names)
if (!EmptyNames.FACE_DOWN_CREATURE.toString().isEmpty()) {
if (!EmptyNames.FACE_DOWN_CREATURE.getObjectName().isEmpty()) {
// if face down permanents gets inner name someday then empty choice must ignore it
assertNamePredicate("by inner - empty choice must return zero", 0, "", true);
}
assertNamePredicate("by inner - face down choice must work", 1, EmptyNames.FACE_DOWN_CREATURE.toString(), true);
assertNamePredicate("by inner - face down choice must work", 1, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), true);
assertNamePredicate("by inner - non existing name must return zero", 0, "Island", true);
assertNamePredicate("by inner - existing name must work", 3, "Forest", true);
}

View file

@ -33,7 +33,7 @@ public class JackdawSaviorTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Damnation");
setChoice(playerA, ""); //Order triggers
setChoice(playerA, "Whenever {this} or another creature you control"); // x2 triggers from Jackdaw Savior
addTarget(playerA, "Jackdaw Savior");
addTarget(playerA, "Memnite");

View file

@ -34,7 +34,7 @@ public class QarsiDeceiverTest extends CardTestPlayerBase {
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, mystic + " using Morph");
checkPT("morph", 3, PhaseStep.POSTCOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
checkPT("morph", 3, PhaseStep.POSTCOMBAT_MAIN, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
activateAbility(5, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}{U}: Turn");

View file

@ -56,8 +56,8 @@ public class MuragandaPetroglyphsTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 4, 4);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 4, 4);
}
@Test
@ -77,9 +77,9 @@ public class MuragandaPetroglyphsTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
//assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2); // no boost (permanent have haste)
assertAbility(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), HasteAbility.getInstance(), true);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
//assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestName(), 2, 2); // no boost (permanent have haste)
assertAbility(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), HasteAbility.getInstance(), true);
}
@Test

View file

@ -66,7 +66,6 @@ public class AlpineHoundmasterTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Alpine Houndmaster");
setChoice(playerA, true);
addTarget(playerA, "Igneous Cur^Alpine Watchdog");
//addTarget(playerA, "");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);

View file

@ -48,7 +48,7 @@ public class AssembleThePlayersTest extends CardTestPlayerBase {
setStopAt(3, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 2, 2);
assertPowerToughness(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 2, 2);
assertPowerToughness(playerA, merfolk, 2, 1);
}

View file

@ -33,9 +33,9 @@ public class CrypticCoatTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, coat);
checkPT("Cloaked is 3/2", 1, PhaseStep.BEGIN_COMBAT, playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 3, 2);
checkPT("Cloaked is 3/2", 1, PhaseStep.BEGIN_COMBAT, playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 3, 2);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", EmptyNames.FACE_DOWN_CREATURE.toString());
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", EmptyNames.FACE_DOWN_CREATURE.getTestCommand());
setChoice(playerB, true); // pay for ward
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{U}{U}: Turn this face-down permanent face up.");

View file

@ -1,6 +1,5 @@
package org.mage.test.cards.single.ths;
import mage.constants.CardType;
import mage.constants.EmptyNames;
import mage.constants.PhaseStep;
import mage.constants.Zone;
@ -48,7 +47,7 @@ public class PurphorosGodOfTheForgeTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Reach of Shadows", 1);
assertPermanentCount(playerA, "Ashcloud Phoenix", 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
Permanent purphorosGodOfTheForge = getPermanent("Purphoros, God of the Forge", playerA);
Assert.assertFalse("Purphoros may not be a creature but it is", purphorosGodOfTheForge.isCreature(currentGame));
@ -79,7 +78,7 @@ public class PurphorosGodOfTheForgeTest extends CardTestPlayerBase {
execute();
assertPermanentCount(playerA, "Ashcloud Phoenix", 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertLife(playerA, 18); // 2 damage from Eidolon of the Great Revel
assertLife(playerB, 18); // 2 damage from Purphoros for the morphed Phoenix

View file

@ -98,7 +98,7 @@ public class CemeteryIlluminatorTest extends CardTestPlayerBase {
assertExileCount(playerA, creature, 1);
assertPermanentCount(playerA, ci, 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPermanentCount(playerA, whetwheel, 0);
}

View file

@ -119,7 +119,7 @@ public class ThijarianWitnessTest extends CardTestPlayerBase {
attack(1, playerA, tiny);
block(1, playerB, tiny, tiny);
setChoice(playerA, ""); //stack triggers
setChoice(playerA, "<i>Bear Witness</i>"); // x2 triggers from Thijarian Witness
setStopAt(1, PhaseStep.END_TURN);
execute();
@ -158,8 +158,8 @@ public class ThijarianWitnessTest extends CardTestPlayerBase {
attack(1, playerA, tiny);
block(1, playerB, tiny, tiny);
setChoice(playerA, ""); //stack triggers
setChoice(playerB, "");
setChoice(playerA, "<i>Bear Witness</i>"); // x2 triggers from Thijarian Witness
setChoice(playerB, "<i>Bear Witness</i>"); // x2 triggers from Thijarian Witness
setStopAt(1, PhaseStep.END_TURN);
execute();

View file

@ -40,7 +40,7 @@ public class WhisperwoodElementalTest extends CardTestPlayerBase {
assertGraveyardCount(playerA, "Silvercoat Lion", 1);
// Manifested creature from dying Silvercoat Lion
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
}

View file

@ -154,6 +154,13 @@ public class TestPlayer implements Player {
}
public void addChoice(String choice) {
// prepare face down
// how-to fix:
// * for face down choices: use EmptyNames.XXX.getTestCommand instead toString
// * for replacement/triggers choices: comment choice command, look at logs for triggers list and use starting text in the choice instead empty
Assert.assertNotEquals("Choice can't be empty", "", choice);
choice = EmptyNames.replaceTestCommandByObjectName(choice);
choices.add(choice);
}
@ -182,6 +189,12 @@ public class TestPlayer implements Player {
}
public void addTarget(String target) {
// prepare face down
// how-to fix: if it's a face down object then use getTestCommand instead toString
Assert.assertNotEquals("Target can't be empty", "", target);
target = EmptyNames.replaceTestCommandByObjectName(target);
targets.add(target);
}

View file

@ -300,7 +300,7 @@ public class TokenImagesTest extends CardTestPlayerBase {
Assert.assertNotEquals(prefix + " - wrong image number", Integer.valueOf(0), object.getImageNumber());
// characteristic checks instead new test
Assert.assertEquals(prefix + " - wrong name", EmptyNames.FACE_DOWN_CREATURE.toString(), object.getName());
Assert.assertEquals(prefix + " - wrong name", EmptyNames.FACE_DOWN_CREATURE.getObjectName(), object.getName());
Assert.assertEquals(prefix + " - wrong power", 2, object.getPower().getValue());
Assert.assertEquals(prefix + " - wrong toughness", 2, object.getToughness().getValue());
Assert.assertEquals(prefix + " - wrong color", "", object.getColor(currentGame).toString());
@ -746,7 +746,7 @@ public class TokenImagesTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), faceDownAmount);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), faceDownAmount);
assert_FaceDownMorphImageNumber(Arrays.asList(1, 2, 3));
}
@ -765,7 +765,7 @@ public class TokenImagesTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), faceDownAmount);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), faceDownAmount);
assert_FaceDownMorphImageNumber(Arrays.asList(1, 2, 3));
}
@ -844,7 +844,7 @@ public class TokenImagesTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}
@Test
@ -856,16 +856,16 @@ public class TokenImagesTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Aerie Bowmasters using Morph");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
runCode("on face down", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
assertPermanentCount(playerA, "Aerie Bowmasters", 0);
Permanent permanent = getPermanent(EmptyNames.FACE_DOWN_CREATURE.toString(), playerA);
Permanent permanent = getPermanent(EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), playerA);
assertFaceDownCharacteristics("permanent", permanent, TokenRepository.XMAGE_IMAGE_NAME_FACE_DOWN_MORPH);
});
// face up it and find counter
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{5}{G}: Turn this");
runCode("on face up", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 0);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 0);
assertPermanentCount(playerA, "Aerie Bowmasters", 1);
assertCounterCount(playerA, "Aerie Bowmasters", CounterType.P1P1, 1);
});

View file

@ -32,7 +32,9 @@ import mage.utils.SystemUtil;
import mage.util.CardUtil;
import mage.view.GameView;
import org.junit.Assert;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.mage.test.player.PlayerAction;
import org.mage.test.player.TestPlayer;
@ -349,12 +351,16 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void checkPT(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, Integer power, Integer toughness) {
//Assert.assertNotEquals("", permanentName);
Assert.assertNotEquals("", permanentName);
permanentName = EmptyNames.replaceTestCommandByObjectName(permanentName);
check(checkName, turnNum, step, player, CHECK_COMMAND_PT, permanentName, power.toString(), toughness.toString());
}
public void checkDamage(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, Integer damage) {
//Assert.assertNotEquals("", permanentName);
Assert.assertNotEquals("", permanentName);
permanentName = EmptyNames.replaceTestCommandByObjectName(permanentName);
check(checkName, turnNum, step, player, CHECK_COMMAND_DAMAGE, permanentName, damage.toString());
}
@ -367,7 +373,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void checkAbility(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, Class<?> abilityClass, Boolean mustHave) {
//Assert.assertNotEquals("", permanentName);
Assert.assertNotEquals("", permanentName);
permanentName = EmptyNames.replaceTestCommandByObjectName(permanentName);
check(checkName, turnNum, step, player, CHECK_COMMAND_ABILITY, permanentName, abilityClass.getName(), mustHave.toString());
}
@ -412,12 +420,13 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void checkPermanentCount(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, Integer count) {
//Assert.assertNotEquals("", permanentName);
checkPermanentCount(checkName, turnNum, step, player, player, permanentName, count);
}
public void checkPermanentCount(String checkName, int turnNum, PhaseStep step, TestPlayer player, TestPlayer targetPlayer, String permanentName, Integer count) {
//Assert.assertNotEquals("", permanentName);
Assert.assertNotEquals("", permanentName);
permanentName = EmptyNames.replaceTestCommandByObjectName(permanentName);
check(checkName, turnNum, step, player, CHECK_COMMAND_PERMANENT_COUNT, targetPlayer.getId().toString(), permanentName, count.toString());
}
@ -438,17 +447,23 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void checkExileCount(String checkName, int turnNum, PhaseStep step, TestPlayer player, String cardName, Integer count) {
//Assert.assertNotEquals("", permanentName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
check(checkName, turnNum, step, player, CHECK_COMMAND_EXILE_COUNT, cardName, count.toString());
}
public void checkGraveyardCount(String checkName, int turnNum, PhaseStep step, TestPlayer player, String cardName, Integer count) {
//Assert.assertNotEquals("", permanentName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
check(checkName, turnNum, step, player, CHECK_COMMAND_GRAVEYARD_COUNT, cardName, count.toString());
}
public void checkLibraryCount(String checkName, int turnNum, PhaseStep step, TestPlayer player, String cardName, Integer count) {
//Assert.assertNotEquals("", permanentName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
check(checkName, turnNum, step, player, CHECK_COMMAND_LIBRARY_COUNT, cardName, count.toString());
}
@ -457,32 +472,44 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void checkHandCardCount(String checkName, int turnNum, PhaseStep step, TestPlayer player, String cardName, Integer count) {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
check(checkName, turnNum, step, player, CHECK_COMMAND_HAND_CARD_COUNT, cardName, count.toString());
}
public void checkCommandCardCount(String checkName, int turnNum, PhaseStep step, TestPlayer player, String cardName, Integer count) {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
check(checkName, turnNum, step, player, CHECK_COMMAND_COMMAND_CARD_COUNT, cardName, count.toString());
}
public void checkEmblemCount(String checkName, int turnNum, PhaseStep step, TestPlayer player, String emblemName, Integer count) {
//Assert.assertNotEquals("", emblemName);
Assert.assertNotEquals("", emblemName);
emblemName = EmptyNames.replaceTestCommandByObjectName(emblemName);
check(checkName, turnNum, step, player, CHECK_COMMAND_EMBLEM_COUNT, emblemName, count.toString());
}
public void checkColor(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, String colors, Boolean mustHave) {
//Assert.assertNotEquals("", permanentName);
Assert.assertNotEquals("", permanentName);
permanentName = EmptyNames.replaceTestCommandByObjectName(permanentName);
check(checkName, turnNum, step, player, CHECK_COMMAND_COLOR, permanentName, colors, mustHave.toString());
}
public void checkType(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, CardType type, Boolean mustHave) {
//Assert.assertNotEquals("", permanentName);
Assert.assertNotEquals("", permanentName);
permanentName = EmptyNames.replaceTestCommandByObjectName(permanentName);
check(checkName, turnNum, step, player, CHECK_COMMAND_TYPE, permanentName, type.toString(), mustHave.toString());
}
public void checkSubType(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, SubType subType, Boolean mustHave) {
//Assert.assertNotEquals("", permanentName);
Assert.assertNotEquals("", permanentName);
permanentName = EmptyNames.replaceTestCommandByObjectName(permanentName);
check(checkName, turnNum, step, player, CHECK_COMMAND_SUBTYPE, permanentName, subType.toString(), mustHave.toString());
}
@ -850,7 +877,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
@Override
public void assertPowerToughness(Player player, String cardName, int powerNeeded, int toughnessNeeded, Filter.ComparisonScope scope, boolean checkBaseValues) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
int count = 0;
int fit = 0;
int foundPower = 0;
@ -908,7 +937,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
@Override
public void assertAbilities(Player player, String cardName, List<Ability> abilities)
throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
int count = 0;
Permanent found = null;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
@ -944,7 +975,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @throws AssertionError
*/
public void assertAbility(Player player, String cardName, Ability ability, boolean mustHave, int count) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
int foundCount = 0;
Permanent found = null;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
@ -970,6 +1003,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void assertAbilityCount(Player player, String cardName, Class<? extends Ability> searchedAbility, int amount) {
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
Permanent found = null;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
if (isObjectHaveTargetNameOrAlias(player, permanent, cardName)) {
@ -1010,7 +1046,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
*/
@Override
public void assertPermanentCount(Player player, String cardName, int count) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
int actualCount = 0;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
if (permanent.getControllerId().equals(player.getId())) {
@ -1024,7 +1062,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
@Override
public void assertTokenCount(Player player, String tokenName, int count) throws AssertionError {
//Assert.assertNotEquals("", tokenName);
Assert.assertNotEquals("", tokenName);
tokenName = EmptyNames.replaceTestCommandByObjectName(tokenName);
int actualCount = 0;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
if (permanent instanceof PermanentToken) {
@ -1040,7 +1080,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
@Override
public void assertCommandZoneCount(Player player, String commandZoneObjectName, int count) throws AssertionError {
//Assert.assertNotEquals("", commandZoneObjectName);
Assert.assertNotEquals("", commandZoneObjectName);
commandZoneObjectName = EmptyNames.replaceTestCommandByObjectName(commandZoneObjectName);
int actualCount = 0;
for (CommandObject commandObject : currentGame.getState().getCommand()) {
if (commandObject.getControllerId().equals(player.getId()) && isObjectHaveTargetNameOrAlias(player, commandObject, commandZoneObjectName)) {
@ -1101,7 +1143,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param count Expected count.
*/
public void assertCounterCount(Player player, String cardName, String counterName, int count) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
Permanent found = null;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
if (isObjectHaveTargetNameOrAlias(player, permanent, cardName) && (player == null || permanent.getControllerId().equals(player.getId()))) {
@ -1121,7 +1165,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param count Expected count.
*/
public void assertCounterOnExiledCardCount(String cardName, CounterType type, int count) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
Card found = null;
for (Card card : currentGame.getExile().getAllCards(currentGame)) {
@ -1154,11 +1200,13 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param mustHave true if creature should have type, false if it should not
*/
public void assertType(String cardName, CardType type, boolean mustHave) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
assertAliaseSupportInActivateCommand(cardName, false);
Permanent found = null;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
if (permanent.getName().equals(cardName)) {
if (CardUtil.haveSameNames(permanent.getName(), cardName, true)) {
found = permanent;
break;
}
@ -1179,7 +1227,6 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param subType a subtype to test for
*/
public void assertType(String cardName, CardType type, SubType subType) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Permanent found = getPermanent(cardName);
assertTrue("(Battlefield) card type not found (" + cardName + ':' + type + ')', found.getCardType(currentGame).contains(type));
if (subType != null) {
@ -1194,7 +1241,6 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param type A type to test for
*/
public void assertNotType(String cardName, CardType type) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Permanent found = getPermanent(cardName);
Assert.assertFalse("(Battlefield) card type found (" + cardName + ':' + type + ')', found.getCardType(currentGame).contains(type));
}
@ -1206,7 +1252,6 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param subType a subtype to test for
*/
public void assertNotSubtype(String cardName, SubType subType) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Permanent found = getPermanent(cardName);
if (subType != null) {
Assert.assertFalse("(Battlefield) card sub-type equal (" + cardName + ':' + subType.getDescription() + ')', found.hasSubtype(subType, currentGame));
@ -1220,7 +1265,6 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param subType a subtype to test for
*/
public void assertSubtype(String cardName, SubType subType) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Permanent found = getPermanent(cardName);
if (subType != null) {
assertTrue("(Battlefield) card sub-type equal (" + cardName + ':' + subType.getDescription() + ')', found.hasSubtype(subType, currentGame));
@ -1236,7 +1280,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param mustHave must or not must have that colors
*/
public void assertColor(Player player, String cardName, ObjectColor searchColors, boolean mustHave) {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
Assert.assertNotEquals("must setup colors to search", 0, searchColors.getColorCount());
Permanent card = getPermanent(cardName, player);
@ -1271,7 +1317,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param tapped Whether the permanent is tapped or not
*/
public void assertTapped(String cardName, boolean tapped) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
assertAliaseSupportInActivateCommand(cardName, true);
Permanent found = null;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
@ -1299,12 +1347,14 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param count The number of these permanents that should be tapped
*/
public void assertTappedCount(String cardName, boolean tapped, int count) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
assertAliaseSupportInActivateCommand(cardName, false);
int tappedAmount = 0;
Permanent found = null;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
if (permanent.getName().equals(cardName)) {
if (CardUtil.haveSameNames(permanent.getName(), cardName, true)) {
if (permanent.isTapped() == tapped) {
tappedAmount++;
}
@ -1322,11 +1372,13 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param attacking Whether the permanent is attacking or not
*/
public void assertAttacking(String cardName, boolean attacking) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
assertAliaseSupportInActivateCommand(cardName, false);
Permanent found = null;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
if (permanent.getName().equals(cardName)) {
if (CardUtil.haveSameNames(permanent.getName(), cardName, true)) {
found = permanent;
}
}
@ -1355,7 +1407,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param count Expected count.
*/
public void assertHandCount(Player player, String cardName, int count) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
int actual;
if (cardName.contains("//")) { // special logic for checked split cards, because in game logic of card name filtering is different from in test
actual = 0;
@ -1414,6 +1468,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param subType Expected subtype.
*/
public void assertExiledCardSubtype(String cardName, SubType subType) throws AssertionError {
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
boolean found = false;
for (ExileZone exile : currentGame.getExile().getExileZones()) {
for (Card card : exile.getCards(currentGame)) {
@ -1433,7 +1490,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param count Expected count.
*/
public void assertExileCount(String cardName, int count) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
int actualCount = 0;
for (ExileZone exile : currentGame.getExile().getExileZones()) {
for (Card card : exile.getCards(currentGame)) {
@ -1473,12 +1532,14 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param count Expected count.
*/
public void assertExileCount(Player owner, String cardName, int count) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
assertAliaseSupportInActivateCommand(cardName, false);
int actualCount = 0;
for (ExileZone exile : currentGame.getExile().getExileZones()) {
for (Card card : exile.getCards(currentGame)) {
if (card.isOwnedBy(owner.getId()) && card.getName().equals(cardName)) {
if (card.isOwnedBy(owner.getId()) && CardUtil.haveSameNames(card.getName(), cardName, true)) {
actualCount++;
}
}
@ -1486,20 +1547,6 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
Assert.assertEquals("(Exile " + owner.getName() + ") Card counts are not equal (" + cardName + ").", count, actualCount);
}
/**
* Assert card count in a specific exile zone.
*
* @param exileZoneName Name of the exile zone to be counted.
* @param count Expected count.
* @throws AssertionError
*/
public void assertExileZoneCount(String exileZoneName, int count) throws AssertionError {
ExileZone exileZone = currentGame.getExile().getExileZone(CardUtil.getExileZoneId(exileZoneName, currentGame));
int actualCount = exileZone == null ? 0 : exileZone.getCards(currentGame).size();
Assert.assertEquals("(Exile \"" + exileZoneName + "\") Card counts are not equal.", count, actualCount);
}
/**
* Assert card count in player's graveyard.
*
@ -1508,8 +1555,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param count Expected count.
*/
public void assertGraveyardCount(Player player, String cardName, int count) throws AssertionError {
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
assertAliaseSupportInActivateCommand(cardName, true);
//Assert.assertNotEquals("", cardName);
int actualCount = 0;
for (Card card : player.getGraveyard().getCards(currentGame)) {
if (isObjectHaveTargetNameOrAlias(player, card, cardName)) {
@ -1540,7 +1590,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param count Expected count.
*/
public void assertLibraryCount(Player player, String cardName, int count) throws AssertionError {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
int actualCount = 0;
for (Card card : player.getLibrary().getCards(currentGame)) {
if (CardUtil.haveSameNames(card.getName(), cardName, true)) {
@ -1614,9 +1666,16 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param isAttached true => assertIsAttachedTo, false => assertIsNotAttachedTo
*/
public void assertAttachedTo(TestPlayer thePlayer, String theAttachment, String thePermanent, boolean isAttached) {
Assert.assertNotEquals("", theAttachment);
theAttachment = EmptyNames.replaceTestCommandByObjectName(theAttachment);
Assert.assertNotEquals("", thePermanent);
thePermanent = EmptyNames.replaceTestCommandByObjectName(thePermanent);
String needPermanent = thePermanent;
String needAttachment = theAttachment;
List<Permanent> permanents = currentGame.getBattlefield().getAllActivePermanents().stream()
.filter(permanent -> permanent.isControlledBy(thePlayer.getId()))
.filter(permanent -> permanent.getName().equals(thePermanent))
.filter(permanent -> CardUtil.haveSameNames(permanent.getName(), needPermanent, true))
.collect(Collectors.toList());
assertTrue(theAttachment + " was " + (!isAttached ? "" : "not") + " attached to " + thePermanent,
!isAttached ^
@ -1624,13 +1683,16 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
.anyMatch(permanent -> permanent.getAttachments()
.stream()
.map(id -> currentGame.getCard(id))
.map(MageObject::getName)
.collect(Collectors.toList()).contains(theAttachment)));
.filter(Objects::nonNull)
.anyMatch(o -> CardUtil.haveSameNames(o.getName(), needAttachment, true))));
}
public Permanent getPermanent(String cardName, UUID controller) {
assertAliaseSupportInActivateCommand(cardName, false);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
Permanent found = null;
Pattern indexedName = Pattern.compile("^([\\w| ]+):(\\d+)$"); // Ends with <:number>
Matcher indexedMatcher = indexedName.matcher(cardName);
@ -1641,7 +1703,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
index = Integer.parseInt(indexedMatcher.group(2));
}
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
if (permanent.getName().equals(cardName)) {
if (CardUtil.haveSameNames(permanent.getName(), cardName, true)) {
if (controller == null || permanent.getControllerId().equals(controller)) {
found = permanent;
if (count != index) {
@ -1664,13 +1726,17 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void playLand(int turnNum, PhaseStep step, TestPlayer player, String cardName) {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
assertAliaseSupportInActivateCommand(cardName, false);
addPlayerAction(player, turnNum, step, ACTIVATE_PLAY + cardName);
}
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName) {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
assertAliaseSupportInActivateCommand(cardName, false);
addPlayerAction(player, turnNum, step, ACTIVATE_CAST + cardName);
}
@ -1683,14 +1749,18 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, Player target) {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
// warning, target in spell cast command setups without choose target call
assertAliaseSupportInActivateCommand(cardName, false);
addPlayerAction(player, turnNum, step, ACTIVATE_CAST + cardName + "$targetPlayer=" + target.getName());
}
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, Player target, int manaInPool) {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
assertAliaseSupportInActivateCommand(cardName, false);
addPlayerAction(player, turnNum, step, ACTIVATE_CAST + cardName + "$targetPlayer=" + target.getName() + "$manaInPool=" + manaInPool);
}
@ -1810,9 +1880,14 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* warning, do not support cards with target adjusters - use addTarget instead
*/
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName) {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
Assert.assertNotEquals("", targetName);
targetName = EmptyNames.replaceTestCommandByObjectName(targetName);
assertAliaseSupportInActivateCommand(cardName, true);
assertAliaseSupportInActivateCommand(targetName, true);
addPlayerAction(player, turnNum, step, ACTIVATE_CAST + cardName + "$target=" + targetName);
}
@ -1863,7 +1938,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param clause
*/
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName, String spellOnStack, StackClause clause) {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
Assert.assertNotEquals("", targetName);
targetName = EmptyNames.replaceTestCommandByObjectName(targetName);
assertAliaseSupportInActivateCommand(cardName, true);
assertAliaseSupportInActivateCommand(targetName, true);
assertAliaseSupportInActivateCommand(spellOnStack, false);
@ -1891,7 +1970,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName, String spellOnStack, String spellOnTopOfStack) {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
Assert.assertNotEquals("", targetName);
targetName = EmptyNames.replaceTestCommandByObjectName(targetName);
assertAliaseSupportInActivateCommand(cardName, false);
assertAliaseSupportInActivateCommand(targetName, false);
assertAliaseSupportInActivateCommand(spellOnStack, false);
@ -1961,6 +2044,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param clause
*/
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, String targetName, String spellOnStack, StackClause clause) {
Assert.assertNotEquals("", targetName);
targetName = EmptyNames.replaceTestCommandByObjectName(targetName);
assertAliaseSupportInActivateCommand(ability, true);
assertAliaseSupportInActivateCommand(targetName, true);
StringBuilder sb = new StringBuilder(ACTIVATE_ABILITY).append(ability);
@ -1986,24 +2072,32 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void addCounters(int turnNum, PhaseStep step, TestPlayer player, String cardName, CounterType type, int count) {
//Assert.assertNotEquals("", cardName);
Assert.assertNotEquals("", cardName);
cardName = EmptyNames.replaceTestCommandByObjectName(cardName);
addPlayerAction(player, turnNum, step, "addCounters:" + cardName + '$' + type.getName() + '$' + count);
}
public void attack(int turnNum, TestPlayer player, String attacker) {
//Assert.assertNotEquals("", attacker);
Assert.assertNotEquals("", attacker);
attacker = EmptyNames.replaceTestCommandByObjectName(attacker);
assertAliaseSupportInActivateCommand(attacker, false); // it uses old special notation like card_name:index
addPlayerAction(player, turnNum, PhaseStep.DECLARE_ATTACKERS, "attack:" + attacker);
}
public void attack(int turnNum, TestPlayer player, String attacker, TestPlayer defendingPlayer) {
//Assert.assertNotEquals("", attacker);
Assert.assertNotEquals("", attacker);
attacker = EmptyNames.replaceTestCommandByObjectName(attacker);
assertAliaseSupportInActivateCommand(attacker, false); // it uses old special notation like card_name:index
addPlayerAction(player, turnNum, PhaseStep.DECLARE_ATTACKERS, "attack:" + attacker + "$defendingPlayer=" + defendingPlayer.getName());
}
public void attack(int turnNum, TestPlayer player, String attacker, String permanent) {
//Assert.assertNotEquals("", attacker);
Assert.assertNotEquals("", attacker);
attacker = EmptyNames.replaceTestCommandByObjectName(attacker);
assertAliaseSupportInActivateCommand(attacker, false); // it uses old special notation like card_name:index
assertAliaseSupportInActivateCommand(permanent, false);
addPlayerAction(player, turnNum, PhaseStep.DECLARE_ATTACKERS, "attack:" + attacker + "$permanent=" + permanent);
@ -2014,15 +2108,18 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void block(int turnNum, TestPlayer player, String blocker, String attacker) {
//Assert.assertNotEquals("", blocker);
//Assert.assertNotEquals("", attacker);
Assert.assertNotEquals("", attacker);
attacker = EmptyNames.replaceTestCommandByObjectName(attacker);
Assert.assertNotEquals("", blocker);
blocker = EmptyNames.replaceTestCommandByObjectName(blocker);
assertAliaseSupportInActivateCommand(blocker, false); // it uses old special notation like card_name:index
assertAliaseSupportInActivateCommand(attacker, false);
addPlayerAction(player, turnNum, PhaseStep.DECLARE_BLOCKERS, "block:" + blocker + '$' + attacker);
}
public void blockSkip(int turnNum, TestPlayer player) {
block(turnNum, player, TestPlayer.BLOCK_SKIP, "");
block(turnNum, player, TestPlayer.BLOCK_SKIP, TestPlayer.ATTACK_SKIP);
}
/**
@ -2193,7 +2290,6 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void assertDamageReceived(Player player, String cardName, int expected) {
//Assert.assertNotEquals("", cardName);
Permanent p = getPermanent(cardName, player);
if (p != null) {
Assert.assertEquals("Wrong damage received: ", expected, p.getDamage());
@ -2239,7 +2335,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
if (player != null) { // TODO: remove null check and replace all null-player calls in tests by player
return testPlayer.hasObjectTargetNameOrAlias(object, nameOrAlias);
} else {
return object.getName().equals(nameOrAlias);
return CardUtil.haveSameNames(object.getName(), nameOrAlias, true);
}
}

View file

@ -20,32 +20,32 @@ public class AliasesApiTest extends CardTestPlayerBase {
public void test_NamesEquals() {
// empty names for face down cards
Assert.assertTrue(CardUtil.haveEmptyName(""));
Assert.assertTrue(CardUtil.haveEmptyName(EmptyNames.FACE_DOWN_CREATURE.toString()));
Assert.assertTrue(CardUtil.haveEmptyName(EmptyNames.FACE_DOWN_CREATURE.getObjectName()));
Assert.assertFalse(CardUtil.haveEmptyName(" "));
Assert.assertFalse(CardUtil.haveEmptyName("123"));
Assert.assertFalse(CardUtil.haveEmptyName("Sample Name"));
// same names (empty names can't be same)
Assert.assertFalse(CardUtil.haveSameNames("", ""));
Assert.assertFalse(CardUtil.haveSameNames(EmptyNames.FACE_DOWN_CREATURE.toString(), ""));
Assert.assertFalse(CardUtil.haveSameNames(EmptyNames.FACE_DOWN_CREATURE.toString(), EmptyNames.FACE_DOWN_CREATURE.toString()));
Assert.assertFalse(CardUtil.haveSameNames(EmptyNames.FACE_DOWN_TOKEN.toString(), ""));
Assert.assertFalse(CardUtil.haveSameNames(EmptyNames.FACE_DOWN_TOKEN.toString(), EmptyNames.FACE_DOWN_CREATURE.toString()));
Assert.assertFalse(CardUtil.haveSameNames(EmptyNames.FACE_DOWN_CREATURE.getObjectName(), ""));
Assert.assertFalse(CardUtil.haveSameNames(EmptyNames.FACE_DOWN_CREATURE.getObjectName(), EmptyNames.FACE_DOWN_CREATURE.getObjectName()));
Assert.assertFalse(CardUtil.haveSameNames(EmptyNames.FACE_DOWN_TOKEN.getObjectName(), ""));
Assert.assertFalse(CardUtil.haveSameNames(EmptyNames.FACE_DOWN_TOKEN.getObjectName(), EmptyNames.FACE_DOWN_CREATURE.getObjectName()));
Assert.assertTrue(CardUtil.haveSameNames("Name", "Name"));
Assert.assertFalse(CardUtil.haveSameNames("Name", ""));
Assert.assertFalse(CardUtil.haveSameNames("Name", " "));
Assert.assertFalse(CardUtil.haveSameNames("Name", "123"));
Assert.assertFalse(CardUtil.haveSameNames("Name", EmptyNames.FACE_DOWN_CREATURE.toString()));
Assert.assertFalse(CardUtil.haveSameNames("Name", EmptyNames.FACE_DOWN_CREATURE.getObjectName()));
Assert.assertFalse(CardUtil.haveSameNames("Name1", "Name2"));
// ignore mtg rules (empty names must be same)
Assert.assertTrue(CardUtil.haveSameNames("", "", true));
Assert.assertTrue(CardUtil.haveSameNames(EmptyNames.FACE_DOWN_CREATURE.toString(), EmptyNames.FACE_DOWN_CREATURE.toString(), true));
Assert.assertTrue(CardUtil.haveSameNames(EmptyNames.FACE_DOWN_CREATURE.getObjectName(), EmptyNames.FACE_DOWN_CREATURE.getObjectName(), true));
Assert.assertTrue(CardUtil.haveSameNames("Name", "Name", true));
Assert.assertFalse(CardUtil.haveSameNames("Name", "", true));
Assert.assertFalse(CardUtil.haveSameNames("Name", " ", true));
Assert.assertFalse(CardUtil.haveSameNames("Name", "123", true));
Assert.assertFalse(CardUtil.haveSameNames("Name", EmptyNames.FACE_DOWN_CREATURE.toString(), true));
Assert.assertFalse(CardUtil.haveSameNames("Name", EmptyNames.FACE_DOWN_CREATURE.getObjectName(), true));
Assert.assertFalse(CardUtil.haveSameNames("Name1", "Name2", true));
// name with split card
@ -68,12 +68,12 @@ public class AliasesApiTest extends CardTestPlayerBase {
// normal spell
Assert.assertFalse(CardUtil.haveSameNames(normalSpell, "", currentGame));
Assert.assertFalse(CardUtil.haveSameNames(normalSpell, "Other", currentGame));
Assert.assertFalse(CardUtil.haveSameNames(normalSpell, EmptyNames.FACE_DOWN_CREATURE.toString(), currentGame));
Assert.assertFalse(CardUtil.haveSameNames(normalSpell, EmptyNames.FACE_DOWN_CREATURE.getObjectName(), currentGame));
Assert.assertTrue(CardUtil.haveSameNames(normalSpell, "Balduvian Bears", currentGame));
// face down spell
Assert.assertFalse(CardUtil.haveSameNames(faceDownSpell, "", currentGame));
Assert.assertFalse(CardUtil.haveSameNames(faceDownSpell, "Other", currentGame));
Assert.assertFalse(CardUtil.haveSameNames(faceDownSpell, EmptyNames.FACE_DOWN_CREATURE.toString(), currentGame));
Assert.assertFalse(CardUtil.haveSameNames(faceDownSpell, EmptyNames.FACE_DOWN_CREATURE.getObjectName(), currentGame));
Assert.assertFalse(CardUtil.haveSameNames(faceDownSpell, "Balduvian Bears", currentGame));
}

View file

@ -251,7 +251,7 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl {
String originalObjectInfo = object.toString();
// warning, it's a direct changes to the object (without game state, so no game param here)
object.setName(EmptyNames.FACE_DOWN_CREATURE.toString());
object.setName(EmptyNames.FACE_DOWN_CREATURE.getObjectName());
object.removeAllSuperTypes();
object.getSubtype().clear();
object.removeAllCardTypes();

View file

@ -870,7 +870,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
@Override
public String getLogName() {
if (name.isEmpty()) {
return GameLog.getNeutralColoredText(EmptyNames.FACE_DOWN_CREATURE.toString());
return GameLog.getNeutralColoredText(EmptyNames.FACE_DOWN_CREATURE.getObjectName());
} else {
return GameLog.getColoredObjectIdName(this);
}

View file

@ -1,33 +1,50 @@
package mage.constants;
import java.util.Arrays;
/**
*
* @author JayDi85
*/
public enum EmptyNames {
// TODO: make names for that cards and enable Assert.assertNotEquals("", permanentName); for assertXXX tests
// TODO: replace all getName().equals to haveSameNames and haveEmptyName
FACE_DOWN_CREATURE(""), // "Face down creature"
FACE_DOWN_TOKEN(""), // "Face down token"
FACE_DOWN_CARD(""); // "Face down card"
FACE_DOWN_CREATURE("", "[face_down_creature]"), // "Face down creature"
FACE_DOWN_TOKEN("", "[face_down_token]"), // "Face down token"
FACE_DOWN_CARD("", "[face_down_card]"); // "Face down card"
public static final String EMPTY_NAME_IN_LOGS = "face down object";
private final String cardName;
private final String objectName; // for mtg rules
private final String testCommand; // for unit tests
EmptyNames(String cardName) {
this.cardName = cardName;
EmptyNames(String objectName, String testCommand) {
this.objectName = objectName;
this.testCommand = testCommand;
}
@Override
public String toString() {
return cardName;
return objectName;
}
/**
* Face down choice for unit tests (use it instead empty string)
*/
public String getTestCommand() {
return this.testCommand;
}
public String getObjectName() {
return this.objectName;
}
public static boolean isEmptyName(String objectName) {
return objectName.equals(FACE_DOWN_CREATURE.toString())
|| objectName.equals(FACE_DOWN_TOKEN.toString())
|| objectName.equals(FACE_DOWN_CARD.toString());
return objectName.equals(FACE_DOWN_CREATURE.getObjectName())
|| objectName.equals(FACE_DOWN_TOKEN.getObjectName())
|| objectName.equals(FACE_DOWN_CARD.getObjectName());
}
public static String replaceTestCommandByObjectName(String searchCommand) {
EmptyNames res = Arrays.stream(values()).filter(e -> e.testCommand.equals(searchCommand)).findAny().orElse(null);
return res == null ? searchCommand : res.objectName;
}
}

View file

@ -248,7 +248,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
public String getName() {
if (name.isEmpty()) {
if (faceDown) {
return EmptyNames.FACE_DOWN_CREATURE.toString();
return EmptyNames.FACE_DOWN_CREATURE.getObjectName();
} else {
return "";
}

View file

@ -71,7 +71,7 @@ public class PermanentToken extends PermanentImpl {
@Override
public String getName() {
if (name.isEmpty()) {
return EmptyNames.FACE_DOWN_TOKEN.toString();
return EmptyNames.FACE_DOWN_TOKEN.getObjectName();
} else {
return name;
}

View file

@ -5199,7 +5199,7 @@ public abstract class PlayerImpl implements Player, Serializable {
}
visibleName = card.getLogName() + (card.isCopy() ? " (Copy)" : "");
} else {
visibleName = "a " + GameLog.getNeutralObjectIdName(EmptyNames.FACE_DOWN_CARD.toString(), card.getId());
visibleName = "a " + GameLog.getNeutralObjectIdName(EmptyNames.FACE_DOWN_CARD.getObjectName(), card.getId());
}
game.informPlayers(this.getLogName() + " moves " + visibleName
+ (fromZone != null ? " from " + fromZone.toString().toLowerCase(Locale.ENGLISH) : "")