use of mage.verify.mtgjson.MtgJsonSet in project mage by magefree.
the class VerifyCardDataTest method test_checkWrongCardsDataInSets.
@Test
// TODO: enable after all missing cards and settings fixes
@Ignore
public void test_checkWrongCardsDataInSets() {
Collection<String> errorsList = new ArrayList<>();
Collection<String> warningsList = new ArrayList<>();
Collection<ExpansionSet> xmageSets = Sets.getInstance().values();
Set<String> foundedJsonCards = new HashSet<>();
// CHECK: wrong card numbers
for (ExpansionSet set : xmageSets) {
if (skipListHaveName(SKIP_LIST_WRONG_CARD_NUMBERS, set.getCode())) {
continue;
}
for (ExpansionSet.SetCardInfo card : set.getSetCardInfo()) {
MtgJsonCard jsonCard = MtgJsonService.cardFromSet(set.getCode(), card.getName(), card.getCardNumber());
if (jsonCard == null) {
// see convertMtgJsonToXmageCardNumber for card number convert notation
errorsList.add("Error: unknown card number or set, use standard number notations: " + set.getCode() + " - " + set.getName() + " - " + card.getName() + " - " + card.getCardNumber());
continue;
}
// index for missing cards
String code = MtgJsonService.xMageToMtgJsonCodes.getOrDefault(set.getCode(), set.getCode()) + " - " + jsonCard.getRealCardName() + " - " + jsonCard.number;
foundedJsonCards.add(code);
// CHECK: only lands can use full art in current version;
// Another cards must be in text render mode as normal, example: https://scryfall.com/card/sld/76/athreos-god-of-passage
boolean isLand = card.getRarity().equals(Rarity.LAND);
if (card.isFullArt() && !isLand) {
errorsList.add("Error: only lands can use full art setting: " + set.getCode() + " - " + set.getName() + " - " + card.getName() + " - " + card.getCardNumber());
}
// CHECK: must use full art setting
if (jsonCard.isFullArt && isLand && !card.isFullArt()) {
errorsList.add("Error: card must use full art setting: " + set.getCode() + " - " + set.getName() + " - " + card.getName() + " - " + card.getCardNumber());
}
// CHECK: must not use full art setting
if (!jsonCard.isFullArt && card.isFullArt()) {
errorsList.add("Error: card must NOT use full art setting: " + set.getCode() + " - " + set.getName() + " - " + card.getName() + " - " + card.getCardNumber());
}
}
}
// CHECK: missing cards from set
for (MtgJsonSet jsonSet : MtgJsonService.sets().values()) {
if (skipListHaveName(SKIP_LIST_UNSUPPORTED_SETS, jsonSet.code) || skipListHaveName(SKIP_LIST_WRONG_CARD_NUMBERS, jsonSet.code)) {
continue;
}
ExpansionSet xmageSet = Sets.findSet(jsonSet.code);
if (xmageSet == null) {
warningsList.add("Warning: found un-implemented set from mtgjson database: " + jsonSet.code + " - " + jsonSet.name + " - " + jsonSet.releaseDate);
continue;
}
for (MtgJsonCard jsonCard : jsonSet.cards) {
String code = jsonSet.code + " - " + jsonCard.getRealCardName() + " - " + jsonCard.number;
if (!foundedJsonCards.contains(code)) {
if (CardRepository.instance.findCard(jsonCard.getRealCardName()) == null) {
// ignore non-implemented cards
continue;
}
errorsList.add("Error: missing card from xmage's set: " + jsonSet.code + " - " + jsonCard.getRealCardName() + " - " + jsonCard.number);
}
}
}
printMessages(warningsList);
printMessages(errorsList);
if (errorsList.size() > 0) {
Assert.fail("Found wrong cards data in sets, errors: " + errorsList.size());
}
}
use of mage.verify.mtgjson.MtgJsonSet in project mage by magefree.
the class VerifyCardDataTest method test_checkMissingSets.
@Test
public void test_checkMissingSets() {
// generate unimplemented sets list
Collection<String> info = new ArrayList<>();
int missingSets = 0;
int missingCards = 0;
int unsupportedSets = 0;
int unsupportedCards = 0;
int mtgCards = 0;
int mtgSets = 0;
int xmageCards = 0;
int xmageUnofficialSets = 0;
int xmageUnofficialCards = 0;
Collection<ExpansionSet> sets = Sets.getInstance().values();
Assert.assertFalse("XMage data must contains sets list", sets.isEmpty());
Assert.assertFalse("MtgJson data must contains sets list", MtgJsonService.sets().isEmpty());
// official sets
for (Map.Entry<String, MtgJsonSet> refEntry : MtgJsonService.sets().entrySet()) {
MtgJsonSet refSet = refEntry.getValue();
mtgCards += refSet.totalSetSize;
// replace codes for aliases
String searchSet = MtgJsonService.mtgJsonToXMageCodes.getOrDefault(refSet.code, refSet.code);
if (skipListHaveName(SKIP_LIST_UNSUPPORTED_SETS, searchSet)) {
unsupportedSets++;
unsupportedCards += refSet.totalSetSize;
continue;
}
ExpansionSet mageSet = Sets.findSet(searchSet.toUpperCase(Locale.ENGLISH));
if (mageSet == null) {
missingSets = missingSets + 1;
missingCards = missingCards + refSet.cards.size();
info.add("Warning: missing set " + refSet.code + " - " + refSet.name + " (cards: " + refSet.cards.size() + ", date: " + refSet.releaseDate + ")");
continue;
}
mtgSets++;
xmageCards += mageSet.getSetCardInfo().size();
}
if (info.size() > 0) {
info.add("Warning: total missing sets: " + missingSets + ", with missing cards: " + missingCards);
}
// unofficial sets info
for (ExpansionSet set : sets) {
if (MtgJsonService.sets().containsKey(set.getCode())) {
continue;
}
xmageUnofficialSets++;
xmageUnofficialCards += set.getSetCardInfo().size();
info.add("Unofficial set: " + set.getCode() + " - " + set.getName() + ", cards: " + set.getSetCardInfo().size() + ", year: " + set.getReleaseYear());
}
printMessages(info);
System.out.println();
System.out.println("Official sets implementation stats:");
System.out.println("* MTG sets: " + MtgJsonService.sets().size() + ", cards: " + mtgCards);
System.out.println("* Implemented sets: " + mtgSets + ", cards: " + xmageCards);
System.out.println("* Unsupported sets: " + unsupportedSets + ", cards: " + unsupportedCards);
System.out.println("* TODO sets: " + (MtgJsonService.sets().size() - mtgSets - unsupportedSets) + ", cards: " + (mtgCards - xmageCards - unsupportedCards));
System.out.println();
System.out.println("Unofficial sets implementation stats:");
System.out.println("* Implemented sets: " + xmageUnofficialSets + ", cards: " + xmageUnofficialCards);
System.out.println();
}
Aggregations