diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-013/DeckPanel.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-013/DeckPanel.js index 28bbbd082..8329873bb 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-013/DeckPanel.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-013/DeckPanel.js @@ -16,7 +16,13 @@ var DeckPanel = Class.extend({ fpContainer:null, shadowContainer:null, - init:function (deckDiv) { + cardLayoutFunc: null, + cardWidthToHeightFunc: null, + + init:function (deckDiv, cardLayoutFunc, cardWidthToHeightFunc) { + this.cardLayoutFunc = cardLayoutFunc; + this.cardWidthToHeightFunc = cardWidthToHeightFunc; + var tabGroup = $(""); tabGroup.append("
  • Ring-bearer (0)
  • "); tabGroup.append("
  • Ring (0)
  • "); @@ -38,23 +44,7 @@ var DeckPanel = Class.extend({ this.tabs = $(deckDiv).tabs(); - var isFirstWithSameBlueprintIdInGroup = - function(testedCardId, cardGroup, blueprintId) { - var first; - var finished = false; - - cardGroup.iterCards( - function(cardDiv, cardId, props, layoutFunc) { - if (!finished && props["blueprintId"] == blueprintId) { - first = (cardId == testedCardId); - finished = true; - } - }); - - return first; - }; - - this.ringBearerContainer = new CardContainer(this.ringBearerDiv, this.layoutCardContainer); + this.ringBearerContainer = new CardContainer(this.ringBearerDiv, this.layoutCardContainer, this.cardLayoutFunc, this.cardWidthToHeightFunc); var ringBearerGroup = new RowCardLayoutCardGroup(this.ringBearerDiv, function() { return true; @@ -63,7 +53,7 @@ var DeckPanel = Class.extend({ ringBearerGroup.setMaxCardHeight(300); this.ringBearerContainer.addCardGroup("main", ringBearerGroup); - this.ringContainer = new CardContainer(this.ringDiv, this.layoutCardContainer); + this.ringContainer = new CardContainer(this.ringDiv, this.layoutCardContainer, this.cardLayoutFunc, this.cardWidthToHeightFunc); var ringGroup = new RowCardLayoutCardGroup(this.ringDiv, function() { return true; @@ -72,7 +62,7 @@ var DeckPanel = Class.extend({ ringGroup.setMaxCardHeight(300); this.ringContainer.addCardGroup("main", ringGroup); - this.sitesContainer = new CardContainer(this.sitesDiv, this.layoutCardContainer); + this.sitesContainer = new CardContainer(this.sitesDiv, this.layoutCardContainer, this.cardLayoutFunc, this.cardWidthToHeightFunc); var sitesGroup = new RowCardLayoutCardGroup(this.sitesDiv, function() { return true; @@ -81,7 +71,7 @@ var DeckPanel = Class.extend({ sitesGroup.setMaxCardHeight(300); this.sitesContainer.addCardGroup("main", sitesGroup); - this.fpContainer = new CardContainer(this.fpDiv, this.layoutCardContainer); + this.fpContainer = new CardContainer(this.fpDiv, this.layoutCardContainer, this.cardLayoutFunc, this.cardWidthToHeightFunc); var fpGroup = new RowCardLayoutCardGroup(this.fpDiv, function(cardDiv, cardId, props) { return true; @@ -90,7 +80,7 @@ var DeckPanel = Class.extend({ fpGroup.setMaxCardHeight(300); this.fpContainer.addCardGroup("main", fpGroup); - this.shadowContainer = new CardContainer(this.shadowDiv, this.layoutCardContainer); + this.shadowContainer = new CardContainer(this.shadowDiv, this.layoutCardContainer, this.cardLayoutFunc, this.cardWidthToHeightFunc); var shadowGroup = new RowCardLayoutCardGroup(this.shadowDiv, function(cardDiv, cardId, props) { return true; @@ -187,17 +177,17 @@ var DeckPanel = Class.extend({ return cardInGroupProps; }, - addCardToGroup: function(groupContainer, cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc) { + addCardToGroup: function(groupContainer, cardElem, cardId, cardProps) { var cardInGroupProps = this.findCardPropsInGroup(groupContainer, cardProps["blueprintId"]);; if (cardInGroupProps == null) { cardProps["countInDeck"] = 1; - groupContainer.addCard(cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc); + groupContainer.addCard(cardElem, cardId, cardProps); } else { cardInGroupProps["countInDeck"] = cardInGroupProps["countInDeck"] + 1; } }, - addCard: function(cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc) { + addCard: function(cardElem, cardId, cardProps) { var group = cardProps["group"]; if (group == "ring") { @@ -211,8 +201,8 @@ var DeckPanel = Class.extend({ } }, - addRingBearerCard: function(cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc) { - this.addCardToGroup(this.ringBearerContainer, cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc); + addRingBearerCard: function(cardElem, cardId, cardProps) { + this.addCardToGroup(this.ringBearerContainer, cardElem, cardId, cardProps); }, removeCardAndUpdate: function(cardElem, cardId, cardProps) { @@ -225,7 +215,7 @@ var DeckPanel = Class.extend({ else cardPropsInGroup["countInDeck"]=cardPropsInGroup["countInDeck"]-1; groupContainer.layoutCards(); - + var count = that.getCardCountInGroup(groupContainer); var title = titlePrefix + " (" + count + ")"; $(".ui-tabs-nav a[href='#" + tabHref + "']", that.tabs).html(title); @@ -243,35 +233,35 @@ var DeckPanel = Class.extend({ this.updateDeckCounts(); }, - addCardToGroupAndUpdate: function(groupContainer, titlePrefix, tabHref, cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc) { - this.addCardToGroup(groupContainer, cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc); + addCardToGroupAndUpdate: function(groupContainer, titlePrefix, tabHref, cardElem, cardId, cardProps) { + this.addCardToGroup(groupContainer, cardElem, cardId, cardProps); groupContainer.layoutCards(); var count = this.getCardCountInGroup(groupContainer); var title = titlePrefix + " (" + count + ")"; $(".ui-tabs-nav a[href='#" + tabHref + "']", this.tabs).html(title); }, - addCardAndUpdate: function(cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc) { + addCardAndUpdate: function(cardElem, cardId, cardProps) { var group = cardProps["group"]; var that = this; if (group == "ring") { - this.addCardToGroupAndUpdate(this.ringContainer, "Ring", "ring", cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc); + this.addCardToGroupAndUpdate(this.ringContainer, "Ring", "ring", cardElem, cardId, cardProps); } else if (group == "ringBearer") { var selectedTabIndex = this.tabs.tabs('option', 'selected'); if (selectedTabIndex == 0) { - this.addCardToGroupAndUpdate(this.ringBearerContainer, "Ring-bearer", "ringBearer", cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc); + this.addCardToGroupAndUpdate(this.ringBearerContainer, "Ring-bearer", "ringBearer", cardElem, cardId, cardProps); } else { - this.addCardToGroupAndUpdate(this.fpContainer, "Free People", "fp", cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc); + this.addCardToGroupAndUpdate(this.fpContainer, "Free People", "fp", cardElem, cardId, cardProps); } } else if (group == "site") { - this.addCardToGroupAndUpdate(this.sitesContainer, "Sites", "sites", cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc); + this.addCardToGroupAndUpdate(this.sitesContainer, "Sites", "sites", cardElem, cardId, cardProps); } else if (group == "fp") { - this.addCardToGroupAndUpdate(this.fpContainer, "Free People", "fp", cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc); + this.addCardToGroupAndUpdate(this.fpContainer, "Free People", "fp", cardElem, cardId, cardProps); } else if (group == "shadow") { - this.addCardToGroupAndUpdate(this.shadowContainer, "Shadow", "shadow", cardElem, cardId, cardProps, layoutCardFunc, widthToHeightScaleFunc); + this.addCardToGroupAndUpdate(this.shadowContainer, "Shadow", "shadow", cardElem, cardId, cardProps); } } }); \ No newline at end of file diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-013/deckBuildingUi2.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-013/deckBuildingUi2.js index 918bbf7cc..c31e87e7a 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-013/deckBuildingUi2.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gemp-013/deckBuildingUi2.js @@ -34,7 +34,7 @@ var GempLotrDeckBuildingUI2 = Class.extend({ var that = this; - this.collectionContainer = new CardContainer(collectionContentsDiv, this.layoutCollectionContainer); + this.collectionContainer = new CardContainer(collectionContentsDiv, this.layoutCollectionContainer, this.layoutCardInCollection, this.widthToHeightScaleInCollection); this.collectionGroup = new RowCardLayoutCardGroup(collectionContentsDiv, function() { return true; @@ -85,7 +85,7 @@ var GempLotrDeckBuildingUI2 = Class.extend({ that.finishCollection(); }); - this.deckPanel = new DeckPanel(deckDiv); + this.deckPanel = new DeckPanel(deckDiv, this.layoutCardInDeck, this.widthToHeightScaleInCollection); this.collectionType = "default"; this.cardFilter.getCollection(); @@ -195,7 +195,7 @@ var GempLotrDeckBuildingUI2 = Class.extend({ var collections = root.getElementsByTagName("collection"); for (var i = 0; i < collections.length; i++) { var collection = collections[i]; - this.collectionSelect.append(""); + that.collectionSelect.append(""); } } }); @@ -218,7 +218,7 @@ var GempLotrDeckBuildingUI2 = Class.extend({ cardProps["blueprintId"] = blueprintId; cardProps["image"] = image; cardProps["hor"] = horizontal; - this.deckPanel.addCardAndUpdate(this.createDeckCardElem(cardProps), "" + (this.cardInDeckId++), cardProps, this.layoutCardInDeck, this.widthToHeightScaleInCollection); + this.deckPanel.addCardAndUpdate(this.createDeckCardElem(cardProps), "" + (this.cardInDeckId++), cardProps); }, addCardToCollection: function(type, blueprintId, count, group, contents) { @@ -240,7 +240,7 @@ var GempLotrDeckBuildingUI2 = Class.extend({ props["image"] = card.imageUrl; props["group"] = group; - this.collectionContainer.addCard(this.createCollectionCardElem(props), "" + (this.cardInCollectionId++), props, this.layoutCardInCollection, this.widthToHeightScaleInCollection); + this.collectionContainer.addCard(this.createCollectionCardElem(props), "" + (this.cardInCollectionId++), props); }, updateCardCount: function(cardDiv, props) { @@ -285,7 +285,7 @@ var GempLotrDeckBuildingUI2 = Class.extend({ return 360 / 500; }, - layoutCardInCollection: function(cardDiv, cardId, props, cardLeft, cardTop, cardWidth, cardHeight) { + layoutCardInCollection: function(cardDiv, cardId, props, zIndex, cardLeft, cardTop, cardWidth, cardHeight) { $(".img", cardDiv).css({"left":0, "top":0, "width":cardWidth, "height":cardHeight}); var maxDimension = Math.max(cardWidth, cardHeight) if (props["type"] == "card") { @@ -296,7 +296,7 @@ var GempLotrDeckBuildingUI2 = Class.extend({ $(".click", cardDiv).css({"left":0, "top":0, "width":cardWidth, "height":cardHeight}); }, - layoutCardInDeck: function(cardDiv, cardId, props, cardLeft, cardTop, cardWidth, cardHeight) { + layoutCardInDeck: function(cardDiv, cardId, props, zIndex, cardLeft, cardTop, cardWidth, cardHeight) { $(".img", cardDiv).css({"left":0, "top":0, "width":cardWidth, "height":cardHeight}); var maxDimension = Math.max(cardWidth, cardHeight) if (props["type"] == "card") {