diff --git a/Mage.Verify/src/main/java/mage/verify/JsonCard.java b/Mage.Verify/src/main/java/mage/verify/JsonCard.java index 8a7d1b6916..0196ee128a 100644 --- a/Mage.Verify/src/main/java/mage/verify/JsonCard.java +++ b/Mage.Verify/src/main/java/mage/verify/JsonCard.java @@ -34,6 +34,8 @@ class JsonCard { public List printings; public String power; public String rarity; + public boolean starter; + public String side; public List rulings; public List subtypes; public List supertypes; @@ -44,8 +46,4 @@ class JsonCard { public String uuid; public List variations; public String watermark; - - // unknown - public boolean starter; - public String side; } diff --git a/Mage.Verify/src/main/java/mage/verify/MtgJson.java b/Mage.Verify/src/main/java/mage/verify/MtgJson.java index 4301ac0b6c..355eafc930 100644 --- a/Mage.Verify/src/main/java/mage/verify/MtgJson.java +++ b/Mage.Verify/src/main/java/mage/verify/MtgJson.java @@ -12,7 +12,10 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.text.Normalizer; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.zip.ZipInputStream; public final class MtgJson { @@ -60,16 +63,29 @@ public final class MtgJson { static { try { cards = loadAllCards(); - List oldKeys = new ArrayList<>(); + + List keysToDelete = new ArrayList<>(); + + // fix names Map newKeys = new HashMap<>(); for (String key : cards.keySet()) { if (key.contains("(")) { newKeys.put(key.replaceAll("\\(.*\\)", "").trim(), cards.get(key)); - oldKeys.add(key); + keysToDelete.add(key); } } cards.putAll(newKeys); - cards.keySet().removeAll(oldKeys); + cards.keySet().removeAll(keysToDelete); + + // remove wrong data (tokens) + keysToDelete.clear(); + for (Map.Entry record : cards.entrySet()) { + if (record.getValue().layout.equals("token") || record.getValue().layout.equals("double_faced_token")) { + keysToDelete.add(record.getKey()); + } + } + cards.keySet().removeAll(keysToDelete); + addAliases(cards); } catch (IOException e) { throw new RuntimeException(e); diff --git a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java index 0ebbe0f3e4..0d11f3230a 100644 --- a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java +++ b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java @@ -1,17 +1,5 @@ package mage.verify; -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Modifier; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; -import java.nio.file.Paths; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; import mage.ObjectColor; import mage.abilities.keyword.MultikickerAbility; import mage.cards.*; @@ -29,6 +17,19 @@ import org.mage.plugins.card.images.CardDownloadData; import org.mage.plugins.card.images.DownloadPictures; import org.reflections.Reflections; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Modifier; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Paths; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + /** * @author JayDi85 */ @@ -58,18 +59,25 @@ public class VerifyCardDataTest { skipListCreate("PT"); skipListAddName("PT", "UST", "Garbage Elemental"); skipListAddName("PT", "UST", "Infinity Elemental"); + skipListAddName("PT", "UNH", "Old Fogey"); // color skipListCreate("COLOR"); // cost skipListCreate("COST"); + skipListAddName("COST", "KTK", "Erase"); + skipListAddName("COST", "M13", "Erase"); + skipListAddName("COST", "ULG", "Erase"); + skipListAddName("COST", "H17", "Grimlock, Dinobot Leader"); // supertype skipListCreate("SUPERTYPE"); // type skipListCreate("TYPE"); + skipListAddName("TYPE", "UNH", "Old Fogey"); + skipListAddName("TYPE", "UST", "capital offense"); // subtype skipListCreate("SUBTYPE"); @@ -594,7 +602,7 @@ public class VerifyCardDataTest { // fix names (e.g. Urza’s to Urza's) if (expected != null && expected.contains("Urza’s")) { expected = new ArrayList<>(expected); - for (ListIterator it = ((List) expected).listIterator(); it.hasNext();) { + for (ListIterator it = ((List) expected).listIterator(); it.hasNext(); ) { if (it.next().equals("Urza’s")) { it.set("Urza's"); }