mirror of
https://github.com/magefree/mage.git
synced 2026-01-19 01:39:58 -08:00
more refactoring
This commit is contained in:
parent
45f810f4ed
commit
0c27211f11
39 changed files with 100 additions and 100 deletions
|
|
@ -33,12 +33,12 @@ public class FavorableWindsTest extends CardTestPlayerBase {
|
|||
int countSkySpirit = 0;
|
||||
int countMerfolkLooter = 0;
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(playerA.getId())) {
|
||||
if (permanent.getName().equals("Sky Spirit")) {
|
||||
if (permanent.hasName("Sky Spirit", currentGame)) {
|
||||
countSkySpirit++;
|
||||
// should get +1/+1, original is 2/2
|
||||
Assert.assertEquals("Power is not the same", 3, permanent.getPower().getValue());
|
||||
Assert.assertEquals("Toughness is not the same", 3, permanent.getToughness().getValue());
|
||||
} else if (permanent.getName().equals("Merfolk Looter")) {
|
||||
} else if (permanent.hasName("Merfolk Looter", currentGame)) {
|
||||
countMerfolkLooter++;
|
||||
// should NOT get +1/+1, original is 1/1
|
||||
Assert.assertEquals("Power is not the same", 1, permanent.getPower().getValue());
|
||||
|
|
@ -51,12 +51,12 @@ public class FavorableWindsTest extends CardTestPlayerBase {
|
|||
countSkySpirit = 0;
|
||||
countMerfolkLooter = 0;
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(playerB.getId())) {
|
||||
if (permanent.getName().equals("Sky Spirit")) {
|
||||
if (permanent.hasName("Sky Spirit", currentGame)) {
|
||||
countSkySpirit++;
|
||||
// should NOT +1/+1, original is 2/2
|
||||
Assert.assertEquals("Power is not the same", 2, permanent.getPower().getValue());
|
||||
Assert.assertEquals("Toughness is not the same", 2, permanent.getToughness().getValue());
|
||||
} else if (permanent.getName().equals("Merfolk Looter")) {
|
||||
} else if (permanent.hasName("Merfolk Looter", currentGame)) {
|
||||
countMerfolkLooter++;
|
||||
// should NOT get +1/+1, original is 1/1
|
||||
Assert.assertEquals("Power is not the same", 1, permanent.getPower().getValue());
|
||||
|
|
@ -88,12 +88,12 @@ public class FavorableWindsTest extends CardTestPlayerBase {
|
|||
int countSkySpirit = 0;
|
||||
int countMerfolkLooter = 0;
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(playerA.getId())) {
|
||||
if (permanent.getName().equals("Sky Spirit")) {
|
||||
if (permanent.hasName("Sky Spirit", currentGame)) {
|
||||
countSkySpirit++;
|
||||
// should get +1/+1, original is 2/2
|
||||
Assert.assertEquals("Power is not the same", 5, permanent.getPower().getValue());
|
||||
Assert.assertEquals("Toughness is not the same", 5, permanent.getToughness().getValue());
|
||||
} else if (permanent.getName().equals("Merfolk Looter")) {
|
||||
} else if (permanent.hasName("Merfolk Looter", currentGame)) {
|
||||
countMerfolkLooter++;
|
||||
// should NOT get +1/+1, original is 1/1
|
||||
Assert.assertEquals("Power is not the same", 1, permanent.getPower().getValue());
|
||||
|
|
@ -106,12 +106,12 @@ public class FavorableWindsTest extends CardTestPlayerBase {
|
|||
countSkySpirit = 0;
|
||||
countMerfolkLooter = 0;
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(playerB.getId())) {
|
||||
if (permanent.getName().equals("Sky Spirit")) {
|
||||
if (permanent.hasName("Sky Spirit", currentGame)) {
|
||||
countSkySpirit++;
|
||||
// should NOT +1/+1, original is 2/2
|
||||
Assert.assertEquals("Power is not the same", 2, permanent.getPower().getValue());
|
||||
Assert.assertEquals("Toughness is not the same", 2, permanent.getToughness().getValue());
|
||||
} else if (permanent.getName().equals("Merfolk Looter")) {
|
||||
} else if (permanent.hasName("Merfolk Looter", currentGame)) {
|
||||
countMerfolkLooter++;
|
||||
// should NOT get +1/+1, original is 1/1
|
||||
Assert.assertEquals("Power is not the same", 1, permanent.getPower().getValue());
|
||||
|
|
|
|||
|
|
@ -127,13 +127,13 @@ public class PaintersServantTest extends CardTestPlayerBase {
|
|||
Assert.assertEquals(false, card.getColor(currentGame).isBlue());
|
||||
}
|
||||
for (Card card : playerA.getGraveyard().getCards(currentGame)) {
|
||||
if (card.getName().equals("Silvercoat Lion")) {
|
||||
if (card.hasName("Silvercoat Lion", currentGame)) {
|
||||
Assert.assertEquals(true, card.getColor(currentGame).isWhite());
|
||||
Assert.assertEquals(false, card.getColor(currentGame).isBlue());
|
||||
}
|
||||
}
|
||||
for (Card card : playerB.getGraveyard().getCards(currentGame)) {
|
||||
if (card.getName().equals("Silvercoat Lion")) {
|
||||
if (card.hasName("Silvercoat Lion", currentGame)) {
|
||||
Assert.assertEquals(true, card.getColor(currentGame).isWhite());
|
||||
Assert.assertEquals(false, card.getColor(currentGame).isBlue());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class WonderTest extends CardTestPlayerBase {
|
|||
|
||||
// check no flying in graveyard
|
||||
for (Card card : playerA.getGraveyard().getCards(currentGame)) {
|
||||
if (card.getName().equals("Runeclaw Bear")) {
|
||||
if (card.hasName("Runeclaw Bear", currentGame)) {
|
||||
Assert.assertFalse(card.hasAbility(FlyingAbility.getInstance(), currentGame));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class ArtisanOfFormsTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, "Silvercoat Lion", 2);
|
||||
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(playerA.getId())) {
|
||||
if (permanent.getName().equals("Silvercoat Lion")) {
|
||||
if (permanent.hasName("Silvercoat Lion", currentGame)) {
|
||||
Assert.assertEquals("Creature has to have Cast + Heroic ability", 2, permanent.getAbilities().size());
|
||||
}
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ public class ArtisanOfFormsTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, "Silvercoat Lion", 3);
|
||||
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(playerA.getId())) {
|
||||
if (permanent.getName().equals("Silvercoat Lion")) {
|
||||
if (permanent.hasName("Silvercoat Lion", currentGame)) {
|
||||
Assert.assertEquals("Creature has to have Cast + Heroic ability", 2, permanent.getAbilities().size());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -634,12 +634,12 @@ public class CopySpellTest extends CardTestPlayerBase {
|
|||
|
||||
// counters checks, have to check if it's a card or a token since token copies have isCopy()=false
|
||||
int originalCounters = currentGame.getBattlefield().getAllActivePermanents().stream()
|
||||
.filter(p -> p.getName().equals("Grenzo, Dungeon Warden"))
|
||||
.filter(p -> p.hasName("Grenzo, Dungeon Warden", currentGame))
|
||||
.filter(p -> p instanceof PermanentCard)
|
||||
.mapToInt(p -> p.getCounters(currentGame).getCount(CounterType.P1P1))
|
||||
.sum();
|
||||
int copyCounters = currentGame.getBattlefield().getAllActivePermanents().stream()
|
||||
.filter(p -> p.getName().equals("Grenzo, Dungeon Warden"))
|
||||
.filter(p -> p.hasName("Grenzo, Dungeon Warden", currentGame))
|
||||
.filter(p -> p instanceof PermanentToken)
|
||||
.mapToInt(p -> p.getCounters(currentGame).getCount(CounterType.P1P1))
|
||||
.sum();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class EssenceOfTheWildCopyTest extends CardTestPlayerBase {
|
|||
|
||||
private Permanent findOriginPermanent(Game game, String permName) {
|
||||
for (Permanent perm : game.getBattlefield().getAllActivePermanents()) {
|
||||
if (!perm.isCopy() && perm.getName().equals(permName)) {
|
||||
if (!perm.isCopy() && perm.hasName(permName, currentGame)) {
|
||||
return perm;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class EssenceOfTheWildTest extends CardTestPlayerBase {
|
|||
|
||||
private Permanent findOriginPermanent(Game game, String permName) {
|
||||
for (Permanent perm : game.getBattlefield().getAllActivePermanents()) {
|
||||
if (!perm.isCopy() && perm.getName().equals(permName)) {
|
||||
if (!perm.isCopy() && perm.hasName(permName, currentGame)) {
|
||||
return perm;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ public class KikiJikiMirrorBreakerTest extends CardTestPlayerBase {
|
|||
|
||||
Permanent kikiCopy = null;
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, currentGame)) {
|
||||
if (permanent.getName().equals("Silvercoat Lion") && (permanent instanceof PermanentToken)) {
|
||||
if (permanent.hasName("Silvercoat Lion", currentGame) && (permanent instanceof PermanentToken)) {
|
||||
kikiCopy = permanent;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,27 +23,24 @@ public class TokenCopyTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, prowler, prowlerCount);
|
||||
assertPermanentCount(playerA, predator, predatorCount);
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
|
||||
switch (permanent.getName()) {
|
||||
case prowler:
|
||||
Assert.assertEquals("Power of " + prowler + " should be 2", 2, permanent.getPower().getValue());
|
||||
Assert.assertEquals("Toughness of " + prowler + " should be 1", 1, permanent.getToughness().getValue());
|
||||
Assert.assertEquals(prowler + " should be green", ObjectColor.GREEN, permanent.getColor(currentGame));
|
||||
Assert.assertTrue(prowler + " should be a Werewolf", permanent.hasSubtype(SubType.WEREWOLF, currentGame));
|
||||
Assert.assertTrue(prowler + " should be a Horror", permanent.hasSubtype(SubType.HORROR, currentGame));
|
||||
Assert.assertFalse(prowler + " should not be an Eldrazi", permanent.hasSubtype(SubType.ELDRAZI, currentGame));
|
||||
Assert.assertEquals(prowler + " should have mana value 1", 1, permanent.getManaValue());
|
||||
Assert.assertFalse(prowler + " should not be transformed", permanent.isTransformed());
|
||||
break;
|
||||
case predator:
|
||||
Assert.assertEquals("Power of " + predator + " should be 4", 4, permanent.getPower().getValue());
|
||||
Assert.assertEquals("Toughness of " + predator + " should be 4", 4, permanent.getToughness().getValue());
|
||||
Assert.assertTrue(predator + " should be colorless", permanent.getColor(currentGame).isColorless());
|
||||
Assert.assertTrue(predator + " should be an Eldrazi", permanent.hasSubtype(SubType.ELDRAZI, currentGame));
|
||||
Assert.assertTrue(predator + " should be a Werewolf", permanent.hasSubtype(SubType.WEREWOLF, currentGame));
|
||||
Assert.assertFalse(predator + " should not be a Horror", permanent.hasSubtype(SubType.HORROR, currentGame));
|
||||
Assert.assertEquals(predator + " should have mana value 1", 1, permanent.getManaValue());
|
||||
Assert.assertTrue(prowler + " should be transformed", permanent.isTransformed());
|
||||
break;
|
||||
if (permanent.hasName(prowler, currentGame)) {
|
||||
Assert.assertEquals("Power of " + prowler + " should be 2", 2, permanent.getPower().getValue());
|
||||
Assert.assertEquals("Toughness of " + prowler + " should be 1", 1, permanent.getToughness().getValue());
|
||||
Assert.assertEquals(prowler + " should be green", ObjectColor.GREEN, permanent.getColor(currentGame));
|
||||
Assert.assertTrue(prowler + " should be a Werewolf", permanent.hasSubtype(SubType.WEREWOLF, currentGame));
|
||||
Assert.assertTrue(prowler + " should be a Horror", permanent.hasSubtype(SubType.HORROR, currentGame));
|
||||
Assert.assertFalse(prowler + " should not be an Eldrazi", permanent.hasSubtype(SubType.ELDRAZI, currentGame));
|
||||
Assert.assertEquals(prowler + " should have mana value 1", 1, permanent.getManaValue());
|
||||
Assert.assertFalse(prowler + " should not be transformed", permanent.isTransformed());
|
||||
} else if (permanent.hasName(predator, currentGame)) {
|
||||
Assert.assertEquals("Power of " + predator + " should be 4", 4, permanent.getPower().getValue());
|
||||
Assert.assertEquals("Toughness of " + predator + " should be 4", 4, permanent.getToughness().getValue());
|
||||
Assert.assertTrue(predator + " should be colorless", permanent.getColor(currentGame).isColorless());
|
||||
Assert.assertTrue(predator + " should be an Eldrazi", permanent.hasSubtype(SubType.ELDRAZI, currentGame));
|
||||
Assert.assertTrue(predator + " should be a Werewolf", permanent.hasSubtype(SubType.WEREWOLF, currentGame));
|
||||
Assert.assertFalse(predator + " should not be a Horror", permanent.hasSubtype(SubType.HORROR, currentGame));
|
||||
Assert.assertEquals(predator + " should have mana value 1", 1, permanent.getManaValue());
|
||||
Assert.assertTrue(prowler + " should be transformed", permanent.isTransformed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ public class CollectEvidenceTest extends CardTestPlayerBase {
|
|||
|
||||
// before
|
||||
runCode("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||
Card card = playerA.getHand().getCards(game).stream().filter(c -> c.getName().equals(bite)).findFirst().orElse(null);
|
||||
Card card = playerA.getHand().getCards(game).stream().filter(c -> c.hasName(bite, currentGame)).findFirst().orElse(null);
|
||||
Assert.assertNotNull(card);
|
||||
Ability ability = card.getAbilities(game).stream().filter(a -> a instanceof CollectEvidenceAbility).findFirst().orElse(null);
|
||||
Assert.assertNotNull(ability);
|
||||
|
|
|
|||
|
|
@ -1051,7 +1051,7 @@ public class ModalDoubleFacedCardsTest extends CardTestPlayerBase {
|
|||
runCode("check side 2", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||
PermanentToken permanent = (PermanentToken) game.getBattlefield().getAllPermanents()
|
||||
.stream()
|
||||
.filter(p -> p.getName().equals("Tergrid, God of Fright"))
|
||||
.filter(p -> p.hasName("Tergrid, God of Fright", currentGame))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
Assert.assertNotNull(permanent);
|
||||
|
|
@ -1080,7 +1080,7 @@ public class ModalDoubleFacedCardsTest extends CardTestPlayerBase {
|
|||
GameView gameView = getGameView(playerA);
|
||||
PermanentView permanentView = gameView.getMyPlayer().getBattlefield().values()
|
||||
.stream()
|
||||
.filter(p -> p.getName().equals("Tergrid, God of Fright"))
|
||||
.filter(p -> p.hasName("Tergrid, God of Fright", currentGame))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
Assert.assertNotNull(permanentView);
|
||||
|
|
|
|||
|
|
@ -427,7 +427,7 @@ public class CostModificationTest extends CardTestPlayerBase {
|
|||
|
||||
// Huatli: check x cost changes
|
||||
runCode("check x cost", 3, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||
Permanent huatli = game.getBattlefield().getAllActivePermanents().stream().filter(p -> p.getName().equals("Huatli, Warrior Poet")).findFirst().orElse(null);
|
||||
Permanent huatli = game.getBattlefield().getAllActivePermanents().stream().filter(p -> p.hasName("Huatli, Warrior Poet", currentGame)).findFirst().orElse(null);
|
||||
Assert.assertNotNull("must have huatli on battlefield", huatli);
|
||||
LoyaltyAbility ability = (LoyaltyAbility) huatli.getAbilities(game).stream().filter(a -> a.getRule().startsWith("-X: ")).findFirst().orElse(null);
|
||||
Assert.assertNotNull("must have loyalty ability", ability);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class DungeonTest extends CardTestPlayerBase {
|
|||
return;
|
||||
}
|
||||
Assert.assertNotNull("Dungeon should not be null", dungeon);
|
||||
Assert.assertEquals("Dungeon should be " + dungeonName, dungeonName, dungeon.getName());
|
||||
Assert.assertTrue("Dungeon should be " + dungeonName, dungeon.hasName(dungeonName, currentGame));
|
||||
Assert.assertEquals(
|
||||
"Current room is " + roomName,
|
||||
roomName, dungeon.getCurrentRoom().getName()
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public class EmblemsTest extends CardTestPlayerBase {
|
|||
|
||||
boolean found = false;
|
||||
for (Card card : playerA.getHand().getCards(currentGame)) {
|
||||
if (card.getName().equals("Elite Vanguard")) {
|
||||
if (card.hasName("Elite Vanguard", currentGame)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package org.mage.test.cards.emblems;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.command.emblems.TheRingEmblem;
|
||||
|
|
@ -33,15 +32,15 @@ public class TheRingEmblemTest extends CardTestPlayerBase {
|
|||
boolean hasEmblem = ringEmblems.stream().anyMatch(e -> e.isControlledBy(player.getId()));
|
||||
Assert.assertEquals(info + " - ring emblem for " + player.getName(), needEmblem, hasEmblem);
|
||||
|
||||
String hasBearer = Optional.ofNullable(player.getRingBearer(currentGame)).map(MageObject::getName).orElse(null);
|
||||
Assert.assertEquals(info + " - ring bearer for " + player.getName(), needBearer, hasBearer);
|
||||
boolean hasBearer = Optional.ofNullable(player.getRingBearer(currentGame)).map(permanent -> permanent.hasName(needBearer, currentGame)).orElse(false);
|
||||
Assert.assertTrue(info + " - ring bearer for " + player.getName(), hasBearer);
|
||||
}
|
||||
|
||||
private void assertPermanent(String info, Player player, String needName, boolean needLegendary) {
|
||||
Permanent permanent = currentGame.getBattlefield().getAllActivePermanents(player.getId())
|
||||
.stream()
|
||||
.filter(p -> p.isControlledBy(player.getId()))
|
||||
.filter(p -> p.getName().equals(needName))
|
||||
.filter(p -> p.hasName(needName, currentGame))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
Assert.assertNotNull(info + " - permanent " + needName + " for player " + player.getName() + " must exist", permanent);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import org.junit.Test;
|
|||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class EnchantingGraveyardCardsTest extends CardTestPlayerBase {
|
||||
|
|
@ -50,7 +49,7 @@ public class EnchantingGraveyardCardsTest extends CardTestPlayerBase {
|
|||
if (spellweaver != null) {
|
||||
attachedToCard = playerB.getGraveyard().get(spellweaver.getAttachedTo(), currentGame);
|
||||
}
|
||||
Assert.assertTrue(SPELLWEAVER_VOLUTE + " has to be attached to Lightning Bolt in graveyard", attachedToCard != null && attachedToCard.getName().equals(LIGHTNING_BOLT));
|
||||
Assert.assertTrue(SPELLWEAVER_VOLUTE + " has to be attached to Lightning Bolt in graveyard", attachedToCard != null && attachedToCard.hasName(LIGHTNING_BOLT, currentGame));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -94,7 +93,7 @@ public class EnchantingGraveyardCardsTest extends CardTestPlayerBase {
|
|||
if (spellweaver != null) {
|
||||
attachedToCard = playerA.getGraveyard().get(spellweaver.getAttachedTo(), currentGame);
|
||||
}
|
||||
Assert.assertTrue(SPELLWEAVER_VOLUTE + " has to be attached to Aerial Volley in graveyard", attachedToCard != null && attachedToCard.getName().equals("Aerial Volley"));
|
||||
Assert.assertTrue(SPELLWEAVER_VOLUTE + " has to be attached to Aerial Volley in graveyard", attachedToCard != null && attachedToCard.hasName("Aerial Volley", currentGame));
|
||||
|
||||
assertHandCount(playerA, 1);
|
||||
|
||||
|
|
@ -139,7 +138,7 @@ public class EnchantingGraveyardCardsTest extends CardTestPlayerBase {
|
|||
assertGraveyardCount(playerA, SPELLWEAVER_VOLUTE, 1);
|
||||
|
||||
for (Card card : currentGame.getExile().getAllCards(currentGame)) {
|
||||
if (card.getName().equals(LIGHTNING_BOLT)) {
|
||||
if (card.hasName(LIGHTNING_BOLT, currentGame)) {
|
||||
Assert.assertTrue(LIGHTNING_BOLT + " may not have any attachments", card.getAttachments().isEmpty());
|
||||
|
||||
}
|
||||
|
|
@ -183,7 +182,7 @@ public class EnchantingGraveyardCardsTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, SPELLWEAVER_VOLUTE, 0);
|
||||
|
||||
for (Card card : playerB.getGraveyard().getCards(currentGame)) {
|
||||
if (card.getName().equals(LIGHTNING_BOLT)) {
|
||||
if (card.hasName(LIGHTNING_BOLT, currentGame)) {
|
||||
Assert.assertTrue(LIGHTNING_BOLT + " may not have any attachments", card.getAttachments().isEmpty());
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class BaneAlleyBrokerTest extends CardTestPlayerBase {
|
|||
assertExileCount("Goblin Roughrider", 1);
|
||||
|
||||
for (Card card : currentGame.getExile().getAllCards(currentGame)) {
|
||||
if (card.getName().equals("Goblin Roughrider")) {
|
||||
if (card.hasName("Goblin Roughrider", currentGame)) {
|
||||
Assert.assertTrue("Exiled card is not face down", card.isFaceDown(currentGame));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class SummonersEggTest extends CardTestPlayerBase {
|
|||
|
||||
assertExileCount("Goblin Roughrider", 1);
|
||||
for (Card card : currentGame.getExile().getAllCards(currentGame)) {
|
||||
if (card.getName().equals("Goblin Roughrider")) {
|
||||
if (card.hasName("Goblin Roughrider", currentGame)) {
|
||||
Assert.assertTrue("Exiled card is not face down", card.isFaceDown(currentGame));
|
||||
}
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ public class SummonersEggTest extends CardTestPlayerBase {
|
|||
assertExileCount("Goblin Roughrider", 0);
|
||||
assertPermanentCount(playerA, "Goblin Roughrider", 1);
|
||||
for (Permanent p : currentGame.getBattlefield().getAllActivePermanents()) {
|
||||
if (p.getName().equals("Goblin Roughrider")) {
|
||||
if (p.hasName("Goblin Roughrider", currentGame)) {
|
||||
Assert.assertTrue("Permanent is not face up", !p.isFaceDown(currentGame));
|
||||
}
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ public class SummonersEggTest extends CardTestPlayerBase {
|
|||
|
||||
assertExileCount("Forest", 1);
|
||||
for (Card card : currentGame.getExile().getAllCards(currentGame)) {
|
||||
if (card.getName().equals("Forest")) {
|
||||
if (card.hasName("Forest", currentGame)) {
|
||||
Assert.assertTrue("Exiled card is not face up", !card.isFaceDown(currentGame));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class PalisadeGiantTest extends CardTestPlayerBase {
|
|||
|
||||
int damage = 0;
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(playerA.getId())) {
|
||||
if (permanent.getName().equals("Palisade Giant")) {
|
||||
if (permanent.hasName("Palisade Giant", currentGame)) {
|
||||
damage += permanent.getDamage();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class RootpathPurifierTest extends CardTestPlayerBase {
|
|||
playerA.getHand()
|
||||
.getCards(currentGame)
|
||||
.stream()
|
||||
.filter(card -> tree.equals(card.getName()))
|
||||
.filter(card -> card.hasName(tree, currentGame))
|
||||
.noneMatch(card -> card.isBasic(currentGame))
|
||||
);
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ public class RootpathPurifierTest extends CardTestPlayerBase {
|
|||
playerA.getLibrary()
|
||||
.getCards(currentGame)
|
||||
.stream()
|
||||
.filter(card -> tree.equals(card.getName()))
|
||||
.filter(card -> card.hasName(tree, currentGame))
|
||||
.noneMatch(card -> card.isBasic(currentGame))
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class MarathWillOfTheWildTest extends CardTestCommanderDuelBase {
|
|||
ManaPaidSourceWatcher watcher = game.getState().getWatcher(ManaPaidSourceWatcher.class);
|
||||
Permanent perm = game.getBattlefield().getAllPermanents()
|
||||
.stream()
|
||||
.filter(p -> p.getName().equals("Marath, Will of the Wild"))
|
||||
.filter(p -> p.hasName("Marath, Will of the Wild", currentGame))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
Assert.assertNotNull(perm);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class DustOfMomentsTest extends CardTestPlayerBase {
|
|||
Assert.assertEquals(2, activeCreatures.size());
|
||||
|
||||
for (final Permanent creature : activeCreatures) {
|
||||
Assert.assertEquals("Chronozoa", creature.getName());
|
||||
Assert.assertTrue(creature.hasName("Chronozoa", currentGame));
|
||||
Assert.assertEquals(3, creature.getCounters(currentGame).getCount(CounterType.TIME));
|
||||
}
|
||||
// Check time counters on kraken
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class TravelersCloakTest extends CardTestPlayerBase {
|
|||
runCode("check blocking", 1, PhaseStep.DECLARE_BLOCKERS, playerB, (info, player, game) -> {
|
||||
Permanent blocker = game.getBattlefield().getAllActivePermanents()
|
||||
.stream()
|
||||
.filter(p -> p.getName().equals("Kitesail Corsair"))
|
||||
.filter(p -> p.hasName("Kitesail Corsair", currentGame))
|
||||
.findFirst()
|
||||
.get();
|
||||
Assert.assertFalse("Grizzly Bears must be protected from blocking by Kitesail Corsair",
|
||||
|
|
@ -50,4 +50,4 @@ public class TravelersCloakTest extends CardTestPlayerBase {
|
|||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class WitchKingOfAngmarTest extends CardTestPlayerBase {
|
|||
|
||||
runCode("check ring bear", 2, PhaseStep.POSTCOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||
Assert.assertNotNull(playerA.getRingBearer(game));
|
||||
Assert.assertEquals(witchKing, playerA.getRingBearer(game).getName());
|
||||
Assert.assertTrue(playerA.getRingBearer(game).hasName(witchKing, currentGame));
|
||||
Assert.assertNull(playerB.getRingBearer(game));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class GristTheHungerTideTest extends CardTestPlayerBase {
|
|||
execute();
|
||||
|
||||
for (Card card : currentGame.getCards()) {
|
||||
if (!card.getName().equals(grist)) {
|
||||
if (!card.hasName(grist, currentGame)) {
|
||||
continue;
|
||||
}
|
||||
Zone zone = currentGame.getState().getZone(card.getId());
|
||||
|
|
@ -56,7 +56,7 @@ public class GristTheHungerTideTest extends CardTestPlayerBase {
|
|||
execute();
|
||||
|
||||
for (Card card : currentGame.getCards()) {
|
||||
if (!card.getName().equals(grist)) {
|
||||
if (!card.hasName(grist, currentGame)) {
|
||||
continue;
|
||||
}
|
||||
Assert.assertEquals("", Zone.EXILED, currentGame.getState().getZone(card.getId()));
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public class ShiftingWoodlandTest extends CardTestPlayerBase {
|
|||
castSpell(1, PhaseStep.END_COMBAT, playerA, "Shoot the Sheriff", "Grizzly Bears", true);
|
||||
|
||||
runCode("check that the copy effect ended", 1, PhaseStep.END_COMBAT, playerA, (info, player, game) -> {
|
||||
Card card = player.getGraveyard().getCards(game).stream().filter(c -> c.getName().equals(woodland)).findFirst().orElse(null);
|
||||
Card card = player.getGraveyard().getCards(game).stream().filter(c -> c.hasName(woodland, currentGame)).findFirst().orElse(null);
|
||||
if (card == null) {
|
||||
Assert.fail("Shifting Woodland is not in the graveyard");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class StoryweaveTest extends CardTestPlayerBase {
|
|||
.getBattlefield()
|
||||
.getAllActivePermanents()
|
||||
.stream()
|
||||
.filter(permanent -> "Centaur Token".equals(permanent.getName()))
|
||||
.filter(permanent -> permanent.hasName("Centaur Token", currentGame))
|
||||
.noneMatch(permanent -> permanent.getCounters(currentGame).getCount(CounterType.P1P1) != 2));
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ public class StoryweaveTest extends CardTestPlayerBase {
|
|||
.getBattlefield()
|
||||
.getAllActivePermanents()
|
||||
.stream()
|
||||
.filter(permanent -> "Centaur Token".equals(permanent.getName()))
|
||||
.filter(permanent -> permanent.hasName("Centaur Token", currentGame))
|
||||
.noneMatch(permanent -> permanent.getCounters(currentGame).getCount(CounterType.P1P1) != 0));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ public class ChronozoaTest extends CardTestPlayerBase {
|
|||
|
||||
for (final Permanent creature : creatures) {
|
||||
// Make sure the creatures are Chronozoa tokens
|
||||
Assert.assertEquals("Chronozoa", creature.getName());
|
||||
Assert.assertEquals("Chronozoa has to be a token", true, creature instanceof PermanentToken);
|
||||
Assert.assertTrue(creature.hasName("Chronozoa", currentGame));
|
||||
Assert.assertTrue("Chronozoa has to be a token", creature instanceof PermanentToken);
|
||||
|
||||
// Make sure each token has 2 time counters
|
||||
final Counters counters = creature.getCounters(currentGame);
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class CastThroughTimeTest extends CardTestPlayerBase {
|
|||
|
||||
boolean found = false;
|
||||
for (Card card : currentGame.getPlayer(playerA.getId()).getHand().getCards(currentGame)) {
|
||||
if (card.getName().equals("Lightning Bolt")) {
|
||||
if (card.hasName("Lightning Bolt", currentGame)) {
|
||||
for (String rule : card.getRules(currentGame)) {
|
||||
if (rule.startsWith("Rebound")) {
|
||||
found = true;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class TadeasJuniperAscendantTest extends CardTestPlayerBase {
|
|||
private Permanent getBlocker(String blocker, mage.game.Game game) {
|
||||
return game.getBattlefield().getAllActivePermanents()
|
||||
.stream()
|
||||
.filter(p -> p.getName().equals(blocker))
|
||||
.filter(p -> p.hasName(blocker, currentGame))
|
||||
.findFirst()
|
||||
.get();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class GodEternalDiesTriggeredAbilityTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, godEternalBontu, 0);
|
||||
assertGraveyardCount(playerA, godEternalBontu, 0);
|
||||
Card card = currentGame.getCard(playerA.getLibrary().getCardList().get(2));
|
||||
Assert.assertEquals(card.getName(), godEternalBontu);
|
||||
Assert.assertTrue(card.hasName(godEternalBontu, currentGame));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -54,7 +54,7 @@ public class GodEternalDiesTriggeredAbilityTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, godEternalBontu, 0);
|
||||
assertExileCount(playerA, godEternalBontu, 0);
|
||||
Card card = currentGame.getCard(playerA.getLibrary().getCardList().get(2));
|
||||
Assert.assertEquals(card.getName(), godEternalBontu);
|
||||
Assert.assertTrue(card.hasName(godEternalBontu, currentGame));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class ReturnToHandEffectsTest extends CardTestPlayerBase {
|
|||
.getAllActivePermanents()
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(p -> p.getName().equals(cardName))
|
||||
.filter(p -> p.hasName(cardName, currentGame))
|
||||
.findFirst();
|
||||
if (!optPermanent.isPresent()) {
|
||||
Assert.fail(info + " — no permanent named \"" + cardName + "\" found on battlefield");
|
||||
|
|
@ -133,7 +133,7 @@ public class ReturnToHandEffectsTest extends CardTestPlayerBase {
|
|||
.getCards(game)
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(p -> p.getName().equals(cardName))
|
||||
.filter(p -> p.hasName(cardName, currentGame))
|
||||
.findFirst();
|
||||
if (!optCard.isPresent()) {
|
||||
Assert.fail(info + " — no card named \"" + cardName + "\" found in graveyard");
|
||||
|
|
@ -152,7 +152,7 @@ public class ReturnToHandEffectsTest extends CardTestPlayerBase {
|
|||
.getCards(game)
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(p -> p.getName().equals(cardName))
|
||||
.filter(p -> p.hasName(cardName, currentGame))
|
||||
.findFirst();
|
||||
if (!optCard.isPresent()) {
|
||||
Assert.fail(info + " — no card named \"" + cardName + "\" found in hand");
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class MulliganCardSorterTest extends CardTestPlayerBase {
|
|||
.stream()
|
||||
.map(name -> currentGame.getCards()
|
||||
.stream()
|
||||
.filter(c -> c.getName().equals(name))
|
||||
.filter(c -> c.hasName(name, currentGame))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new IllegalStateException("Can't find testing card " + name))
|
||||
)
|
||||
|
|
@ -110,4 +110,4 @@ public class MulliganCardSorterTest extends CardTestPlayerBase {
|
|||
));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class PlayableEmblemsTest extends CardTestCommander4Players {
|
|||
// playable commander
|
||||
UUID needObjectId = game.getCommandersIds(playerA, CommanderCardType.COMMANDER_OR_OATHBREAKER, false)
|
||||
.stream()
|
||||
.filter(id -> game.getObject(id).getName().equals("Balduvian Bears"))
|
||||
.filter(id -> game.getObject(id).hasName("Balduvian Bears", currentGame))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
Assert.assertNotNull(needObjectId);
|
||||
|
|
@ -63,7 +63,7 @@ public class PlayableEmblemsTest extends CardTestCommander4Players {
|
|||
// non playable commander
|
||||
needObjectId = game.getCommandersIds(playerA, CommanderCardType.COMMANDER_OR_OATHBREAKER, false)
|
||||
.stream()
|
||||
.filter(id -> game.getObject(id).getName().equals("Goblin Arsonist"))
|
||||
.filter(id -> game.getObject(id).hasName("Goblin Arsonist", currentGame))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
Assert.assertNotNull(needObjectId);
|
||||
|
|
@ -74,7 +74,7 @@ public class PlayableEmblemsTest extends CardTestCommander4Players {
|
|||
.stream()
|
||||
.filter(obj -> obj instanceof Emblem)
|
||||
.filter(obj -> obj.isControlledBy(playerA.getId()))
|
||||
.filter(obj -> obj.getName().equals("Emblem Momir"))
|
||||
.filter(obj -> obj.hasName("Emblem Momir", currentGame))
|
||||
.map(MageItem::getId)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ public class TokenImagesTest extends CardTestPlayerBase {
|
|||
Map<String, List<Card>> realServerStats = new LinkedHashMap<>();
|
||||
currentGame.getBattlefield().getAllPermanents()
|
||||
.stream()
|
||||
.filter(card -> card.getName().equals(tokenName))
|
||||
.filter(card -> card.hasName(tokenName, currentGame))
|
||||
.filter(card -> card instanceof PermanentToken)
|
||||
.sorted(Comparator.comparing(Card::getExpansionSetCode))
|
||||
.forEach(card -> {
|
||||
|
|
@ -267,7 +267,7 @@ public class TokenImagesTest extends CardTestPlayerBase {
|
|||
private void assert_TokenOrCardImageNumber(String tokenOrCardName, List<Integer> needUniqueImages) {
|
||||
Set<Integer> serverStats = currentGame.getBattlefield().getAllPermanents()
|
||||
.stream()
|
||||
.filter(card -> card.getName().equals(tokenOrCardName))
|
||||
.filter(card -> card.hasName(tokenOrCardName, currentGame))
|
||||
.filter(card -> card instanceof MageObjectImpl)
|
||||
.sorted(Comparator.comparing(Card::getExpansionSetCode))
|
||||
.map(card -> (MageObjectImpl) card)
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ public class TokenNamesTest extends CardTestPlayerBase {
|
|||
|
||||
@Test
|
||||
public void test_Rules_111_4_AutoGeneratedName() {
|
||||
Assert.assertEquals("Human Cleric Token", new CreatureToken(2, 2, "", SubType.HUMAN, SubType.CLERIC).getName());
|
||||
Assert.assertEquals("Warrior Token", new CreatureToken(2, 2, "", SubType.WARRIOR).getName());
|
||||
Assert.assertEquals("Custom Name", new CreatureToken(2, 2, "", SubType.WARRIOR).withName("Custom Name").getName());
|
||||
Assert.assertTrue(new CreatureToken(2, 2, "", SubType.HUMAN, SubType.CLERIC).hasName("Human Cleric Token", currentGame));
|
||||
Assert.assertTrue(new CreatureToken(2, 2, "", SubType.WARRIOR).hasName("Warrior Token", currentGame));
|
||||
Assert.assertTrue(new CreatureToken(2, 2, "", SubType.WARRIOR).withName("Custom Name").hasName("Custom Name", currentGame));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import mage.game.draft.ReshuffledSet;
|
|||
import mage.sets.*;
|
||||
import mage.util.CardUtil;
|
||||
import org.junit.Assert;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
@ -23,6 +22,12 @@ import org.mage.test.serverside.base.MageTestPlayerBase;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* @author nigelzor, JayDi85
|
||||
*/
|
||||
|
|
@ -50,7 +55,7 @@ public class BoosterGenerationTest extends MageTestPlayerBase {
|
|||
|
||||
private static boolean contains(List<Card> cards, String name, String code) {
|
||||
return cards.stream().anyMatch((card)
|
||||
-> (card.getName().equals(name)
|
||||
-> (card.hasName(name, currentGame)
|
||||
&& (code == null || card.getExpansionSetCode().equals(code)))
|
||||
);
|
||||
}
|
||||
|
|
@ -331,22 +336,22 @@ public class BoosterGenerationTest extends MageTestPlayerBase {
|
|||
case 2:
|
||||
assertEquals(
|
||||
"Booster can't have two snow lands unless one is Shimmerdrift Vale or Faceless Haven", 1,
|
||||
snowLands.stream().filter(card -> card.getName().equals("Shimmerdrift Vale") || card.getName().equals("Faceless Haven")).count()
|
||||
snowLands.stream().filter(card -> card.hasName("Shimmerdrift Vale", currentGame) || card.hasName("Faceless Haven", currentGame)).count()
|
||||
);
|
||||
assertEquals(
|
||||
"Booster can't have two snow lands unless one is not Shimmerdrift Vale or Faceless Haven", 1,
|
||||
snowLands.stream().filter(card -> !card.getName().equals("Shimmerdrift Vale") && !card.getName().equals("Faceless Haven")).count()
|
||||
snowLands.stream().filter(card -> !card.hasName("Shimmerdrift Vale", currentGame) && !card.hasName("Faceless Haven", currentGame)).count()
|
||||
);
|
||||
break;
|
||||
case 3:
|
||||
assertEquals("Booster can't have three snow lands unless one is Shimmerdrift Vale", 1,
|
||||
snowLands.stream().filter(card -> card.getName().equals("Shimmerdrift Vale")).count()
|
||||
snowLands.stream().filter(card -> card.hasName("Shimmerdrift Vale", currentGame)).count()
|
||||
);
|
||||
assertEquals("Booster can't have three snow lands unless one is Faceless Haven", 1,
|
||||
snowLands.stream().filter(card -> card.getName().equals("Faceless Haven")).count()
|
||||
snowLands.stream().filter(card -> card.hasName("Faceless Haven", currentGame)).count()
|
||||
);
|
||||
assertEquals("Booster can't have three snow lands unless one is not Shimmerdrift Vale or Faceless Haven", 1,
|
||||
snowLands.stream().filter(card -> !card.getName().equals("Shimmerdrift Vale") && !card.getName().equals("Faceless Haven")).count()
|
||||
snowLands.stream().filter(card -> !card.hasName("Shimmerdrift Vale", currentGame) && !card.hasName("Faceless Haven", currentGame)).count()
|
||||
);
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -91,13 +91,13 @@ public class AddCardApiTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, "Memorial to Glory", 2);
|
||||
getBattlefieldCards(playerA)
|
||||
.stream()
|
||||
.filter(info -> info.getCard().getName().equals("Memorial to Glory"))
|
||||
.filter(info -> info.getCard().hasName("Memorial to Glory", currentGame))
|
||||
.forEach(info -> Assert.assertEquals("40K", info.getCard().getExpansionSetCode()));
|
||||
|
||||
assertPermanentCount(playerA, "Plains", 2);
|
||||
getBattlefieldCards(playerA)
|
||||
.stream()
|
||||
.filter(info -> info.getCard().getName().equals("Plains"))
|
||||
.filter(info -> info.getCard().hasName("Plains", currentGame))
|
||||
.forEach(info -> Assert.assertEquals("PANA", info.getCard().getExpansionSetCode()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class SearchLibraryPutInHandOrOnBattlefieldEffect extends SearchEffect {
|
|||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
if (card.getName().equals(nameToPutOnBattlefield)) {
|
||||
if (card.hasName(nameToPutOnBattlefield, currentGame)) {
|
||||
askToPutOntoBf = true;
|
||||
cardToPutOnBf = card;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue