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