mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
added MTGJSON metadata to verify test
This commit is contained in:
parent
213564f8cd
commit
ef8ee52b94
2 changed files with 21 additions and 4 deletions
|
@ -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;
|
||||
}
|
|
@ -33,9 +33,8 @@ public final class MtgJsonService {
|
|||
return json.prepareIndex();
|
||||
}
|
||||
|
||||
private static Map<String, MtgJsonSet> 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> T readFromZip(String filename, Class<T> 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<String, MtgJsonSet> 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<String, MtgJsonSet> 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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue