mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Tests: improved mtgjson's card search in verify, added debug info to mtgjson's data;
This commit is contained in:
parent
6200b43a8d
commit
77209073e9
4 changed files with 46 additions and 19 deletions
|
@ -33,7 +33,26 @@ public final class MtgJsonCard {
|
||||||
public boolean isFullArt;
|
public boolean isFullArt;
|
||||||
public List<String> printings; // set codes with that card
|
public List<String> printings; // set codes with that card
|
||||||
|
|
||||||
public String getRealCardName() {
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return number + " - " + this.getNameAsFull()
|
||||||
|
+ (this.getNameAsFull().equals(this.getNameAsFace()) ? "" : String.format(" (face: %s)", this.getNameAsFace()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return single side name like Ice from Fire // Ice
|
||||||
|
*/
|
||||||
|
public String getNameAsFace() {
|
||||||
|
// return single side name
|
||||||
|
return faceName != null ? faceName : (asciiName != null ? asciiName : name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return full card name like Fire // Ice
|
||||||
|
*/
|
||||||
|
public String getNameAsFull() {
|
||||||
// xmage split a double faced card to two different cards, but mtgjson/scryfall uses full name,
|
// xmage split a double faced card to two different cards, but mtgjson/scryfall uses full name,
|
||||||
// so use faceName property for full name searching
|
// so use faceName property for full name searching
|
||||||
if ("transform".equals(layout)
|
if ("transform".equals(layout)
|
||||||
|
@ -42,7 +61,7 @@ public final class MtgJsonCard {
|
||||||
|| "modal_dfc".equals(layout)
|
|| "modal_dfc".equals(layout)
|
||||||
|| "reversible_card".equals(layout) // reversible_card - example: Zndrsplt, Eye of Wisdom
|
|| "reversible_card".equals(layout) // reversible_card - example: Zndrsplt, Eye of Wisdom
|
||||||
|| "meld".equals(layout)) { // meld - mtgjson uses composite names for meld cards, but scryfall uses simple face names
|
|| "meld".equals(layout)) { // meld - mtgjson uses composite names for meld cards, but scryfall uses simple face names
|
||||||
return faceName;
|
return getNameAsFace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return asciiName != null ? asciiName : name;
|
return asciiName != null ? asciiName : name;
|
||||||
|
|
|
@ -77,9 +77,10 @@ public final class MtgJsonService {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for a double faced cards each side goes here as one card, so must search by face name
|
||||||
String needName = convertXmageToMtgJsonCardName(name);
|
String needName = convertXmageToMtgJsonCardName(name);
|
||||||
return set.cards.stream()
|
return set.cards.stream()
|
||||||
.filter(c -> needName.equals(c.getRealCardName()))
|
.filter(c -> needName.equals(c.getNameAsFace()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +148,7 @@ public final class MtgJsonService {
|
||||||
public HashMap<String, ArrayList<MtgJsonCard>> data;
|
public HashMap<String, ArrayList<MtgJsonCard>> data;
|
||||||
|
|
||||||
private boolean containsSameNames(ArrayList<MtgJsonCard> list) {
|
private boolean containsSameNames(ArrayList<MtgJsonCard> list) {
|
||||||
Set<String> names = list.stream().map(MtgJsonCard::getRealCardName).collect(Collectors.toSet());
|
Set<String> names = list.stream().map(MtgJsonCard::getNameAsFace).collect(Collectors.toSet());
|
||||||
return names.size() == 1;
|
return names.size() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,9 @@ public final class MtgJsonSet {
|
||||||
public String name;
|
public String name;
|
||||||
public String releaseDate;
|
public String releaseDate;
|
||||||
public int totalSetSize;
|
public int totalSetSize;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return code + " - " + name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,10 +62,11 @@ 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 = "40K"; // check all abilities and output cards with wrong abilities texts;
|
private static final String FULL_ABILITIES_CHECK_SET_CODE = "40K"; // check all abilities and output cards with wrong abilities texts;
|
||||||
private static final boolean AUTO_FIX_SAMPLE_DECKS = false; // debug only: auto-fix sample decks by test_checkSampleDecks test run
|
private static final boolean CHECK_ONLY_ABILITIES_TEXT = false; // use when checking text locally, suppresses unnecessary checks and output messages
|
||||||
private static final boolean ONLY_TEXT = false; // use when checking text locally, suppresses unnecessary checks and output messages
|
|
||||||
|
|
||||||
private static final Set<String> checkedNames = new HashSet<>();
|
private static final boolean AUTO_FIX_SAMPLE_DECKS = false; // debug only: auto-fix sample decks by test_checkSampleDecks test run
|
||||||
|
|
||||||
|
private static final Set<String> checkedNames = new HashSet<>(); // skip already checked cards
|
||||||
private static final HashMap<String, Set<String>> skipCheckLists = new HashMap<>();
|
private static final HashMap<String, Set<String>> skipCheckLists = new HashMap<>();
|
||||||
private static final Set<String> subtypesToIgnore = new HashSet<>();
|
private static final Set<String> subtypesToIgnore = new HashSet<>();
|
||||||
private static final String SKIP_LIST_PT = "PT";
|
private static final String SKIP_LIST_PT = "PT";
|
||||||
|
@ -631,7 +632,7 @@ public class VerifyCardDataTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// index for missing cards
|
// index for missing cards
|
||||||
String code = MtgJsonService.xMageToMtgJsonCodes.getOrDefault(set.getCode(), set.getCode()) + " - " + jsonCard.getRealCardName() + " - " + jsonCard.number;
|
String code = MtgJsonService.xMageToMtgJsonCodes.getOrDefault(set.getCode(), set.getCode()) + " - " + jsonCard.getNameAsFull() + " - " + jsonCard.number;
|
||||||
foundedJsonCards.add(code);
|
foundedJsonCards.add(code);
|
||||||
|
|
||||||
// CHECK: only lands can use full art in current version;
|
// CHECK: only lands can use full art in current version;
|
||||||
|
@ -678,12 +679,12 @@ public class VerifyCardDataTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MtgJsonCard jsonCard : jsonSet.cards) {
|
for (MtgJsonCard jsonCard : jsonSet.cards) {
|
||||||
String code = jsonSet.code + " - " + jsonCard.getRealCardName() + " - " + jsonCard.number;
|
String code = jsonSet.code + " - " + jsonCard.getNameAsFull() + " - " + jsonCard.number;
|
||||||
if (!foundedJsonCards.contains(code)) {
|
if (!foundedJsonCards.contains(code)) {
|
||||||
if (!implementedIndex.contains(jsonCard.getRealCardName())) {
|
if (!implementedIndex.contains(jsonCard.getNameAsFull())) {
|
||||||
warningsList.add("Warning: un-implemented card from mtgjson: " + jsonSet.code + " - " + jsonCard.getRealCardName() + " - " + jsonCard.number);
|
warningsList.add("Warning: un-implemented card from mtgjson: " + jsonSet.code + " - " + jsonCard.getNameAsFull() + " - " + jsonCard.number);
|
||||||
} else {
|
} else {
|
||||||
errorsList.add("Error: missing card from xmage's set: " + jsonSet.code + " - " + jsonCard.getRealCardName() + " - " + jsonCard.number);
|
errorsList.add("Error: missing card from xmage's set: " + jsonSet.code + " - " + jsonCard.getNameAsFull() + " - " + jsonCard.number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1314,19 +1315,20 @@ public class VerifyCardDataTest {
|
||||||
return options != null && options.contains(value);
|
return options != null && options.contains(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkName(MtgJsonCard ref) {
|
private static boolean wasCheckedByAbilityText(MtgJsonCard ref) {
|
||||||
if (!ONLY_TEXT) {
|
// ignore already checkd cards, so no bloated logs from duplicated cards
|
||||||
|
if (!CHECK_ONLY_ABILITIES_TEXT) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (checkedNames.contains(ref.getRealCardName())) {
|
if (checkedNames.contains(ref.getNameAsFace())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
checkedNames.add(ref.getRealCardName());
|
checkedNames.add(ref.getNameAsFace());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAll(Card card, MtgJsonCard ref, int cardIndex) {
|
private void checkAll(Card card, MtgJsonCard ref, int cardIndex) {
|
||||||
if (!ONLY_TEXT) {
|
if (!CHECK_ONLY_ABILITIES_TEXT) {
|
||||||
checkCost(card, ref);
|
checkCost(card, ref);
|
||||||
checkPT(card, ref);
|
checkPT(card, ref);
|
||||||
checkSubtypes(card, ref);
|
checkSubtypes(card, ref);
|
||||||
|
@ -1679,7 +1681,7 @@ public class VerifyCardDataTest {
|
||||||
|
|
||||||
private void checkWrongAbilitiesText(Card card, MtgJsonCard ref, int cardIndex) {
|
private void checkWrongAbilitiesText(Card card, MtgJsonCard ref, int cardIndex) {
|
||||||
// checks missing or wrong text
|
// checks missing or wrong text
|
||||||
if (!card.getExpansionSetCode().equals(FULL_ABILITIES_CHECK_SET_CODE) || !checkName(ref)) {
|
if (!card.getExpansionSetCode().equals(FULL_ABILITIES_CHECK_SET_CODE) || !wasCheckedByAbilityText(ref)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1782,7 +1784,7 @@ public class VerifyCardDataTest {
|
||||||
|
|
||||||
if (!isAbilityFounded && cardRules[i].length() > 0) {
|
if (!isAbilityFounded && cardRules[i].length() > 0) {
|
||||||
isFine = false;
|
isFine = false;
|
||||||
if (!ONLY_TEXT) {
|
if (!CHECK_ONLY_ABILITIES_TEXT) {
|
||||||
warn(card, "card ability can't be found in ref [" + card.getName() + ": " + cardRules[i] + "]");
|
warn(card, "card ability can't be found in ref [" + card.getName() + ": " + cardRules[i] + "]");
|
||||||
}
|
}
|
||||||
cardRules[i] = "- " + cardRules[i];
|
cardRules[i] = "- " + cardRules[i];
|
||||||
|
|
Loading…
Reference in a new issue