Work on merchant.
This commit is contained in:
@@ -8,7 +8,7 @@ import com.gempukku.lotro.common.Keyword;
|
||||
import java.util.*;
|
||||
|
||||
public class SortAndFilterCards {
|
||||
public <T extends CardItem> List<T> process(String filter, List<T> items, LotroCardBlueprintLibrary library, Map<String, SetRarity> rarities) {
|
||||
public <T extends CardItem> List<T> process(String filter, Collection<T> items, LotroCardBlueprintLibrary library, Map<String, SetRarity> rarities) {
|
||||
if (filter == null)
|
||||
filter = "";
|
||||
String[] filterParams = filter.split(" ");
|
||||
|
||||
@@ -18,10 +18,7 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Singleton
|
||||
@Path("/merchant")
|
||||
@@ -74,9 +71,13 @@ public class MerchantResource extends AbstractResource {
|
||||
|
||||
CardCollection collection = _collectionsManager.getPlayerCollection(resourceOwner, "permanent");
|
||||
|
||||
List<CardItem> cardItems = new ArrayList<CardItem>();
|
||||
Set<CardItem> cardItems = new HashSet<CardItem>();
|
||||
cardItems.addAll(collection.getAllItems());
|
||||
cardItems.addAll(_merchantService.getSellableItems());
|
||||
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>();
|
||||
|
||||
@@ -29,7 +29,7 @@ var CardFilter = Class.extend({
|
||||
this.addCardFunc = addCardFunc;
|
||||
this.finishCollectionFunc = finishCollectionFunc;
|
||||
|
||||
this.filter = "cardType:-THE_ONE_RING";
|
||||
this.filter = "";
|
||||
|
||||
this.buildUi(elem);
|
||||
},
|
||||
@@ -303,9 +303,9 @@ var CardFilter = Class.extend({
|
||||
|
||||
var cardType = $("#cardType option:selected").prop("value");
|
||||
if (cardType == "")
|
||||
cardType = "cardType:-THE_ONE_RING";
|
||||
cardType = "";
|
||||
else
|
||||
cardType = "cardType:" + cardType;
|
||||
cardType = "cardType:" + cardType + " ";
|
||||
|
||||
var keyword = $("#keyword option:selected").prop("value");
|
||||
if (keyword != "")
|
||||
@@ -349,7 +349,7 @@ var CardFilter = Class.extend({
|
||||
|
||||
getCollection: function() {
|
||||
var that = this;
|
||||
this.getCollectionFunc(this.filter + this.calculateFullFilterPostfix(), this.start, this.count, function(xml) {
|
||||
this.getCollectionFunc((this.filter + this.calculateFullFilterPostfix()).trim(), this.start, this.count, function(xml) {
|
||||
that.displayCollection(xml);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -83,11 +83,11 @@ var packBlueprints = {
|
||||
|
||||
"RoS - Faramir Starter": "/gemp-lotr/images/boosters/eof_faramir_starter.png",
|
||||
"RoS - Witch-king Starter": "/gemp-lotr/images/boosters/eof_witch_king_starter.png",
|
||||
"RoS - Booster": "/gemp-lotr/images/boosters/ros_booster.jpg",
|
||||
"RoS - Booster": "/gemp-lotr/images/boosters/ros_booster.png",
|
||||
|
||||
"TaD - Faramir Starter": "/gemp-lotr/images/boosters/eof_faramir_starter.png",
|
||||
"TaD - Witch-king Starter": "/gemp-lotr/images/boosters/eof_witch_king_starter.png",
|
||||
"TaD - Booster": "/gemp-lotr/images/boosters/tad_booster.jpg"
|
||||
"TaD - Booster": "/gemp-lotr/images/boosters/tad_booster.png"
|
||||
};
|
||||
|
||||
var Card = Class.extend({
|
||||
|
||||
@@ -56,6 +56,19 @@ var GempLotrMerchantUI = Class.extend({
|
||||
};
|
||||
this.infoDialog.swipe(swipeOptions);
|
||||
|
||||
$("body").click(
|
||||
function (event) {
|
||||
return that.clickCardFunction(event);
|
||||
});
|
||||
$("body").mousedown(
|
||||
function (event) {
|
||||
return that.dragStartCardFunction(event);
|
||||
});
|
||||
$("body").mouseup(
|
||||
function (event) {
|
||||
return that.dragStopCardFunction(event);
|
||||
});
|
||||
|
||||
this.cardFilter.getCollection();
|
||||
},
|
||||
|
||||
@@ -96,6 +109,34 @@ var GempLotrMerchantUI = Class.extend({
|
||||
return true;
|
||||
},
|
||||
|
||||
clickCardFunction: function(event) {
|
||||
var that = this;
|
||||
|
||||
var tar = $(event.target);
|
||||
if (!this.successfulDrag && this.infoDialog.dialog("isOpen")) {
|
||||
this.infoDialog.dialog("close");
|
||||
event.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tar.hasClass("actionArea")) {
|
||||
tar = tar.parent();
|
||||
if (tar.hasClass("borderOverlay")) {
|
||||
var selectedCardElem = tar.parent();
|
||||
if (event.which == 1) {
|
||||
if (!this.successfulDrag) {
|
||||
if (event.shiftKey) {
|
||||
this.displayCardInfo(selectedCardElem.data("card"));
|
||||
}
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
displayCardInfo: function(card) {
|
||||
this.infoDialog.html("");
|
||||
this.infoDialog.html("<div style='scroll: auto'></div>");
|
||||
@@ -121,19 +162,55 @@ var GempLotrMerchantUI = Class.extend({
|
||||
},
|
||||
|
||||
addCardToList: function(elem, type, blueprintId, count) {
|
||||
var buyPrice = elem.getAttribute("buyPrice");
|
||||
var sellPrice = elem.getAttribute("sellPrice");
|
||||
var tradeFoil = elem.getAttribute("tradeFoil");
|
||||
|
||||
var sizeListeners = new Array();
|
||||
sizeListeners[0] = {
|
||||
sizeChanged: function(cardElem, width, height) {
|
||||
$(".owned", cardElem).css({position:"absolute", left:5, top: height - 60, width: 30, height: 30});
|
||||
$(".buyPrice", cardElem).css({position: "absolute", left: 40, top: height - 80, width: width - 45, height: 25});
|
||||
$(".sellPrice", cardElem).css({position: "absolute", left: 40, top: height - 50, width: width - 45, height: 25});
|
||||
$(".tradeFoil", cardElem).css({position: "absolute", left: 40, top: height - 20, width: width - 45, height: 15});
|
||||
}
|
||||
};
|
||||
|
||||
var cardDiv = null;
|
||||
|
||||
if (type == "pack") {
|
||||
var card = new Card(blueprintId, "merchant", "collection", "player");
|
||||
card.tokens = {"count":count};
|
||||
var cardDiv = createCardDiv(card.imageUrl, null, false, true, true);
|
||||
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.tokens = {"count":count};
|
||||
var cardDiv = createCardDiv(card.imageUrl, null, card.isFoil());
|
||||
cardDiv = createCardDiv(card.imageUrl, null, card.isFoil());
|
||||
cardDiv.data("card", card);
|
||||
cardDiv.data("sizeListeners", sizeListeners);
|
||||
this.cardsDiv.append(cardDiv);
|
||||
}
|
||||
|
||||
if (cardDiv != null) {
|
||||
cardDiv.append("<div class='owned'>" + count + "</div>");
|
||||
if (buyPrice != null) {
|
||||
var buyBut = $("<div class='buyPrice'>Buy price<br/>" + this.formatPrice(buyPrice) + "</div>").button();
|
||||
cardDiv.append(buyBut);
|
||||
}
|
||||
if (sellPrice != null) {
|
||||
var sellBut = $("<div class='sellPrice'>Sell price<br/>" + this.formatPrice(sellPrice) + "</div>").button();
|
||||
cardDiv.append(sellBut);
|
||||
}
|
||||
if (tradeFoil == "true") {
|
||||
var tradeFoilBut = $("<div class='tradeFoil'>Trade 4 for foil</div>").button();
|
||||
cardDiv.append(tradeFoilBut);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
formatPrice: function(price) {
|
||||
return Math.floor(price / 100) + "G " + price % 100 + "S";
|
||||
},
|
||||
|
||||
finishList: function() {
|
||||
|
||||
@@ -19,21 +19,11 @@
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
.selectableCard > .borderOverlay {
|
||||
border: 2px solid #00ff00;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.selectedCard > .borderOverlay {
|
||||
border: 2px solid #00cccc;
|
||||
}
|
||||
|
||||
.cardCount {
|
||||
width: 20px;
|
||||
height: 18px;
|
||||
.owned {
|
||||
background-color: #000000;
|
||||
border: 1px solid #ffffff;
|
||||
color: #ffffff;
|
||||
font-size: 120%;
|
||||
font-size: 220%;
|
||||
font-weight: bolder;
|
||||
display: table-cell;
|
||||
text-align: center;
|
||||
@@ -41,22 +31,8 @@
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.ui-layout-east {
|
||||
width: 350px;
|
||||
}
|
||||
|
||||
#manageDecks {
|
||||
color: #ffffff;
|
||||
font-size: 180%;
|
||||
}
|
||||
|
||||
#editingDeck {
|
||||
vertical-align: top;
|
||||
padding-left: 3px;
|
||||
}
|
||||
|
||||
#deckStats {
|
||||
color: #ffffff;
|
||||
.buyPrice, .sellPrice, .tradeFoil {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.ui-button-text-only .ui-button-text {
|
||||
@@ -72,15 +48,15 @@
|
||||
}
|
||||
|
||||
#fullFiltering select {
|
||||
font-size: 80%;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
#fullFiltering input {
|
||||
font-size: 80%;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
#filtering select {
|
||||
font-size: 80%;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user