Adding filtering by minimum count of owned cards.

This commit is contained in:
marcins78@gmail.com
2012-03-14 15:02:36 +00:00
parent f6de3457bc
commit 20c499a57b
3 changed files with 16 additions and 6 deletions

View File

@@ -63,6 +63,7 @@ public class MerchantResource extends AbstractResource {
public Document getCollection(
@QueryParam("participantId") String participantId,
@QueryParam("filter") String filter,
@QueryParam("ownedMin") int ownedMin,
@QueryParam("start") int start,
@QueryParam("count") int count,
@Context HttpServletRequest request,
@@ -72,12 +73,19 @@ public class MerchantResource extends AbstractResource {
CardCollection collection = _collectionsManager.getPlayerCollection(resourceOwner, "permanent");
Set<CardItem> cardItems = new HashSet<CardItem>();
cardItems.addAll(collection.getAllItems());
Set<CardItem> items = _merchantService.getSellableItems();
for (CardItem item : items) {
if (collection.getItemCount(item.getBlueprintId()) == 0)
final List<CardCollection.Item> allItems = collection.getAllItems();
for (CardCollection.Item item : allItems) {
if (item.getCount() >= ownedMin)
cardItems.add(item);
}
if (ownedMin <= 0) {
Set<CardItem> items = _merchantService.getSellableItems();
for (CardItem item : items) {
if (collection.getItemCount(item.getBlueprintId()) == 0)
cardItems.add(item);
}
}
List<CardItem> filteredResult = _sortAndFilterCards.process(filter, cardItems, _library, _rarities);
List<CardItem> pageToDisplay = new ArrayList<CardItem>();

View File

@@ -164,7 +164,7 @@ var GempLotrCommunication = Class.extend({
dataType: "xml"
});
},
getMerchant: function(filter, start, count, callback) {
getMerchant: function(filter, ownedMin, start, count, callback) {
$.ajax({
type: "GET",
url: this.url + "/merchant",
@@ -172,6 +172,7 @@ var GempLotrCommunication = Class.extend({
data: {
participantId: getUrlParam("participantId"),
filter: filter,
ownedMin: ownedMin,
start: start,
count: count},
success: this.deliveryCheck(callback),

View File

@@ -13,6 +13,7 @@ var GempLotrMerchantUI = Class.extend({
questionDialog: null,
currencyCount: null,
ownedMin: 0,
init: function(cardListElem, cardFilterElem) {
var that = this;
@@ -21,7 +22,7 @@ var GempLotrMerchantUI = Class.extend({
this.cardFilter = new CardFilter(cardFilterElem,
function(filter, start, count, callback) {
that.comm.getMerchant(filter, start, count, callback);
that.comm.getMerchant(filter, that.ownedMin, start, count, callback);
},
function(rootElem) {
that.clearList(rootElem);