mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Tests: improved logs in verify tests;
This commit is contained in:
parent
56c0dc485c
commit
5157a88dba
1 changed files with 25 additions and 14 deletions
|
@ -45,6 +45,8 @@ public class VerifyCardDataTest {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(VerifyCardDataTest.class);
|
private static final Logger logger = Logger.getLogger(VerifyCardDataTest.class);
|
||||||
|
|
||||||
|
private static final String FULL_ABILITIES_CHECK_SET_CODE = "THB"; // check all abilities and output cards with wrong abilities texts;
|
||||||
|
|
||||||
// right now this is very noisy, and not useful enough to make any assertions on
|
// right now this is very noisy, and not useful enough to make any assertions on
|
||||||
private static final boolean CHECK_SOURCE_TOKENS = false;
|
private static final boolean CHECK_SOURCE_TOKENS = false;
|
||||||
|
|
||||||
|
@ -146,13 +148,15 @@ public class VerifyCardDataTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void verifyCards() throws IOException {
|
public void verifyCards() throws IOException {
|
||||||
|
int cardIndex = 0;
|
||||||
for (Card card : CardScanner.getAllCards()) {
|
for (Card card : CardScanner.getAllCards()) {
|
||||||
|
cardIndex++;
|
||||||
Set<String> tokens = findSourceTokens(card.getClass());
|
Set<String> tokens = findSourceTokens(card.getClass());
|
||||||
if (card.isSplitCard()) {
|
if (card.isSplitCard()) {
|
||||||
check(((SplitCard) card).getLeftHalfCard(), null);
|
check(((SplitCard) card).getLeftHalfCard(), null, cardIndex);
|
||||||
check(((SplitCard) card).getRightHalfCard(), null);
|
check(((SplitCard) card).getRightHalfCard(), null, cardIndex);
|
||||||
} else {
|
} else {
|
||||||
check(card, tokens);
|
check(card, tokens, cardIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,13 +724,13 @@ public class VerifyCardDataTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void check(Card card, Set<String> tokens) {
|
private void check(Card card, Set<String> tokens, int cardIndex) {
|
||||||
JsonCard ref = MtgJson.card(card.getName());
|
JsonCard ref = MtgJson.card(card.getName());
|
||||||
if (ref == null) {
|
if (ref == null) {
|
||||||
warn(card, "Missing card reference");
|
warn(card, "Missing card reference");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
checkAll(card, ref);
|
checkAll(card, ref, cardIndex);
|
||||||
if (tokens != null) {
|
if (tokens != null) {
|
||||||
JsonCard ref2 = null;
|
JsonCard ref2 = null;
|
||||||
if (card.isFlipCard()) {
|
if (card.isFlipCard()) {
|
||||||
|
@ -754,7 +758,7 @@ public class VerifyCardDataTest {
|
||||||
return options != null && options.contains(value);
|
return options != null && options.contains(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAll(Card card, JsonCard ref) {
|
private void checkAll(Card card, JsonCard ref, int cardIndex) {
|
||||||
checkCost(card, ref);
|
checkCost(card, ref);
|
||||||
checkPT(card, ref);
|
checkPT(card, ref);
|
||||||
checkSubtypes(card, ref);
|
checkSubtypes(card, ref);
|
||||||
|
@ -765,7 +769,7 @@ public class VerifyCardDataTest {
|
||||||
checkBasicLands(card, ref);
|
checkBasicLands(card, ref);
|
||||||
checkMissingAbilities(card, ref);
|
checkMissingAbilities(card, ref);
|
||||||
checkWrongSymbolsInRules(card);
|
checkWrongSymbolsInRules(card);
|
||||||
checkWrongAbilitiesText(card, ref);
|
checkWrongAbilitiesText(card, ref, cardIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkColors(Card card, JsonCard ref) {
|
private void checkColors(Card card, JsonCard ref) {
|
||||||
|
@ -902,6 +906,7 @@ public class VerifyCardDataTest {
|
||||||
.replace("{this}", cardName)
|
.replace("{this}", cardName)
|
||||||
.replace("{source}", cardName)
|
.replace("{source}", cardName)
|
||||||
.replace("−", "-")
|
.replace("−", "-")
|
||||||
|
.replace("—", "-")
|
||||||
.replace("—", "-");
|
.replace("—", "-");
|
||||||
|
|
||||||
// remove html marks
|
// remove html marks
|
||||||
|
@ -929,9 +934,9 @@ public class VerifyCardDataTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkWrongAbilitiesText(Card card, JsonCard ref) {
|
private void checkWrongAbilitiesText(Card card, JsonCard ref, int cardIndex) {
|
||||||
// checks missing or wrong text
|
// checks missing or wrong text
|
||||||
if (!card.getExpansionSetCode().equals("M20")) {
|
if (!card.getExpansionSetCode().equals(FULL_ABILITIES_CHECK_SET_CODE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -944,6 +949,10 @@ public class VerifyCardDataTest {
|
||||||
if (refText.startsWith("(") && refText.endsWith(")")) {
|
if (refText.startsWith("(") && refText.endsWith(")")) {
|
||||||
refText = refText.substring(1, refText.length() - 1);
|
refText = refText.substring(1, refText.length() - 1);
|
||||||
}
|
}
|
||||||
|
// planeswalker fix [-7]: xxx
|
||||||
|
if (refText.contains("[") && refText.contains("]")) {
|
||||||
|
refText = refText.replace("[", "").replace("]", "");
|
||||||
|
}
|
||||||
|
|
||||||
String[] refRules = refText.split("[\\$\\\n]"); // ref card's abilities can be splited by \n or $ chars
|
String[] refRules = refText.split("[\\$\\\n]"); // ref card's abilities can be splited by \n or $ chars
|
||||||
for (int i = 0; i < refRules.length; i++) {
|
for (int i = 0; i < refRules.length; i++) {
|
||||||
|
@ -956,10 +965,11 @@ public class VerifyCardDataTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isFine = true;
|
boolean isFine = true;
|
||||||
for (String cardRule : cardRules) {
|
for (int i = 0; i <= cardRules.length - 1; i++) {
|
||||||
boolean isAbilityFounded = false;
|
boolean isAbilityFounded = false;
|
||||||
for (String refRule : refRules) {
|
for (String refRule : refRules) {
|
||||||
if (cardRule.equals(refRule)) {
|
if (cardRules[i].equals(refRule)) {
|
||||||
|
cardRules[i] = "+ " + cardRules[i];
|
||||||
isAbilityFounded = true;
|
isAbilityFounded = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -967,7 +977,8 @@ public class VerifyCardDataTest {
|
||||||
|
|
||||||
if (!isAbilityFounded) {
|
if (!isAbilityFounded) {
|
||||||
isFine = false;
|
isFine = false;
|
||||||
warn(card, "card ability can't be found in ref [" + card.getName() + ": " + cardRule + "]");
|
warn(card, "card ability can't be found in ref [" + card.getName() + ": " + cardRules[i] + "]");
|
||||||
|
cardRules[i] = "- " + cardRules[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -975,7 +986,7 @@ public class VerifyCardDataTest {
|
||||||
if (!isFine) {
|
if (!isFine) {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("Wrong card " + card.getName());
|
System.out.println("Wrong card " + cardIndex + ": " + card.getName());
|
||||||
Arrays.sort(cardRules);
|
Arrays.sort(cardRules);
|
||||||
for (String s : cardRules) {
|
for (String s : cardRules) {
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
|
@ -984,7 +995,7 @@ public class VerifyCardDataTest {
|
||||||
System.out.println("ref:");
|
System.out.println("ref:");
|
||||||
Arrays.sort(refRules);
|
Arrays.sort(refRules);
|
||||||
for (String s : refRules) {
|
for (String s : refRules) {
|
||||||
System.out.println(s);
|
System.out.println(" " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
Loading…
Reference in a new issue