Deck building.
This commit is contained in:
@@ -3,6 +3,8 @@ package com.gempukku.lotro.server;
|
|||||||
import com.gempukku.lotro.cards.packs.RarityReader;
|
import com.gempukku.lotro.cards.packs.RarityReader;
|
||||||
import com.gempukku.lotro.cards.packs.SetRarity;
|
import com.gempukku.lotro.cards.packs.SetRarity;
|
||||||
import com.gempukku.lotro.collection.CollectionsManager;
|
import com.gempukku.lotro.collection.CollectionsManager;
|
||||||
|
import com.gempukku.lotro.common.CardType;
|
||||||
|
import com.gempukku.lotro.common.Keyword;
|
||||||
import com.gempukku.lotro.common.Side;
|
import com.gempukku.lotro.common.Side;
|
||||||
import com.gempukku.lotro.db.vo.CollectionType;
|
import com.gempukku.lotro.db.vo.CollectionType;
|
||||||
import com.gempukku.lotro.db.vo.League;
|
import com.gempukku.lotro.db.vo.League;
|
||||||
@@ -114,9 +116,9 @@ public class CollectionResource extends AbstractResource {
|
|||||||
Element card = doc.createElement("card");
|
Element card = doc.createElement("card");
|
||||||
card.setAttribute("count", String.valueOf(item.getCount()));
|
card.setAttribute("count", String.valueOf(item.getCount()));
|
||||||
card.setAttribute("blueprintId", blueprintId);
|
card.setAttribute("blueprintId", blueprintId);
|
||||||
Side side = _library.getLotroCardBlueprint(blueprintId).getSide();
|
LotroCardBlueprint blueprint = _library.getLotroCardBlueprint(blueprintId);
|
||||||
if (side != null)
|
appendCardSide(card, blueprint);
|
||||||
card.setAttribute("side", side.toString());
|
appendCardGroup(card, blueprint);
|
||||||
collectionElem.appendChild(card);
|
collectionElem.appendChild(card);
|
||||||
} else {
|
} else {
|
||||||
Element pack = doc.createElement("pack");
|
Element pack = doc.createElement("pack");
|
||||||
@@ -140,6 +142,30 @@ public class CollectionResource extends AbstractResource {
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void appendCardSide(Element card, LotroCardBlueprint blueprint) {
|
||||||
|
Side side = blueprint.getSide();
|
||||||
|
if (side != null)
|
||||||
|
card.setAttribute("side", side.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendCardGroup(Element card, LotroCardBlueprint blueprint) {
|
||||||
|
String group;
|
||||||
|
if (blueprint.getCardType() == CardType.THE_ONE_RING)
|
||||||
|
group="ring";
|
||||||
|
else if (blueprint.getCardType() == CardType.SITE)
|
||||||
|
group="site";
|
||||||
|
else if (blueprint.hasKeyword(Keyword.CAN_START_WITH_RING))
|
||||||
|
group="ringBearer";
|
||||||
|
else if (blueprint.getSide() == Side.FREE_PEOPLE)
|
||||||
|
group="fp";
|
||||||
|
else if (blueprint.getSide() == Side.SHADOW)
|
||||||
|
group="shadow";
|
||||||
|
else
|
||||||
|
group = null;
|
||||||
|
if (group != null)
|
||||||
|
card.setAttribute("group", group);
|
||||||
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_XML)
|
@Produces(MediaType.APPLICATION_XML)
|
||||||
public Document getCollectionTypes(
|
public Document getCollectionTypes(
|
||||||
@@ -205,9 +231,7 @@ public class CollectionResource extends AbstractResource {
|
|||||||
Element card = doc.createElement("card");
|
Element card = doc.createElement("card");
|
||||||
card.setAttribute("count", String.valueOf(item.getCount()));
|
card.setAttribute("count", String.valueOf(item.getCount()));
|
||||||
card.setAttribute("blueprintId", blueprintId);
|
card.setAttribute("blueprintId", blueprintId);
|
||||||
Side side = _library.getLotroCardBlueprint(blueprintId).getSide();
|
appendCardSide(card, _library.getLotroCardBlueprint(blueprintId));
|
||||||
if (side != null)
|
|
||||||
card.setAttribute("side", side.toString());
|
|
||||||
collectionElem.appendChild(card);
|
collectionElem.appendChild(card);
|
||||||
} else {
|
} else {
|
||||||
Element pack = doc.createElement("pack");
|
Element pack = doc.createElement("pack");
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// Each card should have properties:
|
||||||
|
// group: ring, ringBearer, site, fp, shadow
|
||||||
var DeckPanel = Class.extend({
|
var DeckPanel = Class.extend({
|
||||||
tabs:null,
|
tabs:null,
|
||||||
|
|
||||||
@@ -105,9 +107,33 @@ var DeckPanel = Class.extend({
|
|||||||
|
|
||||||
addCard: function(cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc) {
|
addCard: function(cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc) {
|
||||||
var selectedTabIndex = this.tabs.tabs('option', 'selected');
|
var selectedTabIndex = this.tabs.tabs('option', 'selected');
|
||||||
|
|
||||||
this.ringBearerContainer.addCard(cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc);
|
|
||||||
this.ringBearerContainer.layoutCards();
|
|
||||||
|
|
||||||
|
var group = cardProps["group"];
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
var addCardToGroup = function (groupContainer, titlePrefix, tabHref) {
|
||||||
|
groupContainer.addCard(cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc);
|
||||||
|
groupContainer.layoutCards();
|
||||||
|
var count = groupContainer.getCardsCount();
|
||||||
|
var title = titlePrefix+" ("+count+")";
|
||||||
|
$(".ui-tabs-nav a[href='#"+tabHref+"']", that.tabs).html(title);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (group == "ring") {
|
||||||
|
addCardToGroup(this.ringContainer, "Ring", "ring");
|
||||||
|
} else if (group == "ringBearer") {
|
||||||
|
if (selectedTabIndex == 0) {
|
||||||
|
addCardToGroup(this.ringBearerContainer, "Ring-bearer", "ringBearer");
|
||||||
|
} else {
|
||||||
|
addCardToGroup(this.fpContainer, "Free People", "fp");
|
||||||
|
}
|
||||||
|
} else if (group == "site") {
|
||||||
|
addCardToGroup(this.sitesContainer, "Sites", "sites");
|
||||||
|
} else if (group == "fp") {
|
||||||
|
addCardToGroup(this.fpContainer, "Free People", "fp");
|
||||||
|
} else if (group == "shadow") {
|
||||||
|
addCardToGroup(this.shadowContainer, "Shadow", "shadow");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -20,6 +20,7 @@ var GempLotrDeckBuildingUI2 = Class.extend({
|
|||||||
// count: number of cards of that type
|
// count: number of cards of that type
|
||||||
// contents: contents of selection pack
|
// contents: contents of selection pack
|
||||||
// hor: if card is horizontal
|
// hor: if card is horizontal
|
||||||
|
// group: ring, ringBearer, site, fp, shadow
|
||||||
// image: image url
|
// image: image url
|
||||||
|
|
||||||
init:function (filterDiv, pageDiv, collectionContentsDiv, deckDiv) {
|
init:function (filterDiv, pageDiv, collectionContentsDiv, deckDiv) {
|
||||||
@@ -52,7 +53,7 @@ var GempLotrDeckBuildingUI2 = Class.extend({
|
|||||||
that.clearCollection();
|
that.clearCollection();
|
||||||
},
|
},
|
||||||
function (elem, type, blueprintId, count) {
|
function (elem, type, blueprintId, count) {
|
||||||
that.addCardToCollection(type, blueprintId, count, elem.getAttribute("side"), elem.getAttribute("contents"));
|
that.addCardToCollection(type, blueprintId, count, elem.getAttribute("group"), elem.getAttribute("contents"));
|
||||||
},
|
},
|
||||||
function () {
|
function () {
|
||||||
that.finishCollection();
|
that.finishCollection();
|
||||||
@@ -100,7 +101,7 @@ var GempLotrDeckBuildingUI2 = Class.extend({
|
|||||||
this.cardInCollectionId = 0;
|
this.cardInCollectionId = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
addCardToCollection: function(type, blueprintId, count, side, contents) {
|
addCardToCollection: function(type, blueprintId, count, group, contents) {
|
||||||
var props = {};
|
var props = {};
|
||||||
props["blueprintId"] = blueprintId;
|
props["blueprintId"] = blueprintId;
|
||||||
props["count"] = count;
|
props["count"] = count;
|
||||||
@@ -124,6 +125,7 @@ var GempLotrDeckBuildingUI2 = Class.extend({
|
|||||||
props["hor"] = card.horizontal;
|
props["hor"] = card.horizontal;
|
||||||
}
|
}
|
||||||
props["image"] = card.imageUrl;
|
props["image"] = card.imageUrl;
|
||||||
|
props["group"] = group;
|
||||||
|
|
||||||
var cardDiv = this.createCollectionCardElem(props);
|
var cardDiv = this.createCollectionCardElem(props);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user