Adding filtering by minimum count of owned cards.
This commit is contained in:
@@ -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>();
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user