Added Deck Builder filtering in collection by set and card type. Also cards in deck builder collection are sorted

by name.
This commit is contained in:
marcins78@gmail.com
2011-10-04 19:59:39 +00:00
parent e80cdd146d
commit 2b4c28e681
4 changed files with 88 additions and 16 deletions

View File

@@ -34,6 +34,7 @@ public class DefaultCardCollection implements MutableCardCollection {
filter = "";
String[] filterParams = filter.split(" ");
String set = getSetNumber(filterParams);
List<CardType> cardTypes = getEnumFilter(CardType.values(), CardType.class, "cardType", 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);
@@ -49,16 +50,41 @@ public class DefaultCardCollection implements MutableCardCollection {
if (blueprint == null)
result.add(new Item(Item.Type.PACK, count, blueprintId));
else {
if (cardTypes == null || cardTypes.contains(blueprint.getCardType()))
if (cultures == null || cultures.contains(blueprint.getCulture()))
if (containsAllKeywords(blueprint, keywords))
if (siteNumber == null || blueprint.getSiteNumber() == siteNumber.intValue())
result.add(new Item(Item.Type.CARD, count, blueprintId, blueprint));
if (set == null || blueprintId.startsWith(set + "_"))
if (cardTypes == null || cardTypes.contains(blueprint.getCardType()))
if (cultures == null || cultures.contains(blueprint.getCulture()))
if (containsAllKeywords(blueprint, keywords))
if (siteNumber == null || blueprint.getSiteNumber() == siteNumber.intValue())
result.add(new Item(Item.Type.CARD, count, blueprintId, blueprint));
}
}
Collections.sort(result, new Comparator<Item>() {
@Override
public int compare(Item o1, Item o2) {
if (o1.getType() == o2.getType()) {
if (o1.getType() == Item.Type.PACK)
return o1.getBlueprintId().compareTo(o2.getBlueprintId());
else
return o1.getCardBlueprint().getName().compareTo(o2.getCardBlueprint().getName());
} else {
if (o1.getType() == Item.Type.PACK)
return -1;
else
return 1;
}
}
});
return result;
}
private String getSetNumber(String[] filterParams) {
for (String filterParam : filterParams) {
if (filterParam.startsWith("set:"))
return filterParam.substring("set:".length());
}
return null;
}
private Integer getSiteNumber(String[] filterParams) {
for (String filterParam : filterParams) {
if (filterParam.startsWith("siteNumber:"))

View File

@@ -38,7 +38,15 @@
.ui-button-text-only .ui-button-text {
font-size: 70%;
padding: .1em .1em;
padding: .05em .05em;
}
#set {
width: 150px;
}
#cardType {
width: 120px;
}
</style>

View File

@@ -1,5 +1,7 @@
<pre style="font-size:80%">
4 Oct. 2011
- Added Deck Builder filtering in collection by set and card type. Also cards in deck builder collection are sorted
by name.
- Changed the rules system again.
- Most of the cards should now have animations when they affect other cards.
- Added cards from sets 02 and 03 ("Mines of Moria" and "Realm of the Elf Lords").

View File

@@ -55,17 +55,42 @@ var GempLotrDeckBuildingUI = Class.extend({
+ "<input type='checkbox' id='WRAITH'/><label for='WRAITH' id='labelWRAITH'><img src='images/cultures/wraith.gif'/></label>"
+ "</div>");
var combos = $("<div></div>");
combos.append("<select id='set'>"
+ "<option value=''>All Sets</option>"
+ "<option value='1'>01 - The Fellowship of the Ring</option>"
+ "<option value='2'>02 - Mines of Moria</option>"
+ "<option value='3'>03 - Realms of the Elf-lords</option>"
+ "</select>");
combos.append(" <select id='cardType'>"
+ "<option value=''>All Card Types</option>"
+ "<option value='COMPANION'>Companions</option>"
+ "<option value='ALLY'>Allies</option>"
+ "<option value='MINION'>Minions</option>"
+ "<option value='POSSESSION'>Possessions</option>"
+ "<option value='ARTIFACT'>Artifacts</option>"
+ "<option value='EVENT'>Events</option>"
+ "<option value='CONDITION'>Conditions</option>"
+ "</select>");
this.filterDiv.append(combos);
this.collectionDiv.append(this.filterDiv);
$("#culture").buttonset();
$("#labelDWARVEN,#labelELVEN,#labelGANDALF,#labelGONDOR,#labelSHIRE,#labelISENGARD,#labelMORIA,#labelSAURON,#labelWRAITH").click(
function() {
that.filter = that.calculateNormalFilter();
that.start = 0;
that.getCollection();
return true;
});
var filterOut = function() {
that.filter = that.calculateNormalFilter();
that.start = 0;
that.getCollection();
return true;
};
$("#set").change(filterOut);
$("#cardType").change(filterOut);
$("#labelDWARVEN,#labelELVEN,#labelGANDALF,#labelGONDOR,#labelSHIRE,#labelISENGARD,#labelMORIA,#labelSAURON,#labelWRAITH").click(filterOut);
$("#countSlider").slider({
value:18,
@@ -341,10 +366,21 @@ var GempLotrDeckBuildingUI = Class.extend({
if ($(this).hasClass("ui-state-active"))
cultures.push($(this).prop("id").substring(5));
});
if (cultures.length > 0)
return "cardType:-SITE,THE_ONE_RING culture:" + cultures;
var setNo = $("#set option:selected").prop("value");
if (setNo != "")
setNo = " set:" + setNo;
var cardType = $("#cardType option:selected").prop("value");
if (cardType == "")
cardType = "cardType:-SITE,THE_ONE_RING";
else
return "cardType:-SITE,THE_ONE_RING";
cardType = "cardType:" + cardType;
if (cultures.length > 0)
return cardType + setNo + " culture:" + cultures;
else
return cardType + setNo;
},
addCardToDeck: function(blueprintId, side) {