Skip to content

Commit

Permalink
tests: removed and restricted empty commands for choices and targets,…
Browse files Browse the repository at this point in the history
… improved empty name usages in tests (use EmptyNames.xxx.getTestCommand and EmptyNames.xxx.getObjectName for face down objects)
  • Loading branch information
JayDi85 committed Oct 16, 2024
1 parent 06392fe commit a16215c
Show file tree
Hide file tree
Showing 42 changed files with 391 additions and 264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void testBlitzCopy() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void test_NormalPlay_ClientData_CostRulesVisible() {
});
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()
Expand All @@ -76,7 +76,7 @@ public void test_NormalPlay_ClientData_CostRulesVisible() {
.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());
Expand Down Expand Up @@ -145,7 +145,7 @@ public void test_NormalPlay_ClientData_CostRulesVisible() {
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()
Expand Down Expand Up @@ -193,7 +193,7 @@ public void testCostReduction() {
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public void testEchoTriggerClone() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void test_Simple_ManifestFromOwnLibrary() {
setStopAt(1, PhaseStep.END_TURN);
execute();

assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}

@Test
Expand All @@ -55,7 +55,7 @@ public void test_Simple_ManifestFromHand() {
setStopAt(1, PhaseStep.END_TURN);
execute();

assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerA, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);
}

@Test
Expand All @@ -75,8 +75,8 @@ public void test_Simple_ManifestTargetPlayer() {
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
Expand All @@ -90,32 +90,32 @@ public void test_Simple_ManifestFromOpponentLibrary() {
});

// 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());
}

Expand All @@ -137,12 +137,12 @@ private void runManifestThenBlink(String cardToManifest, String cardAfterBlink)
// 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) {
Expand Down Expand Up @@ -239,10 +239,10 @@ public void testETBTriggeredAbilities() {
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);
}

/**
Expand Down Expand Up @@ -271,8 +271,8 @@ public void testETBTriggeredAbilities2() {
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);
Expand Down Expand Up @@ -308,8 +308,8 @@ public void testETBTriggeredAbilities3() {
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);
Expand Down Expand Up @@ -346,8 +346,8 @@ public void testNylea() {
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);

}

Expand Down Expand Up @@ -382,8 +382,8 @@ public void testColorOfManifestedCardDoesNotCount() {
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);

}
Expand Down Expand Up @@ -413,7 +413,7 @@ public void testCardGetsExiledFaceUp() {
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();
Expand All @@ -425,7 +425,7 @@ public void testCardGetsExiledFaceUp() {
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")) {
Expand Down Expand Up @@ -464,7 +464,7 @@ public void testManifestAura() {
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);

}

Expand Down Expand Up @@ -504,7 +504,7 @@ public void testManifestMegamorph_TurnUpByMegamorphCost() {

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);
Expand Down Expand Up @@ -542,7 +542,7 @@ public void testManifestMegamorph_TurnUpBySimpleCost() {

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);
Expand Down Expand Up @@ -582,7 +582,7 @@ public void testManifestForest() {

assertGraveyardCount(playerB, "Silvercoat Lion", 1);

assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.toString(), 1);
assertPermanentCount(playerB, EmptyNames.FACE_DOWN_CREATURE.getTestCommand(), 1);

}

Expand Down Expand Up @@ -619,7 +619,7 @@ public void testWhisperwoodElemental() {
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);

}

Expand Down Expand Up @@ -653,7 +653,7 @@ public void testDiesTriggeredAbilitiesOfManifestedCreatures() {
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);
Expand Down Expand Up @@ -704,7 +704,7 @@ public void test_ManifestSorceryAndBlinkIt() {

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);
Expand Down Expand Up @@ -739,7 +739,7 @@ private PermanentView findFaceDownPermanent(Game game, TestPlayer viewFromPlayer
.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()
Expand Down Expand Up @@ -844,8 +844,8 @@ public void testJeskaiInfiltrator() {
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);
}
Expand Down
Loading

0 comments on commit a16215c

Please sign in to comment.