aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/equalparts/cardbase
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2016-03-19 19:26:05 +0100
committerEduardo Pedroni <e.pedroni91@gmail.com>2016-03-19 19:26:05 +0100
commit5878fd7a3d5cbe80b7ead67b1aa75fc55ff06697 (patch)
treefc99dd478e3cc7dd4f78b9ddef650a9397380495 /src/eu/equalparts/cardbase
parent67a3ab837c6e62e8b070999ca8fed5877e22494f (diff)
Sorted out new cardbase format, need to do decks next
Diffstat (limited to 'src/eu/equalparts/cardbase')
-rw-r--r--src/eu/equalparts/cardbase/Cardbase.java7
-rw-r--r--src/eu/equalparts/cardbase/cards/Card.java1
-rw-r--r--src/eu/equalparts/cardbase/decks/StandaloneDeck.java7
3 files changed, 8 insertions, 7 deletions
diff --git a/src/eu/equalparts/cardbase/Cardbase.java b/src/eu/equalparts/cardbase/Cardbase.java
index 3704d3f..ee49db1 100644
--- a/src/eu/equalparts/cardbase/Cardbase.java
+++ b/src/eu/equalparts/cardbase/Cardbase.java
@@ -2,6 +2,7 @@ package eu.equalparts.cardbase;
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -188,13 +189,13 @@ public class Cardbase {
}
/**
- * @param field the name of the field by which to sort.
+ * @param fieldName the name of the field by which to sort.
* @return an unmodifiable collection representing the cardbase sorted in the required order.
* @throws NoSuchFieldException if the field provided is invalid.
*/
- public Collection<Card> sort(String field) throws NoSuchFieldException {
+ public Collection<Card> sortByField(String fieldName) throws NoSuchFieldException {
List<Card> sortedCards = new ArrayList<Card>(dataContainer.cards.values());
- sortedCards.sort(new CardComparator(Card.class.getDeclaredField(field)));
+ sortedCards.sort(new CardComparator(Card.class.getDeclaredField(fieldName)));
return Collections.unmodifiableCollection(sortedCards);
}
diff --git a/src/eu/equalparts/cardbase/cards/Card.java b/src/eu/equalparts/cardbase/cards/Card.java
index 901a566..9b0975b 100644
--- a/src/eu/equalparts/cardbase/cards/Card.java
+++ b/src/eu/equalparts/cardbase/cards/Card.java
@@ -29,7 +29,6 @@ public class Card {
// Not part of upstream JSON
public String setCode;
public String imageCode;
- //public Integer count;
@Override
public Card clone() {
diff --git a/src/eu/equalparts/cardbase/decks/StandaloneDeck.java b/src/eu/equalparts/cardbase/decks/StandaloneDeck.java
index 4c6d25c..f015a91 100644
--- a/src/eu/equalparts/cardbase/decks/StandaloneDeck.java
+++ b/src/eu/equalparts/cardbase/decks/StandaloneDeck.java
@@ -1,12 +1,13 @@
package eu.equalparts.cardbase.decks;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.HashMap;
+import java.util.Map;
import eu.equalparts.cardbase.cards.Card;
public class StandaloneDeck extends Deck {
- public Set<Card> cards = new HashSet<Card>();
+ private Map<Integer, Card> cards = new HashMap<Integer, Card>();
+ private Map<Integer, Integer> counts = new HashMap<Integer, Integer>();
}