From 59306d5db84daef508119f9ced39d0eb31c7b685 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sun, 23 Aug 2015 20:14:13 +0200 Subject: Added a few more CLI tests, need to figure out why they don't work properly on windows --- src/eu/equalparts/cardbase/utils/MTGUniverse.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/eu/equalparts') diff --git a/src/eu/equalparts/cardbase/utils/MTGUniverse.java b/src/eu/equalparts/cardbase/utils/MTGUniverse.java index 98067fa..dd6f6ad 100644 --- a/src/eu/equalparts/cardbase/utils/MTGUniverse.java +++ b/src/eu/equalparts/cardbase/utils/MTGUniverse.java @@ -32,11 +32,11 @@ public final class MTGUniverse { /** * The base URL from where the information is fetched. */ - private final String BASE_DATA_URL = "http://mtgjson.com/json/"; + private String BASE_DATA_URL = "http://mtgjson.com/json/"; /** * If the upstream set code list can't be loaded, this is loaded instead. */ - private final String FALLBACK_LIST_PATH = "/setlist.json"; + private final String FALLBACK_LIST_PATH = "/fallbackSetList.json"; /** * A cache of CardSets to avoid querying the server many times for the same information. */ @@ -46,6 +46,12 @@ public final class MTGUniverse { */ private HashMap cardSetCache = new HashMap(); + public MTGUniverse() {} + + public MTGUniverse(String dataLocation) { + this.BASE_DATA_URL = dataLocation; + } + /** * Returns the specified card in the form of a {@code Card} object. If the specified number does * not correspond to a card in the set or the specified set code does not correspond to a set, @@ -111,13 +117,13 @@ public final class MTGUniverse { cardSets = JSON.mapper.readValue(new URL(BASE_DATA_URL + "SetList.json"), new TypeReference>() {}); } catch (Exception e) { System.out.println("Error: could not fetch or parse set code list from upstream, using fallback json..."); - e.printStackTrace(); +// e.printStackTrace(); try { cardSets = JSON.mapper.readValue(MTGUniverse.class.getResourceAsStream(FALLBACK_LIST_PATH), new TypeReference>() {}); } catch (Exception f) { System.out.println("Error: could not parse fallback set code list, aborting..."); - f.printStackTrace(); +// f.printStackTrace(); System.exit(1); } } @@ -126,7 +132,7 @@ public final class MTGUniverse { } /** - * This method effectively converts different set code spellings + * This method converts different set code spellings * into the format parsed from the set code list. *
* For instance, if "m15" is passed as the argument, this returns -- cgit v1.2.3