revert accidentally reverted changes

This commit is contained in:
theelk801 2023-04-30 11:29:50 -04:00
parent edb5c99df8
commit b3a421d094

View file

@ -87,13 +87,18 @@ public class VerifyCardDataTest {
"plainswalk", "islandwalk", "swampwalk", "mountainwalk", "forestwalk", "myriad", "prowess", "convoke"
);
private static final List<String> doubleNumbers = new ArrayList<>();
private static final List<String> doubleWords = new ArrayList<>();
{
// numbers
for (int i = 1; i <= 9; i++) {
String s = CardUtil.numberToText(i).toLowerCase(Locale.ENGLISH);
doubleNumbers.add(s + " " + s);
doubleWords.add(s + " " + s);
}
// additional checks
doubleWords.add(" an an ");
doubleWords.add(" a a ");
}
static {
@ -279,7 +284,7 @@ public class VerifyCardDataTest {
}
@Test
public void test_verifyCards() throws IOException {
public void test_verifyCards() {
int cardIndex = 0;
for (Card card : CardScanner.getAllCards()) {
cardIndex++;
@ -1684,15 +1689,15 @@ public class VerifyCardDataTest {
fail(card, "abilities", "mutate cards aren't implemented and shouldn't be available");
}
// special check: duplicated numbers in ability text (wrong target/filter usage)
// special check: duplicated words in ability text (wrong target/filter usage)
// example: You may exile __two two__ blue cards
// possible fixes:
// - remove numbers from filter's text
// - use target.getDescription() in ability instead target.getTargetName()
for (String rule : card.getRules()) {
for (String doubleNumber : doubleNumbers) {
if (rule.contains(doubleNumber)) {
fail(card, "abilities", "duplicated numbers: " + rule);
for (String doubleNumber : doubleWords) {
if (rule.toLowerCase(Locale.ENGLISH).contains(doubleNumber)) {
fail(card, "abilities", "duplicated numbers/words: " + rule);
}
}
}
@ -1792,18 +1797,29 @@ public class VerifyCardDataTest {
}
@Test
public void test_showCardInfo() throws Exception {
// debug only: show direct card info (takes it from class file, not from db repository)
// can check multiple cards at once, example: name1;name2;name3
String cardNames = "Spark Double";
public void test_showCardInfo() {
// debug only: show direct card info from class file without db-recreate
// - search by card name: Spark Double
// - search by class name: SparkDouble
// - multiple searches: name1;class2;name3
String cardSearches = "Spark Double";
CardScanner.scan();
Arrays.stream(cardNames.split(";")).forEach(cardName -> {
cardName = cardName.trim();
CardSetInfo testSet = new CardSetInfo(cardName, "test", "123", Rarity.COMMON);
CardInfo cardInfo = CardRepository.instance.findCard(cardName);
Arrays.stream(cardSearches.split(";")).forEach(searchName -> {
searchName = searchName.trim();
CardInfo cardInfo = CardRepository.instance.findCard(searchName);
if (cardInfo == null) {
Assert.fail("Can't find card name: " + cardName);
String searchClass = String.format("mage.cards.%s.%s",
searchName.substring(0, 1).toLowerCase(Locale.ENGLISH),
searchName);
cardInfo = CardRepository.instance.findCardsByClass(searchClass)
.stream()
.findFirst()
.orElse(null);
}
if (cardInfo == null) {
Assert.fail("Can't find card by name or class: " + searchName);
}
CardSetInfo testSet = new CardSetInfo(cardInfo.getName(), "test", "123", Rarity.COMMON);
Card card = CardImpl.createCard(cardInfo.getClassName(), testSet);
System.out.println();
System.out.println(card.getName() + " " + card.getManaCost().getText());
@ -2197,11 +2213,12 @@ public class VerifyCardDataTest {
@Test
public void test_checkCardConstructors() {
// create all cards, can catch additional verify and runtime checks from abilities and effects
// example: wrong code usage errors
Collection<String> errorsList = new ArrayList<>();
Collection<ExpansionSet> sets = Sets.getInstance().values();
for (ExpansionSet set : sets) {
for (ExpansionSet.SetCardInfo setInfo : set.getSetCardInfo()) {
// catch cards creation errors and report (e.g. on wrong card code or construction checks fail)
try {
Card card = CardImpl.createCard(setInfo.getCardClass(), new CardSetInfo(setInfo.getName(), set.getCode(),
setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo()));