Tweaking new sets, formats and filtering in deck builder.
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
4_002,1_002
|
4_2,1_2
|
||||||
4_062,1_041
|
4_62,1_41
|
||||||
@@ -107,7 +107,7 @@ public class CollectionSerializer {
|
|||||||
private MutableCardCollection deserializeCollectionVer0(BufferedInputStream inputStream) throws IOException {
|
private MutableCardCollection deserializeCollectionVer0(BufferedInputStream inputStream) throws IOException {
|
||||||
int packBytes = inputStream.read();
|
int packBytes = inputStream.read();
|
||||||
|
|
||||||
DefaultCardCollection collection = new DefaultCardCollection();
|
DefaultCardCollection collection = new DefaultCardCollection(_library);
|
||||||
|
|
||||||
byte[] packs = new byte[packBytes];
|
byte[] packs = new byte[packBytes];
|
||||||
int read = inputStream.read(packs);
|
int read = inputStream.read(packs);
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ import java.util.*;
|
|||||||
public class DefaultCardCollection implements MutableCardCollection {
|
public class DefaultCardCollection implements MutableCardCollection {
|
||||||
private Map<String, Integer> _counts = new TreeMap<String, Integer>(new CardBlueprintIdComparator());
|
private Map<String, Integer> _counts = new TreeMap<String, Integer>(new CardBlueprintIdComparator());
|
||||||
private Map<String, LotroCardBlueprint> _cards = new TreeMap<String, LotroCardBlueprint>();
|
private Map<String, LotroCardBlueprint> _cards = new TreeMap<String, LotroCardBlueprint>();
|
||||||
|
private LotroCardBlueprintLibrary _library;
|
||||||
|
|
||||||
|
public DefaultCardCollection(LotroCardBlueprintLibrary library) {
|
||||||
|
_library = library;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCards(String blueprintId, LotroCardBlueprint blueprint, int count) {
|
public void addCards(String blueprintId, LotroCardBlueprint blueprint, int count) {
|
||||||
@@ -34,7 +39,10 @@ public class DefaultCardCollection implements MutableCardCollection {
|
|||||||
filter = "";
|
filter = "";
|
||||||
String[] filterParams = filter.split(" ");
|
String[] filterParams = filter.split(" ");
|
||||||
|
|
||||||
String set = getSetNumber(filterParams);
|
String setStr = getSetNumber(filterParams);
|
||||||
|
String[] sets = null;
|
||||||
|
if (setStr != null)
|
||||||
|
sets = setStr.split(",");
|
||||||
List<CardType> cardTypes = getEnumFilter(CardType.values(), CardType.class, "cardType", null, filterParams);
|
List<CardType> cardTypes = getEnumFilter(CardType.values(), CardType.class, "cardType", null, filterParams);
|
||||||
List<Culture> cultures = getEnumFilter(Culture.values(), Culture.class, "culture", null, filterParams);
|
List<Culture> cultures = getEnumFilter(Culture.values(), Culture.class, "culture", null, filterParams);
|
||||||
List<Keyword> keywords = getEnumFilter(Keyword.values(), Keyword.class, "keyword", Collections.<Keyword>emptyList(), filterParams);
|
List<Keyword> keywords = getEnumFilter(Keyword.values(), Keyword.class, "keyword", Collections.<Keyword>emptyList(), filterParams);
|
||||||
@@ -50,7 +58,7 @@ public class DefaultCardCollection implements MutableCardCollection {
|
|||||||
if (blueprint == null)
|
if (blueprint == null)
|
||||||
result.add(new Item(Item.Type.PACK, count, blueprintId));
|
result.add(new Item(Item.Type.PACK, count, blueprintId));
|
||||||
else {
|
else {
|
||||||
if (set == null || blueprintId.startsWith(set + "_"))
|
if (sets == null || isInSets(blueprintId, sets))
|
||||||
if (cardTypes == null || cardTypes.contains(blueprint.getCardType()))
|
if (cardTypes == null || cardTypes.contains(blueprint.getCardType()))
|
||||||
if (cultures == null || cultures.contains(blueprint.getCulture()))
|
if (cultures == null || cultures.contains(blueprint.getCulture()))
|
||||||
if (containsAllKeywords(blueprint, keywords))
|
if (containsAllKeywords(blueprint, keywords))
|
||||||
@@ -77,6 +85,14 @@ public class DefaultCardCollection implements MutableCardCollection {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isInSets(String blueprintId, String[] sets) {
|
||||||
|
for (String set : sets)
|
||||||
|
if (blueprintId.startsWith(set + "_") || _library.hasAlternateInSet(blueprintId, Integer.parseInt(set)))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private String getSetNumber(String[] filterParams) {
|
private String getSetNumber(String[] filterParams) {
|
||||||
for (String filterParam : filterParams) {
|
for (String filterParam : filterParams) {
|
||||||
if (filterParam.startsWith("set:"))
|
if (filterParam.startsWith("set:"))
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class LotroServer extends AbstractServer {
|
|||||||
public LotroServer(DbAccess dbAccess, LotroCardBlueprintLibrary library, ChatServer chatServer, boolean test) {
|
public LotroServer(DbAccess dbAccess, LotroCardBlueprintLibrary library, ChatServer chatServer, boolean test) {
|
||||||
_lotroCardBlueprintLibrary = library;
|
_lotroCardBlueprintLibrary = library;
|
||||||
_chatServer = chatServer;
|
_chatServer = chatServer;
|
||||||
_defaultCollection = new DefaultCardCollection();
|
_defaultCollection = new DefaultCardCollection(library);
|
||||||
for (int i = 1; i <= 4; i++) {
|
for (int i = 1; i <= 4; i++) {
|
||||||
for (int j = 1; j <= 365; j++) {
|
for (int j = 1; j <= 365; j++) {
|
||||||
String blueprintId = i + "_" + j;
|
String blueprintId = i + "_" + j;
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public abstract class DefaultLotroFormat implements LotroFormat {
|
|||||||
throw new DeckInvalidException("One of the sites is from a different block than the format allows");
|
throw new DeckInvalidException("One of the sites is from a different block than the format allows");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_validSets != null) {
|
if (_validSets.size() > 0) {
|
||||||
validateSet(deck.getRingBearer());
|
validateSet(deck.getRingBearer());
|
||||||
validateSet(deck.getRing());
|
validateSet(deck.getRing());
|
||||||
for (String site : deck.getSites())
|
for (String site : deck.getSites())
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.gempukku.lotro.collection;
|
|||||||
import com.gempukku.lotro.game.CardCollection;
|
import com.gempukku.lotro.game.CardCollection;
|
||||||
import com.gempukku.lotro.game.DefaultCardCollection;
|
import com.gempukku.lotro.game.DefaultCardCollection;
|
||||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||||
|
import static junit.framework.Assert.assertEquals;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@@ -10,19 +11,19 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class CollectionSerializerTest {
|
public class CollectionSerializerTest {
|
||||||
@Test
|
@Test
|
||||||
public void testSerializeDeserialize() throws IOException {
|
public void testSerializeDeserialize() throws IOException {
|
||||||
DefaultCardCollection collection = new DefaultCardCollection();
|
LotroCardBlueprintLibrary library = new LotroCardBlueprintLibrary();
|
||||||
|
|
||||||
|
DefaultCardCollection collection = new DefaultCardCollection(library);
|
||||||
collection.addCards("1_1", null, 2);
|
collection.addCards("1_1", null, 2);
|
||||||
collection.addCards("1_231T", null, 3);
|
collection.addCards("1_231T", null, 3);
|
||||||
collection.addCards("1_23*", null, 3);
|
collection.addCards("1_23*", null, 3);
|
||||||
collection.addCards("1_237T*", null, 3);
|
collection.addCards("1_237T*", null, 3);
|
||||||
collection.addPacks("Fellowship of the Ring", 2);
|
collection.addPacks("Fellowship of the Ring", 2);
|
||||||
|
|
||||||
CollectionSerializer serializer = new CollectionSerializer(new LotroCardBlueprintLibrary());
|
CollectionSerializer serializer = new CollectionSerializer(library);
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
serializer.serializeCollection(collection, baos);
|
serializer.serializeCollection(collection, baos);
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
<b>6 Oct. 2011</b>
|
<b>6 Oct. 2011</b>
|
||||||
- "Hollowing of Isengard" now correctly discards itself upon use.
|
- "Hollowing of Isengard" now correctly discards itself upon use.
|
||||||
- Playing attached permanents now can have twilight cost modified (as for example per "Fell Voice on the Air").
|
- Playing attached permanents now can have twilight cost modified (as for example per "Fell Voice on the Air").
|
||||||
- Now the cards played on a site are finally correctly displayed if in Adventure Path (this time I actually tested it).
|
- Now the cards played on a site are finally correctly displayed if in Adventure Path (this time I actually tested it).
|
||||||
|
- Added additional format for testing that allows cards from any set and any number of them.
|
||||||
|
- Added filtering by block and new sets.
|
||||||
|
|
||||||
<b>5 Oct. 2011</b>
|
<b>5 Oct. 2011</b>
|
||||||
- Added timestamps to the chat messages in GameHall.
|
- Added timestamps to the chat messages in GameHall.
|
||||||
|
|||||||
@@ -64,9 +64,14 @@ var GempLotrDeckBuildingUI = Class.extend({
|
|||||||
|
|
||||||
combos.append("<select id='set'>"
|
combos.append("<select id='set'>"
|
||||||
+ "<option value=''>All Sets</option>"
|
+ "<option value=''>All Sets</option>"
|
||||||
|
+ "<option value='1,2,3'>Fellowship Block</option>"
|
||||||
+ "<option value='1'>01 - The Fellowship of the Ring</option>"
|
+ "<option value='1'>01 - The Fellowship of the Ring</option>"
|
||||||
+ "<option value='2'>02 - Mines of Moria</option>"
|
+ "<option value='2'>02 - Mines of Moria</option>"
|
||||||
+ "<option value='3'>03 - Realms of the Elf-lords</option>"
|
+ "<option value='3'>03 - Realms of the Elf-lords</option>"
|
||||||
|
+ "<option value='4,5,6'>The Two Towers Block</option>"
|
||||||
|
+ "<option value='4'>04 - The Two Towers</option>"
|
||||||
|
+ "<option value='5'>05 - Battle of Helm's Deep</option>"
|
||||||
|
+ "<option value='6'>06 - Ents of Fangorn</option>"
|
||||||
+ "</select>");
|
+ "</select>");
|
||||||
|
|
||||||
combos.append(" <select id='cardType'>"
|
combos.append(" <select id='cardType'>"
|
||||||
|
|||||||
Reference in New Issue
Block a user