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 0392d5331..ee363d375 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 @@ -14,6 +14,7 @@ public class DefaultCardCollection implements MutableCardCollection { public DefaultCardCollection(CardCollection cardCollection) { _counts.putAll(cardCollection.getAll()); + _currency = cardCollection.getCurrency(); } public void addCurrency(int currency) { diff --git a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/AbstractResource.java b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/AbstractResource.java index f61213478..f133a7e56 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/AbstractResource.java +++ b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/AbstractResource.java @@ -35,7 +35,7 @@ public abstract class AbstractResource { Integer lastReward = player.getLastLoginReward(); if (lastReward == null) { _playerDao.setLastReward(player, latestMonday); - _collectionManager.addCurrencyToPlayerCollection(player, new CollectionType("permanent", "My cards"), 5000); + _collectionManager.addCurrencyToPlayerCollection(player, new CollectionType("permanent", "My cards"), 20000); } else { if (latestMonday == lastReward) { if (_playerDao.updateLastReward(player, lastReward, latestMonday)) diff --git a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/MerchantResource.java b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/MerchantResource.java index dfad23e0c..bddd3d1c5 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/MerchantResource.java +++ b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/MerchantResource.java @@ -114,7 +114,7 @@ public class MerchantResource extends AbstractResource { elem.setAttribute("tradeFoil", "true"); elem.setAttribute("blueprintId", blueprintId); Integer buyPrice = buyPrices.get(blueprintId); - if (buyPrice != null) + if (buyPrice != null && collection.getItemCount(blueprintId) > 0) elem.setAttribute("buyPrice", buyPrice.toString()); Integer sellPrice = sellPrices.get(blueprintId); if (sellPrice != null) @@ -129,9 +129,9 @@ public class MerchantResource extends AbstractResource { @POST @Produces(MediaType.APPLICATION_XML) public Document buyItem( - @QueryParam("participantId") String participantId, - @QueryParam("blueprintId") String blueprintId, - @QueryParam("price") int price, + @FormParam("participantId") String participantId, + @FormParam("blueprintId") String blueprintId, + @FormParam("price") int price, @Context HttpServletRequest request, @Context HttpServletResponse response) throws ParserConfigurationException { Player resourceOwner = getResourceOwnerSafely(request, participantId); @@ -147,9 +147,9 @@ public class MerchantResource extends AbstractResource { @POST @Produces(MediaType.APPLICATION_XML) public Document sellItem( - @QueryParam("participantId") String participantId, - @QueryParam("blueprintId") String blueprintId, - @QueryParam("price") int price, + @FormParam("participantId") String participantId, + @FormParam("blueprintId") String blueprintId, + @FormParam("price") int price, @Context HttpServletRequest request, @Context HttpServletResponse response) throws ParserConfigurationException { Player resourceOwner = getResourceOwnerSafely(request, participantId); @@ -165,8 +165,8 @@ public class MerchantResource extends AbstractResource { @POST @Produces(MediaType.APPLICATION_XML) public Document tradeInFoil( - @QueryParam("participantId") String participantId, - @QueryParam("blueprintId") String blueprintId, + @FormParam("participantId") String participantId, + @FormParam("blueprintId") String blueprintId, @Context HttpServletRequest request, @Context HttpServletResponse response) throws ParserConfigurationException { Player resourceOwner = getResourceOwnerSafely(request, participantId); diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/cardFilter.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/cardFilter.js index 93916491a..5e1032adf 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/cardFilter.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/cardFilter.js @@ -358,7 +358,7 @@ var CardFilter = Class.extend({ log(xml); var root = xml.documentElement; - this.clearCollectionFunc(root.tagName); + this.clearCollectionFunc(root); var packs = root.getElementsByTagName("pack"); for (var i = 0; i < packs.length; i++) { diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/communication.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/communication.js index 52c92f6d2..c2ac14b81 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/communication.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/communication.js @@ -179,6 +179,47 @@ var GempLotrCommunication = Class.extend({ dataType: "xml" }); }, + buyItem: function(blueprintId, price, callback) { + $.ajax({ + type: "POST", + url: this.url + "/merchant/buy", + cache: false, + data: { + participantId: getUrlParam("participantId"), + blueprintId: blueprintId, + price: price}, + success: this.deliveryCheck(callback), + error: this.failure, + dataType: "xml" + }); + }, + sellItem: function(blueprintId, price, callback) { + $.ajax({ + type: "POST", + url: this.url + "/merchant/sell", + cache: false, + data: { + participantId: getUrlParam("participantId"), + blueprintId: blueprintId, + price: price}, + success: this.deliveryCheck(callback), + error: this.failure, + dataType: "xml" + }); + }, + tradeInFoil: function(blueprintId, callback) { + $.ajax({ + type: "POST", + url: this.url + "/merchant/tradeFoil", + cache: false, + data: { + participantId: getUrlParam("participantId"), + blueprintId: blueprintId}, + success: this.deliveryCheck(callback), + error: this.failure, + dataType: "xml" + }); + }, getCollection: function(collectionType, filter, start, count, callback) { $.ajax({ type: "GET", diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/merchantUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/merchantUi.js index 4610f601d..0e4662040 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/merchantUi.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/merchantUi.js @@ -8,6 +8,9 @@ var GempLotrMerchantUI = Class.extend({ cardFilter: null, infoDialog: null, + questionDialog: null, + + currencyCount: null, init: function(cardListElem, cardFilterElem) { var that = this; @@ -18,8 +21,8 @@ var GempLotrMerchantUI = Class.extend({ function(filter, start, count, callback) { that.comm.getMerchant(filter, start, count, callback); }, - function() { - that.clearList(); + function(rootElem) { + that.clearList(rootElem); }, function(elem, type, blueprintId, count) { that.addCardToList(elem, type, blueprintId, count); @@ -43,6 +46,15 @@ var GempLotrMerchantUI = Class.extend({ title: "Card information" }); + this.questionDialog = $("
") + .dialog({ + autoOpen: false, + closeOnEscape: true, + resizable: false, + modal: true, + title: "Merchant operation" + }); + var swipeOptions = { threshold: 20, swipeUp: function (event) { @@ -157,8 +169,9 @@ var GempLotrMerchantUI = Class.extend({ this.infoDialog.dialog("open"); }, - clearList: function() { + clearList: function(rootElem) { $(".card", this.cardsDiv).remove(); + this.currencyCount = rootElem.getAttribute("currency"); }, addCardToList: function(elem, type, blueprintId, count) { @@ -177,15 +190,16 @@ var GempLotrMerchantUI = Class.extend({ }; var cardDiv = null; + var card = null; if (type == "pack") { - var card = new Card(blueprintId, "merchant", "collection", "player"); + card = new Card(blueprintId, "merchant", "collection", "player"); cardDiv = createCardDiv(card.imageUrl, null, false, true, true); cardDiv.data("card", card); cardDiv.data("sizeListeners", sizeListeners); this.cardsDiv.append(cardDiv); } else if (type == "card") { - var card = new Card(blueprintId, "merchant", "collection", "player"); + card = new Card(blueprintId, "merchant", "collection", "player"); cardDiv = createCardDiv(card.imageUrl, null, card.isFoil()); cardDiv.data("card", card); cardDiv.data("sizeListeners", sizeListeners); @@ -193,22 +207,88 @@ var GempLotrMerchantUI = Class.extend({ } if (cardDiv != null) { + var that = this; cardDiv.append("