aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/equalparts/cardbase/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/equalparts/cardbase/data')
-rw-r--r--src/eu/equalparts/cardbase/data/CardSet.java32
-rw-r--r--src/eu/equalparts/cardbase/data/CardbaseManager.java50
-rw-r--r--src/eu/equalparts/cardbase/data/FullCardSet.java25
-rw-r--r--src/eu/equalparts/cardbase/data/MetaCardSet.java14
4 files changed, 61 insertions, 60 deletions
diff --git a/src/eu/equalparts/cardbase/data/CardSet.java b/src/eu/equalparts/cardbase/data/CardSet.java
index 2c8f950..959e0a3 100644
--- a/src/eu/equalparts/cardbase/data/CardSet.java
+++ b/src/eu/equalparts/cardbase/data/CardSet.java
@@ -1,28 +1,14 @@
package eu.equalparts.cardbase.data;
-import java.util.ArrayList;
-
public class CardSet {
- public String name;
- public String code;
- public String releaseDate;
- public String border;
- public String type;
- public String block;
- public String gathererCode;
- public ArrayList<Card> cards;
- /**
- * Searches for a card by number (the one shown on the card itself).
- *
- * @param number the number of the card to search.
- * @return the card, or null if no card is found with that number.
- */
- public Card getCardByNumber(String number) {
- for (Card card : cards) {
- if (card.number.equals(number))
- return card;
- }
- return null;
+ public String name = "";
+ public String code = "";
+ public String releaseDate = "";
+
+ @Override
+ public String toString() {
+ return String.format("%1$-12s : %2$s", code, name, releaseDate);
}
-} \ No newline at end of file
+
+}
diff --git a/src/eu/equalparts/cardbase/data/CardbaseManager.java b/src/eu/equalparts/cardbase/data/CardbaseManager.java
index cf18390..e6a4f97 100644
--- a/src/eu/equalparts/cardbase/data/CardbaseManager.java
+++ b/src/eu/equalparts/cardbase/data/CardbaseManager.java
@@ -11,33 +11,37 @@ import eu.equalparts.cardbase.query.IO;
public class CardbaseManager {
- private ArrayList<MetaCardSet> metaSets;
- public Cardbase cardBase;
+ private ArrayList<CardSet> cardSets;
+ public Cardbase cardbase;
/**
- * Parse a cardbase file and create an associated CardBase object.
- * @throws IOException
- * @throws JsonMappingException
- * @throws JsonParseException
+ * Parse a cardbase file and create an associated Cardbase object.
+ *
+ * @param cardbaseFile
+ *
+ * @throws JsonParseException if underlying input contains invalid content of type JsonParser supports (JSON for default case).
+ * @throws JsonMappingException if the input JSON structure does not match structure expected for result type (or has other mismatch issues).
+ * @throws IOException if a low-level I/O problem (unexpected end-of-input, network error) occurs.
*/
- public CardbaseManager(File cardBaseFile) throws JsonParseException, JsonMappingException, IOException {
- metaSets = IO.getAllMetaSets();
- cardBase = IO.readCardBase(cardBaseFile);
+ public CardbaseManager(File cardbaseFile) throws JsonParseException, JsonMappingException, IOException {
+ cardSets = IO.getCardSetList();
+ cardbase = IO.readCardbase(cardbaseFile);
}
/**
- * Create an empty CardBase.
- * @throws IOException
- * @throws JsonMappingException
- * @throws JsonParseException
+ * Create an empty Cardbase.
+ *
+ * @throws JsonParseException if underlying input contains invalid content of type JsonParser supports (JSON for default case).
+ * @throws JsonMappingException if the input JSON structure does not match structure expected for result type (or has other mismatch issues).
+ * @throws IOException if a low-level I/O problem (unexpected end-of-input, network error) occurs.
*/
public CardbaseManager() throws JsonParseException, JsonMappingException, IOException {
- metaSets = IO.getAllMetaSets();
- cardBase = new Cardbase();
+ cardSets = IO.getCardSetList();
+ cardbase = new Cardbase();
}
- public ArrayList<MetaCardSet> getAllMetaSets() {
- return metaSets;
+ public ArrayList<CardSet> getCardSetList() {
+ return cardSets;
}
/**
@@ -50,12 +54,12 @@ public class CardbaseManager {
* @param count
*/
public void addCard(Card newCard, Integer count) {
- Card card = cardBase.getCardByNumber(newCard.setCode, newCard.number);
+ Card card = cardbase.getCardByNumber(newCard.setCode, newCard.number);
if (card != null) {
card.count += count;
} else {
newCard.count = count;
- cardBase.cards.add(newCard);
+ cardbase.cards.add(newCard);
}
}
@@ -70,10 +74,10 @@ public class CardbaseManager {
* @param count
*/
public void removeCard(Card remove, Integer count) {
- Card card = cardBase.getCardByNumber(remove.setCode, remove.number);
+ Card card = cardbase.getCardByNumber(remove.setCode, remove.number);
if (card != null) {
if (card.count <= count) {
- cardBase.cards.remove(card);
+ cardbase.cards.remove(card);
} else {
card.count -= count;
}
@@ -84,7 +88,7 @@ public class CardbaseManager {
* @return an iterator to the cards in the cardbase.
*/
public Iterator<Card> cardIterator() {
- return cardBase.cards.iterator();
+ return cardbase.cards.iterator();
}
/**
@@ -96,6 +100,6 @@ public class CardbaseManager {
* @return
*/
public Card getCard(String code, String number) {
- return cardBase.getCardByNumber(code, number);
+ return cardbase.getCardByNumber(code, number);
}
}
diff --git a/src/eu/equalparts/cardbase/data/FullCardSet.java b/src/eu/equalparts/cardbase/data/FullCardSet.java
new file mode 100644
index 0000000..0b5c099
--- /dev/null
+++ b/src/eu/equalparts/cardbase/data/FullCardSet.java
@@ -0,0 +1,25 @@
+package eu.equalparts.cardbase.data;
+
+import java.util.ArrayList;
+
+public class FullCardSet extends CardSet {
+ public String border;
+ public String type;
+ public String block;
+ public String gathererCode;
+ public ArrayList<Card> cards;
+
+ /**
+ * Searches for a card by number (the one shown on the card itself).
+ *
+ * @param number the number of the card to search.
+ * @return the card, or null if no card is found with that number.
+ */
+ public Card getCardByNumber(String number) {
+ for (Card card : cards) {
+ if (card.number.equals(number))
+ return card;
+ }
+ return null;
+ }
+} \ No newline at end of file
diff --git a/src/eu/equalparts/cardbase/data/MetaCardSet.java b/src/eu/equalparts/cardbase/data/MetaCardSet.java
deleted file mode 100644
index 3b7d4fd..0000000
--- a/src/eu/equalparts/cardbase/data/MetaCardSet.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package eu.equalparts.cardbase.data;
-
-public class MetaCardSet {
-
- public String name = "";
- public String code = "";
- public String releaseDate = "";
-
- @Override
- public String toString() {
- return String.format("%1$-12s : %2$s", code, name, releaseDate);
- }
-
-}