aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/equalparts
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2016-03-25 07:50:26 +0100
committerEduardo Pedroni <e.pedroni91@gmail.com>2016-03-25 07:50:26 +0100
commitf66651cdd6cf6d7449428caae712eeeba8300194 (patch)
tree37678672ad8c9794791f9a222b8e7ab32a141506 /src/eu/equalparts
parent5878fd7a3d5cbe80b7ead67b1aa75fc55ff06697 (diff)
Refactoring decks to be more flexible
Diffstat (limited to 'src/eu/equalparts')
-rw-r--r--src/eu/equalparts/cardbase/Cardbase.java3
-rw-r--r--src/eu/equalparts/cardbase/DataContainer.java5
-rw-r--r--src/eu/equalparts/cardbase/decks/Deck.java14
-rw-r--r--src/eu/equalparts/cardbase/decks/ReferenceDeck.java16
-rw-r--r--src/eu/equalparts/cardbase/decks/StandaloneDeck.java8
5 files changed, 23 insertions, 23 deletions
diff --git a/src/eu/equalparts/cardbase/Cardbase.java b/src/eu/equalparts/cardbase/Cardbase.java
index ee49db1..cdceb75 100644
--- a/src/eu/equalparts/cardbase/Cardbase.java
+++ b/src/eu/equalparts/cardbase/Cardbase.java
@@ -2,7 +2,6 @@ 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;
@@ -12,13 +11,11 @@ import java.util.Map;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import eu.equalparts.cardbase.cards.Card;
import eu.equalparts.cardbase.comparator.CardComparator;
import eu.equalparts.cardbase.decks.ReferenceDeck;
-import eu.equalparts.cardbase.decks.StandaloneDeck;
import eu.equalparts.cardbase.utils.JSON;
/**
diff --git a/src/eu/equalparts/cardbase/DataContainer.java b/src/eu/equalparts/cardbase/DataContainer.java
deleted file mode 100644
index 892c76b..0000000
--- a/src/eu/equalparts/cardbase/DataContainer.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package eu.equalparts.cardbase;
-
-public class DataContainer {
-
-}
diff --git a/src/eu/equalparts/cardbase/decks/Deck.java b/src/eu/equalparts/cardbase/decks/Deck.java
index 1f28d60..7a7b819 100644
--- a/src/eu/equalparts/cardbase/decks/Deck.java
+++ b/src/eu/equalparts/cardbase/decks/Deck.java
@@ -1,12 +1,24 @@
package eu.equalparts.cardbase.decks;
-public abstract class Deck {
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+public abstract class Deck {
public String name = "Unnamed Deck";
public int plains = 0,
islands = 0,
swamps = 0,
mountains = 0,
forests = 0;
+
+ private Map<Integer, Integer> cardReferences = new HashMap<Integer, Integer>();
+
+ public void addCard(Integer cardHash, Integer count) {
+ cardReferences.put(cardHash, count);
+ }
+ public Map<Integer, Integer> getCardReferences() {
+ return Collections.unmodifiableMap(cardReferences);
+ }
}
diff --git a/src/eu/equalparts/cardbase/decks/ReferenceDeck.java b/src/eu/equalparts/cardbase/decks/ReferenceDeck.java
index 2303f24..ab9abf8 100644
--- a/src/eu/equalparts/cardbase/decks/ReferenceDeck.java
+++ b/src/eu/equalparts/cardbase/decks/ReferenceDeck.java
@@ -1,16 +1,11 @@
package eu.equalparts.cardbase.decks;
-import java.util.HashMap;
-import java.util.Map;
-
-import eu.equalparts.cardbase.cards.Card;
+import java.util.Map.Entry;
public class ReferenceDeck extends Deck {
-
- public Map<Integer, Integer> cardReferences = new HashMap<Integer, Integer>();
- public ReferenceDeck() {
-
+ public ReferenceDeck(String deckName) {
+ this.name = deckName;
}
public ReferenceDeck(StandaloneDeck deck) {
@@ -21,9 +16,8 @@ public class ReferenceDeck extends Deck {
this.mountains = deck.mountains;
this.forests = deck.forests;
- // TODO sort this out
- for (Card card : deck.cards) {
- cardReferences.put(card.hashCode(), 1);
+ for (Entry<Integer, Integer> entry : deck.getCardReferences().entrySet()) {
+ getCardReferences().put(entry.getKey(), entry.getValue());
}
}
diff --git a/src/eu/equalparts/cardbase/decks/StandaloneDeck.java b/src/eu/equalparts/cardbase/decks/StandaloneDeck.java
index f015a91..d66311d 100644
--- a/src/eu/equalparts/cardbase/decks/StandaloneDeck.java
+++ b/src/eu/equalparts/cardbase/decks/StandaloneDeck.java
@@ -1,13 +1,15 @@
package eu.equalparts.cardbase.decks;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import eu.equalparts.cardbase.cards.Card;
public class StandaloneDeck extends Deck {
+ private Map<Integer, Card> cardData = new HashMap<Integer, Card>();
- private Map<Integer, Card> cards = new HashMap<Integer, Card>();
- private Map<Integer, Integer> counts = new HashMap<Integer, Integer>();
-
+ public Map<Integer, Card> getCardData() {
+ return Collections.unmodifiableMap(cardData);
+ }
}