From 27be2dd797fc7087c5e362c22c1f30fc377ea0e9 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Thu, 11 Jun 2015 16:57:42 +0200 Subject: Streamlined Card class, cards are now stored in a hashmap, had to write a method to parse full card set json --- src/eu/equalparts/cardbase/data/Card.java | 18 ++--- src/eu/equalparts/cardbase/data/FullCardSet.java | 90 +++++++++++++++++++++--- 2 files changed, 84 insertions(+), 24 deletions(-) (limited to 'src/eu/equalparts/cardbase/data') 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 names; - public String manaCost = ""; - public Integer cmc = 0; - public List colors; + public String name; + public String layout; + public String manaCost; + public Integer cmc; public String type; - public List supertypes; - public List types; - public List 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 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 cards; + private Map 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 getCards() { - return cards; + public Map 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 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 -- cgit v1.2.3