From ef8ee52b9438cab02412d7ef7834de6a43263d0f Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 17 Apr 2021 21:15:42 -0400 Subject: [PATCH] added MTGJSON metadata to verify test --- .../mage/verify/mtgjson/MtgJsonMetadata.java | 9 +++++++++ .../java/mage/verify/mtgjson/MtgJsonService.java | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 Mage.Verify/src/main/java/mage/verify/mtgjson/MtgJsonMetadata.java diff --git a/Mage.Verify/src/main/java/mage/verify/mtgjson/MtgJsonMetadata.java b/Mage.Verify/src/main/java/mage/verify/mtgjson/MtgJsonMetadata.java new file mode 100644 index 0000000000..10c10dfae3 --- /dev/null +++ b/Mage.Verify/src/main/java/mage/verify/mtgjson/MtgJsonMetadata.java @@ -0,0 +1,9 @@ +package mage.verify.mtgjson; + +public final class MtgJsonMetadata { + // MTGJSON metadata + // https://mtgjson.com/file-models/meta/ + + public String date; + public String version; +} diff --git a/Mage.Verify/src/main/java/mage/verify/mtgjson/MtgJsonService.java b/Mage.Verify/src/main/java/mage/verify/mtgjson/MtgJsonService.java index 52c4b193a2..dbc1935c86 100644 --- a/Mage.Verify/src/main/java/mage/verify/mtgjson/MtgJsonService.java +++ b/Mage.Verify/src/main/java/mage/verify/mtgjson/MtgJsonService.java @@ -33,9 +33,8 @@ public final class MtgJsonService { return json.prepareIndex(); } - private static Map loadAllSets() throws IOException { - AllPrintingsModel json = readFromZip("AllPrintings.json.zip", AllPrintingsModel.class); - return json.data; + private static AllPrintingsModel loadAllSets() throws IOException { + return readFromZip("AllPrintings.json.zip", AllPrintingsModel.class); } private static T readFromZip(String filename, Class clazz) throws IOException { @@ -66,6 +65,10 @@ public final class MtgJsonService { return SetHolder.sets; } + public static MtgJsonMetadata meta() { + return SetHolder.meta; + } + public static MtgJsonCard card(String name) { return findReference(CardHolder.cards, name); } @@ -178,6 +181,7 @@ public final class MtgJsonService { private static final class AllPrintingsModel { public HashMap data; + public MtgJsonMetadata meta; } private static final class CardHolder { @@ -218,10 +222,14 @@ public final class MtgJsonService { private static final class SetHolder { private static final Map sets; + private static final MtgJsonMetadata meta; static { try { - sets = loadAllSets(); + AllPrintingsModel model = loadAllSets(); + sets = model.data; + meta = model.meta; + System.out.println("MTGJSON version " + meta.version + ", release date " + meta.date); } catch (IOException e) { throw new RuntimeException(e); }