From 5878fd7a3d5cbe80b7ead67b1aa75fc55ff06697 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sat, 19 Mar 2016 19:26:05 +0100 Subject: Sorted out new cardbase format, need to do decks next --- src/eu/equalparts/cardbase/Cardbase.java | 7 ++++--- src/eu/equalparts/cardbase/cards/Card.java | 1 - src/eu/equalparts/cardbase/decks/StandaloneDeck.java | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/eu') 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 sort(String field) throws NoSuchFieldException { + public Collection sortByField(String fieldName) throws NoSuchFieldException { List sortedCards = new ArrayList(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 cards = new HashSet(); + private Map cards = new HashMap(); + private Map counts = new HashMap(); } -- cgit v1.2.3