mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
Merge 8e833c6414 into 162edb9351
This commit is contained in:
commit
b4a19af9f5
1 changed files with 44 additions and 35 deletions
|
|
@ -91,6 +91,11 @@ public class VerifyCardDataTest {
|
|||
private static final boolean CHECK_COPYABLE_FIELDS = true;
|
||||
private static final boolean CHECK_FILTER_FIELDS = true;
|
||||
|
||||
// enable to do full audits of token data
|
||||
// First task to tackle is all private tokens must be replaced by CreatureToken
|
||||
// This will solve multiple errors for currently offending classes and minimise other subsequent fixes
|
||||
private static final boolean CHECK_TOKEN_DATA_FULL = false;
|
||||
|
||||
// for automated local testing support
|
||||
static {
|
||||
String val = System.getProperty("xmage.tests.verifyCheckSetCodes");
|
||||
|
|
@ -1384,7 +1389,6 @@ public class VerifyCardDataTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore // TODO: enable test after massive token fixes
|
||||
public void test_checkMissingTokenData() {
|
||||
|
||||
Collection<String> errorsList = new ArrayList<>();
|
||||
|
|
@ -1464,29 +1468,32 @@ public class VerifyCardDataTest {
|
|||
}
|
||||
}
|
||||
|
||||
// CHECK: private class for inner tokens (no needs at all -- all private tokens must be replaced by CreatureToken)
|
||||
for (Class<? extends TokenImpl> tokenClass : privateTokens) {
|
||||
String className = extractShortClass(tokenClass);
|
||||
errorsList.add("Warning: no needs in private tokens, replace it with CreatureToken: " + className + " from " + tokenClass.getName());
|
||||
}
|
||||
if (CHECK_TOKEN_DATA_FULL) {
|
||||
// CHECK: private class for inner tokens (no needs at all -- all private tokens must be replaced by CreatureToken)
|
||||
for (Class<? extends TokenImpl> tokenClass : privateTokens) {
|
||||
String className = extractShortClass(tokenClass);
|
||||
errorsList.add("Warning: no needs in private tokens, replace it with CreatureToken: " + className + " from " + tokenClass.getName());
|
||||
}
|
||||
|
||||
// CHECK: all public tokens must have tok-data (private tokens uses for innner abilities -- no need images for it)
|
||||
for (Class<? extends TokenImpl> tokenClass : publicTokens) {
|
||||
Token token = (Token) createNewObject(tokenClass);
|
||||
if (token == null) {
|
||||
// how-to fix:
|
||||
// - create empty param
|
||||
// - fix error in token's constructor
|
||||
errorsList.add("Error: token must have default constructor with zero params: " + tokenClass.getName());
|
||||
} else if (tokDataNamesIndex.getOrDefault(token.getName().replace(" Token", ""), "").isEmpty()) {
|
||||
if (token instanceof CreatureToken || token instanceof XmageToken) {
|
||||
// ignore custom token builders
|
||||
continue;
|
||||
|
||||
// CHECK: all public tokens must have tok-data (private tokens uses for innner abilities -- no need images for it)
|
||||
for (Class<? extends TokenImpl> tokenClass : publicTokens) {
|
||||
Token token = (Token) createNewObject(tokenClass);
|
||||
if (token == null) {
|
||||
// how-to fix:
|
||||
// - create empty param
|
||||
// - fix error in token's constructor
|
||||
errorsList.add("Error: token must have default constructor with zero params: " + tokenClass.getName());
|
||||
} else if (tokDataNamesIndex.getOrDefault(token.getName().replace(" Token", ""), "").isEmpty()) {
|
||||
if (token instanceof CreatureToken || token instanceof XmageToken) {
|
||||
// ignore custom token builders
|
||||
continue;
|
||||
}
|
||||
// how-to fix:
|
||||
// - public token must be downloadable, so tok-data must contain miss set
|
||||
// (also don't forget to add new set to scryfall download)
|
||||
errorsList.add("Error: can't find data in tokens-database.txt for token: " + tokenClass.getName() + " -> " + token.getName());
|
||||
}
|
||||
// how-to fix:
|
||||
// - public token must be downloadable, so tok-data must contain miss set
|
||||
// (also don't forget to add new set to scryfall download)
|
||||
errorsList.add("Error: can't find data in tokens-database.txt for token: " + tokenClass.getName() + " -> " + token.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1502,18 +1509,20 @@ public class VerifyCardDataTest {
|
|||
}
|
||||
|
||||
// CHECK: tokens must have Token word in the name
|
||||
if (token.getDescription().startsWith(token.getName() + ", ")
|
||||
|| token.getDescription().contains("named " + token.getName())
|
||||
|| (token instanceof CreatureToken)
|
||||
|| (token instanceof XmageToken)) {
|
||||
// ignore some names:
|
||||
// - Boo, a legendary 1/1 red Hamster creature token with trample and haste
|
||||
// - 1/1 green Insect creature token with flying named Butterfly
|
||||
// - custom token builders
|
||||
} else {
|
||||
if (!token.getName().endsWith("Token")) {
|
||||
errorsList.add("Error: token's name must ends with Token: "
|
||||
+ tokenClass.getName() + " - " + token.getName());
|
||||
if (CHECK_TOKEN_DATA_FULL) {
|
||||
if (token.getDescription().startsWith(token.getName() + ", ")
|
||||
|| token.getDescription().contains("named " + token.getName())
|
||||
|| (token instanceof CreatureToken)
|
||||
|| (token instanceof XmageToken)) {
|
||||
// ignore some names:
|
||||
// - Boo, a legendary 1/1 red Hamster creature token with trample and haste
|
||||
// - 1/1 green Insect creature token with flying named Butterfly
|
||||
// - custom token builders
|
||||
} else {
|
||||
if (!token.getName().endsWith("Token")) {
|
||||
errorsList.add("Error: token's name must ends with Token: "
|
||||
+ tokenClass.getName() + " - " + token.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1939,7 +1948,7 @@ public class VerifyCardDataTest {
|
|||
|
||||
// "copy" fails means that the copy constructor are not correct inside a card.
|
||||
// To fix those, try to find the class that did trigger the copy failure, and check
|
||||
// that copy() exists, a copy constructor exists, and the copy constructor is right.
|
||||
// that copy() exists, a copy constructor exists, and the copy constructor is right.
|
||||
private void checkCardCanBeCopied(Card card1) {
|
||||
Card card2;
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue