mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
Tests: added many verify checks for missing cards, names, numbers, download settings:
* check wrong card numbers in sets; * check missing cards from set; * check wrong full art settings; * check missing and unknown sets in scryfall download settings; * check missing and unknown direct download links in scryfall download settings; * improved ability text check results; * removed unused tests for word checks;
This commit is contained in:
parent
b083dd48e6
commit
7aac355f4a
7 changed files with 533 additions and 128 deletions
|
|
@ -8,6 +8,8 @@ public final class MtgJsonCard {
|
|||
// contains only used fields, if you need more for tests then just add it here
|
||||
|
||||
public String name;
|
||||
public String asciiName; // mtgjson uses it for some cards like El-Hajjaj
|
||||
public String number; // from sets source only, see https://mtgjson.com/data-models/card/
|
||||
|
||||
public String faceName;
|
||||
public String side;
|
||||
|
|
@ -28,5 +30,6 @@ public final class MtgJsonCard {
|
|||
|
||||
public Integer edhrecRank;
|
||||
public String layout;
|
||||
public boolean isFullArt;
|
||||
public List<String> printings; // set codes with that card
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ public final class MtgJsonService {
|
|||
for (Map.Entry<String, String> entry : mtgJsonToXMageCodes.entrySet()) {
|
||||
xMageToMtgJsonCodes.put(entry.getValue(), entry.getKey());
|
||||
}
|
||||
xMageToMtgJsonCodes.put("8EB", "8ED");
|
||||
xMageToMtgJsonCodes.put("9EB", "9ED");
|
||||
}
|
||||
|
||||
private static Map<String, MtgJsonCard> loadAllCards() throws IOException {
|
||||
|
|
@ -68,20 +70,58 @@ public final class MtgJsonService {
|
|||
return findReference(CardHolder.cards, name);
|
||||
}
|
||||
|
||||
public static List<MtgJsonCard> cardsFromSet(String setCode, String name) {
|
||||
MtgJsonSet set = findReference(SetHolder.sets, setCode);
|
||||
if (set == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
String needName = convertXmageToMtgJsonCardName(name);
|
||||
return set.cards.stream()
|
||||
.filter(c -> needName.equals(c.name) || needName.equals(c.asciiName) || needName.equals(c.faceName))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static MtgJsonCard cardFromSet(String setCode, String name, String number) {
|
||||
String jsonSetCode = xMageToMtgJsonCodes.getOrDefault(setCode, setCode);
|
||||
List<MtgJsonCard> list = cardsFromSet(jsonSetCode, name);
|
||||
return list.stream()
|
||||
.filter(c -> convertMtgJsonToXmageCardNumber(c.number).equals(number))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
private static <T> T findReference(Map<String, T> reference, String name) {
|
||||
T ref = reference.get(name);
|
||||
if (ref == null) {
|
||||
name = name.replaceFirst("\\bA[Ee]", "Æ");
|
||||
ref = reference.get(name);
|
||||
//name = name.replaceFirst("\\bA[Ee]", "Æ");
|
||||
//ref = reference.get(name);
|
||||
}
|
||||
if (ref == null) {
|
||||
name = name.replace("'", "\""); // for Kongming, "Sleeping Dragon" & Pang Tong, "Young Phoenix"
|
||||
//name = name.replace("'", "\""); // for Kongming, "Sleeping Dragon" & Pang Tong, "Young Phoenix"
|
||||
//ref = reference.get(name);
|
||||
}
|
||||
if (ref == null) {
|
||||
name = convertXmageToMtgJsonCardName(name);
|
||||
ref = reference.get(name);
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
private static String convertXmageToMtgJsonCardName(String cardName) {
|
||||
return cardName;
|
||||
//.replaceFirst("Aether", "Æther")
|
||||
//.replace("'", "\""); // for Kongming, "Sleeping Dragon" & Pang Tong, "Young Phoenix"
|
||||
}
|
||||
|
||||
private static String convertMtgJsonToXmageCardNumber(String number) {
|
||||
// card number notation must be same for all sets (replace non-ascii symbols)
|
||||
// so your set generation tools must use same replaces
|
||||
return number
|
||||
.replace("★", "*")
|
||||
.replace("†", "+");
|
||||
}
|
||||
|
||||
private static <T> void addAliases(Map<String, T> reference) {
|
||||
Map<String, String> aliases = new HashMap<>();
|
||||
for (String name : reference.keySet()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue