From f8a1b8e177dd62b191818881124d486aafab1cd2 Mon Sep 17 00:00:00 2001 From: Christian 'ketura' McCarty Date: Wed, 11 Dec 2024 23:32:14 -0600 Subject: [PATCH] Fixed packs not having a count on them in the deckbuilder. Hopefully addressed card pack deliveries being out of sync. --- .../handler/CollectionRequestHandler.java | 26 +------------------ .../src/main/web/js/gemp-022/communication.js | 16 +++++++++--- .../main/web/js/gemp-022/deckBuildingUi.js | 12 ++++++++- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/CollectionRequestHandler.java b/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/CollectionRequestHandler.java index 402426773..c6c1485b1 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/CollectionRequestHandler.java +++ b/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/CollectionRequestHandler.java @@ -206,34 +206,10 @@ public class CollectionRequestHandler extends LotroServerRequestHandler implemen if (packContents == null) throw new HttpProcessingException(404); - DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); - - Document doc = documentBuilder.newDocument(); - - Element collectionElem = doc.createElement("pack"); - doc.appendChild(collectionElem); - - for (CardCollection.Item item : packContents.getAll()) { - String blueprintId = item.getBlueprintId(); - if (item.getType() == CardCollection.Item.Type.CARD) { - Element card = doc.createElement("card"); - card.setAttribute("count", String.valueOf(item.getCount())); - card.setAttribute("blueprintId", blueprintId); - appendCardSide(card, _library.getLotroCardBlueprint(blueprintId)); - collectionElem.appendChild(card); - } else { - Element pack = doc.createElement("pack"); - pack.setAttribute("count", String.valueOf(item.getCount())); - pack.setAttribute("blueprintId", blueprintId); - collectionElem.appendChild(pack); - } - } - Map headers = new HashMap<>(); processDeliveryServiceNotification(resourceOwner, headers); - responseWriter.writeXmlResponse(doc, headers); + responseWriter.writeXmlResponse(null, headers); } finally { postDecoder.destroy(); } diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/communication.js b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/communication.js index a4e3a5edd..b77917e05 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/communication.js +++ b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/communication.js @@ -43,6 +43,12 @@ var GempLotrCommunication = Class.extend({ }); }, + forcePackDelivery:function() { + if (window.deckbuilderDeliveryService != null) { + this.getPackDelivery(window.deckbuilderDeliveryService); + } + }, + getPackDelivery:function (callback) { $.ajax({ type:"GET", @@ -152,8 +158,8 @@ var GempLotrCommunication = Class.extend({ var that = this; return function (xml, status, request) { var delivery = request.getResponseHeader("Delivery-Service-Opened-Pack"); - if (delivery == "true" && window.deckbuilderDeliveryService != null) { - that.getPackDelivery(window.deckbuilderDeliveryService); + if (delivery == "true") { + that.forcePackDelivery(); } callback(xml); }; @@ -540,7 +546,8 @@ var GempLotrCommunication = Class.extend({ cache:false, data:{ participantId:getUrlParam("participantId"), - pack:pack}, + pack:pack + }, success:this.deckbuilderDeliveryCheck(callback), error:this.errorCheck(errorMap), dataType:"xml" @@ -554,7 +561,8 @@ var GempLotrCommunication = Class.extend({ data:{ participantId:getUrlParam("participantId"), pack:pack, - selection:selection}, + selection:selection + }, success:this.deckbuilderDeliveryCheck(callback), error:this.errorCheck(errorMap), dataType:"xml" diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/deckBuildingUi.js b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/deckBuildingUi.js index 264f557c0..e9be288bd 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/deckBuildingUi.js +++ b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/deckBuildingUi.js @@ -343,6 +343,7 @@ var GempLotrDeckBuildingUI = Class.extend({ }, this.checkDirtyInterval); this.updateFormatOptions(); + this.comm.forcePackDelivery(); }, setMapVisibility:function(value) { @@ -752,6 +753,11 @@ var GempLotrDeckBuildingUI = Class.extend({ } else if (selectedCardElem.hasClass("packInCollection")) { // if (confirm("Would you like to open this pack?")) { this.comm.openPack(this.getCollectionType(), selectedCardElem.data("card").blueprintId, function () { + + setTimeout(function (){ + console.log("forcing delivery"); + that.comm.forcePackDelivery(); + }, 1000); that.cardFilter.getCollection(); }, { "404":function () { @@ -761,6 +767,10 @@ var GempLotrDeckBuildingUI = Class.extend({ //} } else if (selectedCardElem.hasClass("cardToSelect")) { this.comm.openSelectionPack(this.getCollectionType(), this.packSelectionId, selectedCardElem.data("card").blueprintId, function () { + setTimeout(function (){ + console.log("forcing delivery"); + that.comm.forcePackDelivery(); + }, 1000); that.cardFilter.getCollection(); }, { "404":function () { @@ -1166,7 +1176,7 @@ var GempLotrDeckBuildingUI = Class.extend({ if (type == "pack") { var card = new Card(blueprintId, null, null, "pack", "collection", "player"); card.tokens = {"count":count}; - var cardDiv = Card.CreateCardDiv(card.imageUrl, null, null, false, false, true); + var cardDiv = Card.CreateCardDiv(card.imageUrl, null, null, false, true, true); cardDiv.data("card", card); if (blueprintId.substr(0, 3) == "(S)") {