Removing cards from deck.

This commit is contained in:
marcins78@gmail.com
2012-12-22 20:37:01 +00:00
parent f8d3120a73
commit 88c64a621d
2 changed files with 29 additions and 12 deletions

View File

@@ -85,7 +85,13 @@ var DeckPanel = Class.extend({
},
clearDeck: function() {
this.ringBearerContainer.removeCards();
this.ringContainer.removeCards();
this.sitesContainer.removeCards();
this.fpContainer.removeCards();
this.shadowContainer.removeCards();
this.updateDeckCounts();
},
layoutUi: function(x, y, width, height) {
@@ -124,6 +130,23 @@ var DeckPanel = Class.extend({
return count;
},
updateDeckCounts: function() {
var that = this;
var updateGroup = function (groupContainer, titlePrefix, tabHref) {
groupContainer.layoutCards();
var count = groupContainer.getCardsCount();
var title = titlePrefix + " (" + count + ")";
$(".ui-tabs-nav a[href='#" + tabHref + "']", that.tabs).html(title);
};
updateGroup(this.ringContainer, "Ring", "ring");
updateGroup(this.ringBearerContainer, "Ring-bearer", "ringBearer");
updateGroup(this.sitesContainer, "Sites", "sites");
updateGroup(this.fpContainer, "Free People", "fp");
updateGroup(this.shadowContainer, "Shadow", "shadow");
},
addCard: function(cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc) {
var group = cardProps["group"];
@@ -147,18 +170,7 @@ var DeckPanel = Class.extend({
},
finishAddingCards: function() {
var updateGroup = function (groupContainer, titlePrefix, tabHref) {
groupContainer.layoutCards();
var count = groupContainer.getCardsCount();
var title = titlePrefix + " (" + count + ")";
$(".ui-tabs-nav a[href='#" + tabHref + "']", that.tabs).html(title);
};
updateGroup(this.ringContainer, "Ring", "ring");
updateGroup(this.ringBearerContainer, "Ring-bearer", "ringBearer");
updateGroup(this.sitesContainer, "Sites", "sites");
updateGroup(this.fpContainer, "Free People", "fp");
updateGroup(this.shadowContainer, "Shadow", "shadow");
this.updateDeckCounts();
},
addSingleCard: function(cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc) {

View File

@@ -87,6 +87,11 @@ var GempLotrDeckBuildingUI2 = Class.extend({
var cardProps = cardElem.data("props");
this.deckPanel.addSingleCard(this.createDeckCardElem(cardProps), ""+(this.cardInDeckId++), cardProps, this.layoutCardInDeck, this.widthToHeightScaleInCollection);
this.updateCardCount(cardElem, cardProps);
} else if (tar.hasClass("cardInDeck")) {
// remove card from deck
cardElem.remove();
this.deckPanel.updateDeckCounts();
this.updateCardCounts();
}
}
return true;