diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/DefaultCardCollection.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/DefaultCardCollection.java index ebac5c7c6..12a0235b4 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/DefaultCardCollection.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/DefaultCardCollection.java @@ -43,6 +43,7 @@ public class DefaultCardCollection implements MutableCardCollection { String[] sets = null; if (setStr != null) sets = setStr.split(","); + List words = getWords(filterParams); List cardTypes = getEnumFilter(CardType.values(), CardType.class, "cardType", null, filterParams); List cultures = getEnumFilter(Culture.values(), Culture.class, "culture", null, filterParams); List keywords = getEnumFilter(Keyword.values(), Keyword.class, "keyword", Collections.emptyList(), filterParams); @@ -62,8 +63,9 @@ public class DefaultCardCollection implements MutableCardCollection { if (cardTypes == null || cardTypes.contains(blueprint.getCardType())) if (cultures == null || cultures.contains(blueprint.getCulture())) if (containsAllKeywords(blueprint, keywords)) - if (siteNumber == null || blueprint.getSiteNumber() == siteNumber) - result.add(new Item(Item.Type.CARD, count, blueprintId, blueprint)); + if (containsAllWords(blueprint, words)) + if (siteNumber == null || blueprint.getSiteNumber() == siteNumber) + result.add(new Item(Item.Type.CARD, count, blueprintId, blueprint)); } } Collections.sort(result, new Comparator() { @@ -101,6 +103,15 @@ public class DefaultCardCollection implements MutableCardCollection { return null; } + private List getWords(String[] filterParams) { + List result = new LinkedList(); + for (String filterParam : filterParams) { + if (filterParam.startsWith("name:")) + result.add(filterParam.substring("name:".length())); + } + return result; + } + private Integer getSiteNumber(String[] filterParams) { for (String filterParam : filterParams) { if (filterParam.startsWith("siteNumber:")) @@ -117,6 +128,14 @@ public class DefaultCardCollection implements MutableCardCollection { return true; } + private boolean containsAllWords(LotroCardBlueprint blueprint, List words) { + for (String word : words) { + if (blueprint == null || !blueprint.getName().toLowerCase().contains(word.toLowerCase())) + return false; + } + return true; + } + private List getEnumFilter(T[] enumValues, Class enumType, String prefix, List defaultResult, String[] filterParams) { for (String filterParam : filterParams) { if (filterParam.startsWith(prefix + ":")) { diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html index 80e7b32cd..ba142945d 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html @@ -1,4 +1,9 @@
+3 Nov. 2011
+- Deck builder now allows to filter sites, rings and ring-bearers on set/block.
+- Deck builder now allows to filter deck cards based on their printed keywords.
+- Deck builder now allows to filter by words in card name.
+
 2 Nov. 2011
 - "O Elbereth! Gilthoniel!" should correctly give the option to cancel a skirmish with Nazgul when used in skirmish
 against Nazgul.
diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/deckBuildingUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/deckBuildingUi.js
index 5a64dd80d..2a1599960 100644
--- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/deckBuildingUi.js
+++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/deckBuildingUi.js
@@ -20,6 +20,7 @@ var GempLotrDeckBuildingUI = Class.extend({
     specialCollectionGroup: null,
     selectionFunc: null,
     pageDiv: null,
+    fullFilterDiv: null,
     filterDiv: null,
     drawDeckDiv: null,
     fpDeckGroup: null,
@@ -124,9 +125,29 @@ var GempLotrDeckBuildingUI = Class.extend({
         this.pageDiv = $("
"); this.pageDiv.append(""); this.pageDiv.append(""); - this.pageDiv.append("
"); + this.pageDiv.append("
"); this.collectionDiv.append(this.pageDiv); + this.fullFilterDiv = $("
"); + this.fullFilterDiv.append(""); + this.fullFilterDiv.append(""); + this.collectionDiv.append(this.fullFilterDiv); + this.filterDiv = $("
"); this.filterDiv.append("
" @@ -149,23 +170,6 @@ var GempLotrDeckBuildingUI = Class.extend({ var combos = $("
"); - combos.append(""); - combos.append(" "); + combos.append(" "); this.filterDiv.append(combos); this.collectionDiv.append(this.filterDiv); @@ -185,6 +216,15 @@ var GempLotrDeckBuildingUI = Class.extend({ $("#culture1").buttonset(); $("#culture2").buttonset(); + var fullFilterChanged = function() { + that.start = 0; + that.getCollection(); + return true; + }; + + $("#set").change(fullFilterChanged); + $("#cardName").change(fullFilterChanged); + var filterOut = function() { that.filter = that.calculateNormalFilter(); that.start = 0; @@ -192,8 +232,8 @@ var GempLotrDeckBuildingUI = Class.extend({ return true; }; - $("#set").change(filterOut); $("#cardType").change(filterOut); + $("#keyword").change(filterOut); $("#labelDWARVEN,#labelELVEN,#labelGANDALF,#labelGONDOR,#labelROHAN,#labelSHIRE,#labelGOLLUM,#labelDUNLAND,#labelISENGARD,#labelMORIA,#labelRAIDER,#labelSAURON,#labelWRAITH").click(filterOut); @@ -561,6 +601,24 @@ var GempLotrDeckBuildingUI = Class.extend({ this.selectionFunc = this.addCardToDeck; }, + calculateFullFilterPostfix: function() { + var setNo = $("#set option:selected").prop("value"); + if (setNo != "") + setNo = " set:" + setNo; + + var cardName = $("#cardName").val(); + if (cardName == "Card name") + cardName = ""; + else { + var cardNameElems = cardName.split(" "); + cardName = ""; + for (var i = 0; i < cardNameElems.length; i++) + cardName += " name:" + cardNameElems[i]; + } + + return setNo + cardName; + }, + calculateNormalFilter: function() { var cultures = new Array(); $("label", $("#culture1")).each( @@ -574,20 +632,20 @@ var GempLotrDeckBuildingUI = Class.extend({ cultures.push($(this).prop("id").substring(5)); }); - 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 cardType = "cardType:" + cardType; + var keyword = $("#keyword option:selected").prop("value"); + if (keyword != "") + keyword = " keyword:" + keyword; + if (cultures.length > 0) - return cardType + setNo + " culture:" + cultures; + return cardType + " culture:" + cultures + keyword; else - return cardType + setNo; + return cardType + keyword; }, addCardToDeck: function(blueprintId, side) { @@ -659,7 +717,7 @@ var GempLotrDeckBuildingUI = Class.extend({ getCollection: function() { var that = this; - this.comm.getCollection(this.collectionType, this.filter, this.start, this.count, function(xml) { + this.comm.getCollection(this.collectionType, this.filter + this.calculateFullFilterPostfix(), this.start, this.count, function(xml) { that.displayCollection(xml); }); }, @@ -771,13 +829,15 @@ var GempLotrDeckBuildingUI = Class.extend({ this.bottomBarDiv.css({ position: "absolute", left: padding * 3 + sitesWidth * 2, top: manageHeight + padding + deckHeight - 50, width: deckWidth - (sitesWidth + padding) * 2 - padding, height: 50 }); - this.filterDiv.css({ position: "absolute", left: padding, top: 50, width: collectionWidth - padding, height: 80 }); - this.normalCollectionDiv.css({ position: "absolute", left: padding, top: 130, width: collectionWidth - padding * 2, height: collectionHeight - 130 }); this.pageDiv.css({ position: "absolute", left: padding, top: 0, width: collectionWidth - padding, height: 50 }); - this.specialCollectionDiv.css({ position: "absolute", left: padding, top: 50, width: collectionWidth - padding * 2, height: collectionHeight - 50 }); + $("#countSlider").css({width: collectionWidth - padding - 100}); + this.fullFilterDiv.css({position:"absolute", left: padding, top: 50, width: collectionWidth - padding, height: 30}); + this.filterDiv.css({ position: "absolute", left: padding, top: 80, width: collectionWidth - padding, height: 80 }); + this.normalCollectionDiv.css({ position: "absolute", left: padding, top: 160, width: collectionWidth - padding * 2, height: collectionHeight - 160 }); + this.specialCollectionDiv.css({ position: "absolute", left: padding, top: 80, width: collectionWidth - padding * 2, height: collectionHeight - 80 }); - this.normalCollectionGroup.setBounds(0, 0, collectionWidth - padding * 2, collectionHeight - 130); - this.specialCollectionGroup.setBounds(0, 0, collectionWidth - padding * 2, collectionHeight - 50); + this.normalCollectionGroup.setBounds(0, 0, collectionWidth - padding * 2, collectionHeight - 160); + this.specialCollectionGroup.setBounds(0, 0, collectionWidth - padding * 2, collectionHeight - 80); }, processError: function (xhr, ajaxOptions, thrownError) {