diff --git a/Mage.Verify/src/main/java/mage/verify/Booster.java b/Mage.Verify/src/main/java/mage/verify/Booster.java new file mode 100644 index 0000000000..161dcfff1d --- /dev/null +++ b/Mage.Verify/src/main/java/mage/verify/Booster.java @@ -0,0 +1,8 @@ +package mage.verify; + +public class Booster { + + public Booster(String mythic){ + + } +} diff --git a/Mage.Verify/src/main/java/mage/verify/ForeignData.java b/Mage.Verify/src/main/java/mage/verify/ForeignData.java new file mode 100644 index 0000000000..e410fb24d7 --- /dev/null +++ b/Mage.Verify/src/main/java/mage/verify/ForeignData.java @@ -0,0 +1,12 @@ +package mage.verify; + +public class ForeignData { + + + public String language; + public String name; + public String type; + public String text; + public String flavorText; + public String multiverseId; +} diff --git a/Mage.Verify/src/main/java/mage/verify/JsonCard.java b/Mage.Verify/src/main/java/mage/verify/JsonCard.java index a17d1a7b6b..c7a0c49a4b 100644 --- a/Mage.Verify/src/main/java/mage/verify/JsonCard.java +++ b/Mage.Verify/src/main/java/mage/verify/JsonCard.java @@ -3,10 +3,23 @@ package mage.verify; import java.util.List; class JsonCard { + public String uuid; + public String convertedManaCost; + public List foreignData; + public boolean isReserved; + public String side; + public Legality legalities; + public List printings; + public List rulings; + public List colorIndicator; public String layout; public String name; public List names; // flip cards public String manaCost; + public boolean hasFoil; + public boolean hasNonFoil; + public String multiverseId; + public String frameVersion; public int cmc; public List colors; public List colorIdentity; @@ -22,6 +35,10 @@ class JsonCard { public boolean starter; // only available in boxed sets and not in boosters public int hand; // vanguard public int life; // vanguard + public String originalText; + public String originalType; + public String flavorText; + public boolean isOnlineOnly; // only available in AllSets.json public String artist; @@ -37,4 +54,6 @@ class JsonCard { public String border; public String watermark; public boolean timeshifted; + public String borderColor; + public boolean isOversized; } diff --git a/Mage.Verify/src/main/java/mage/verify/JsonSet.java b/Mage.Verify/src/main/java/mage/verify/JsonSet.java index 831721937f..466ebbfb63 100644 --- a/Mage.Verify/src/main/java/mage/verify/JsonSet.java +++ b/Mage.Verify/src/main/java/mage/verify/JsonSet.java @@ -1,5 +1,7 @@ package mage.verify; +import com.fasterxml.jackson.annotation.JsonIgnore; + import java.util.List; import java.util.Map; @@ -21,4 +23,14 @@ class JsonSet { public String mkm_id; public String mkm_name; public Map translations; + public int baseSetSize; + @JsonIgnore + public List boosterV3; + public String borderColor; + public Meta meta; + public String mtgoCode; + public List tokens; + public int totalSetSize; + public boolean isOnlineOnly; + public boolean isFoilOnly; } diff --git a/Mage.Verify/src/main/java/mage/verify/Legality.java b/Mage.Verify/src/main/java/mage/verify/Legality.java new file mode 100644 index 0000000000..925bc2189e --- /dev/null +++ b/Mage.Verify/src/main/java/mage/verify/Legality.java @@ -0,0 +1,19 @@ +package mage.verify; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Legality { + @JsonProperty("1v1") + public String oneVersusOne; + public String commander; + public String duel; + public String legacy; + public String penny; + public String vintage; +public String frontier; +public String modern; +public String pauper; +public String brawl; +public String future; +public String standard; +} diff --git a/Mage.Verify/src/main/java/mage/verify/Meta.java b/Mage.Verify/src/main/java/mage/verify/Meta.java new file mode 100644 index 0000000000..4a93171da0 --- /dev/null +++ b/Mage.Verify/src/main/java/mage/verify/Meta.java @@ -0,0 +1,6 @@ +package mage.verify; + +public class Meta { + public String date; + public String version; +} diff --git a/Mage.Verify/src/main/java/mage/verify/MtgJson.java b/Mage.Verify/src/main/java/mage/verify/MtgJson.java index 1919f8db0f..4301ac0b6c 100644 --- a/Mage.Verify/src/main/java/mage/verify/MtgJson.java +++ b/Mage.Verify/src/main/java/mage/verify/MtgJson.java @@ -12,8 +12,7 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.text.Normalizer; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import java.util.zip.ZipInputStream; public final class MtgJson { @@ -61,6 +60,16 @@ public final class MtgJson { static { try { cards = loadAllCards(); + List oldKeys = new ArrayList<>(); + Map newKeys = new HashMap<>(); + for (String key : cards.keySet()) { + if (key.contains("(")) { + newKeys.put(key.replaceAll("\\(.*\\)", "").trim(), cards.get(key)); + oldKeys.add(key); + } + } + cards.putAll(newKeys); + cards.keySet().removeAll(oldKeys); addAliases(cards); } catch (IOException e) { throw new RuntimeException(e); @@ -95,7 +104,7 @@ public final class MtgJson { if (stream == null) { File file = new File(filename); if (!file.exists()) { - InputStream download = new URL("http://mtgjson.com/json/" + filename).openStream(); + InputStream download = new URL("http://mtgjson.com/v4/json/" + filename).openStream(); Files.copy(download, file.toPath(), StandardCopyOption.REPLACE_EXISTING); System.out.println("Downloaded " + filename + " to " + file.getAbsolutePath()); } else { @@ -133,6 +142,7 @@ public final class MtgJson { name = name.replace("'", "\""); // for Kongming, "Sleeping Dragon" & Pang Tong, "Young Phoenix" ref = reference.get(name); } + return ref; } diff --git a/Mage.Verify/src/main/java/mage/verify/Ruling.java b/Mage.Verify/src/main/java/mage/verify/Ruling.java new file mode 100644 index 0000000000..5bcb036329 --- /dev/null +++ b/Mage.Verify/src/main/java/mage/verify/Ruling.java @@ -0,0 +1,6 @@ +package mage.verify; + +public class Ruling { + public String text; + public String date; +} diff --git a/Mage.Verify/src/main/java/mage/verify/Token.java b/Mage.Verify/src/main/java/mage/verify/Token.java new file mode 100644 index 0000000000..c99ed0abc2 --- /dev/null +++ b/Mage.Verify/src/main/java/mage/verify/Token.java @@ -0,0 +1,19 @@ +package mage.verify; + +import java.util.List; + +public class Token { + public String artist; + public String borderColor; + public List colorIdentity; + public List colors; + public String name; + public String number; + public String power; + public String toughness; + public List reverseRelated; + public String text; + public String type; + public String uuid; + public String watermark; +} diff --git a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java index 991315438a..fb16264f15 100644 --- a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java +++ b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java @@ -1,14 +1,13 @@ package mage.verify; import mage.ObjectColor; -import mage.abilities.Ability; +import mage.abilities.keyword.DevoidAbility; import mage.abilities.keyword.MultikickerAbility; import mage.cards.*; import mage.cards.basiclands.BasicLand; -import mage.cards.repository.CardRepository; -import mage.cards.repository.CardScanner; import mage.constants.CardType; import mage.constants.Rarity; +import mage.constants.SubType; import mage.constants.SuperType; import mage.game.permanent.token.Token; import mage.game.permanent.token.TokenImpl; @@ -232,7 +231,7 @@ public class VerifyCardDataTest { // replace codes for aliases String searchSet = MtgJson.mtgJsonToXMageCodes.getOrDefault(refSet.code, refSet.code); - ExpansionSet mageSet = Sets.findSet(searchSet); + ExpansionSet mageSet = Sets.findSet(searchSet.toUpperCase()); if (mageSet == null) { totalMissingSets = totalMissingSets + 1; totalMissingCards = totalMissingCards + refSet.cards.size(); @@ -383,7 +382,7 @@ public class VerifyCardDataTest { // check for (ExpansionSet.SetCardInfo card : set.getSetCardInfo()) { boolean cardHaveDoubleName = (doubleNames.getOrDefault(card.getName(), 0) > 1); - boolean cardHaveVariousSetting = card.getGraphicInfo() == null ? false : card.getGraphicInfo().getUsesVariousArt(); + boolean cardHaveVariousSetting = card.getGraphicInfo() != null && card.getGraphicInfo().getUsesVariousArt(); if (cardHaveDoubleName && !cardHaveVariousSetting) { errorsList.add("error, founded double card names, but UsesVariousArt is not true: " + set.getCode() + " - " + set.getName() + " - " + card.getName() + " - " + card.getCardNumber()); @@ -569,17 +568,22 @@ public class VerifyCardDataTest { return; } - Collection expected = ref.colors; - ObjectColor color = card.getColor(null); - if (expected == null) { - expected = Collections.emptyList(); + Set expected = new HashSet<>(); + if (ref.colors != null) { + expected.addAll(ref.colors); } + if(card.isFlipCard()){ + expected.addAll(ref.colorIdentity); + } + + ObjectColor color = card.getColor(null); + if (expected.size() != color.getColorCount() - || (color.isBlack() && !expected.contains("Black")) - || (color.isBlue() && !expected.contains("Blue")) - || (color.isGreen() && !expected.contains("Green")) - || (color.isRed() && !expected.contains("Red")) - || (color.isWhite() && !expected.contains("White"))) { + || (color.isBlack() && !expected.contains("B")) + || (color.isBlue() && !expected.contains("U")) + || (color.isGreen() && !expected.contains("G")) + || (color.isRed() && !expected.contains("R")) + || (color.isWhite() && !expected.contains("W"))) { fail(card, "colors", color + " != " + expected); } } @@ -601,7 +605,7 @@ public class VerifyCardDataTest { } } - if (!eqSet(card.getSubtype(null).stream().map(p -> p.toString()).collect(Collectors.toSet()), expected)) { + if (!eqSet(card.getSubtype(null).stream().map(SubType::toString).collect(Collectors.toSet()), expected)) { fail(card, "subtypes", card.getSubtype(null) + " != " + expected); } } @@ -628,11 +632,11 @@ public class VerifyCardDataTest { } // special check: kicker ability must be in rules - if (card.getAbilities().containsClass(MultikickerAbility.class) && !card.getRules().stream().anyMatch(rule -> rule.contains("Multikicker"))) { + if (card.getAbilities().containsClass(MultikickerAbility.class) && card.getRules().stream().noneMatch(rule -> rule.contains("Multikicker"))) { fail(card, "abilities", "card have Multikicker ability, but missing it in rules text"); } - // spells have only 1 abilities + // spells have only 1 ability if (card.isSorcery() || card.isInstant()) { return; } @@ -697,7 +701,7 @@ public class VerifyCardDataTest { String expected = ref.manaCost; String cost = join(card.getManaCost().getSymbols()); - if (cost != null && cost.isEmpty()) { + if (cost.isEmpty()) { cost = null; } if (cost != null) {