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

@ -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) : "")