aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/equalparts/cardbase/data
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2015-06-11 16:57:42 +0200
committerEduardo Pedroni <e.pedroni91@gmail.com>2015-06-11 16:57:42 +0200
commit27be2dd797fc7087c5e362c22c1f30fc377ea0e9 (patch)
tree93b0b5360788f1df3b257c294dbe08ffcf291dc2 /src/eu/equalparts/cardbase/data
parent56dc0db523156c6ff77d9212983c51b531250733 (diff)
Streamlined Card class, cards are now stored in a hashmap, had to write a method to parse full card set json
Diffstat (limited to 'src/eu/equalparts/cardbase/data')
-rw-r--r--src/eu/equalparts/cardbase/data/Card.java18
-rw-r--r--src/eu/equalparts/cardbase/data/FullCardSet.java90
2 files changed, 84 insertions, 24 deletions
diff --git a/src/eu/equalparts/cardbase/data/Card.java b/src/eu/equalparts/cardbase/data/Card.java
index 3820223..cca1747 100644
--- a/src/eu/equalparts/cardbase/data/Card.java
+++ b/src/eu/equalparts/cardbase/data/Card.java
@@ -1,19 +1,12 @@
package eu.equalparts.cardbase.data;
-import java.util.List;
-
public class Card {
- public String name = "";
- public String layout = "";
- public List<String> names;
- public String manaCost = "";
- public Integer cmc = 0;
- public List<String> colors;
+ public String name;
+ public String layout;
+ public String manaCost;
+ public Integer cmc;
public String type;
- public List<String> supertypes;
- public List<String> types;
- public List<String> subtypes;
public String rarity;
public String text;
public String flavor;
@@ -23,7 +16,6 @@ public class Card {
public String toughness;
public Integer loyalty;
public Integer multiverseid;
- public List<String> variations;
public String imageName;
public String border;
public String watermark;
@@ -31,5 +23,5 @@ public class Card {
// Not part of upstream JSON
public String setCode;
public Integer count;
-
+
} \ No newline at end of file
diff --git a/src/eu/equalparts/cardbase/data/FullCardSet.java b/src/eu/equalparts/cardbase/data/FullCardSet.java
index d469829..e831b74 100644
--- a/src/eu/equalparts/cardbase/data/FullCardSet.java
+++ b/src/eu/equalparts/cardbase/data/FullCardSet.java
@@ -1,17 +1,19 @@
package eu.equalparts.cardbase.data;
-import java.util.List;
+import java.util.Collections;
+import java.util.Map;
public class FullCardSet {
private String name;
private String code;
+ private String magicCardsInfoCode;
private String releaseDate;
private String border;
private String type;
private String block;
private String gathererCode;
- private List<Card> cards;
+ private Map<String, Card> cards;
/**
* @return the set's name.
@@ -63,12 +65,12 @@ public class FullCardSet {
}
/**
- * @return a full list of the set's cards.
+ * @return a full unmodifiable map of the set's cards.
*/
- public List<Card> getCards() {
- return cards;
+ public Map<String, Card> getCards() {
+ return Collections.unmodifiableMap(cards);
}
-
+
/**
* Searches for a card by number (the one shown on the card itself).
*
@@ -76,10 +78,76 @@ public class FullCardSet {
* @return the requested {@code 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;
+ return cards.get(number);
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @param code the code to set
+ */
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ /**
+ * @param releaseDate the releaseDate to set
+ */
+ public void setReleaseDate(String releaseDate) {
+ this.releaseDate = releaseDate;
+ }
+
+ /**
+ * @param border the border to set
+ */
+ public void setBorder(String border) {
+ this.border = border;
+ }
+
+ /**
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * @param block the block to set
+ */
+ public void setBlock(String block) {
+ this.block = block;
+ }
+
+ /**
+ * @param gathererCode the gathererCode to set
+ */
+ public void setGathererCode(String gathererCode) {
+ this.gathererCode = gathererCode;
+ }
+
+ /**
+ * @param cards the cards to set
+ */
+ public void setCards(Map<String, Card> cards) {
+ this.cards = cards;
+ }
+
+ /**
+ * @return the magicCardsInfoCode
+ */
+ public String getMagicCardsInfoCode() {
+ return magicCardsInfoCode;
+ }
+
+ /**
+ * @param magicCardsInfoCode the magicCardsInfoCode to set
+ */
+ public void setMagicCardsInfoCode(String magicCardsInfoCode) {
+ this.magicCardsInfoCode = magicCardsInfoCode;
}
} \ No newline at end of file