- Attached cards which have cars attached (like in case of "Whisper in the Dark") now should be displayed proparly.

This commit is contained in:
marcins78@gmail.com
2012-06-02 18:46:53 +00:00
parent 5203ebcfd6
commit 6c15ef3b98
2 changed files with 42 additions and 33 deletions

View File

@@ -2,6 +2,7 @@
<b>2 Jun. 2012</b>
- The drop-downs for deck and format in Game Hall no longer reset periodically.
- The formats for each week in League tab are now clickable to show the details for the format.
- Attached cards which have cars attached (like in case of "Whisper in the Dark") now should be displayed proparly.
<b>30 May 2012</b>
- "Pippin, Friend to Frodo" now prevents only Shadow player from discarding Tales, not the FP player, if a Shadow card

View File

@@ -205,13 +205,22 @@ var NormalCardGroup = CardGroup.extend({
} while (!result);
},
getAttachedCardsWidth: function(maxDimension, cardData) {
var result = 0;
for (var i = 0; i < cardData.attachedCards.length; i++) {
var attachedCardData = cardData.attachedCards[i].data("card");
result += attachedCardData.getWidthForMaxDimension(maxDimension);
result += this.getAttachedCardsWidth(maxDimension, attachedCardData);
}
return result;
},
getCardsWithAttachmentWidthProportion: function(cardsToLayout) {
var proportionsArray = new Array();
for (var cardIndex in cardsToLayout) {
var cardData = cardsToLayout[cardIndex].data("card");
var cardWithAttachmentWidth = cardData.getWidthForMaxDimension(1000);
for (var i = 0; i < cardData.attachedCards.length; i++)
cardWithAttachmentWidth += cardData.attachedCards[i].data("card").getWidthForMaxDimension(1000) * 0.2;
cardWithAttachmentWidth += this.getAttachedCardsWidth(1000, cardData) * 0.2;
proportionsArray.push(cardWithAttachmentWidth / 1000);
}
return proportionsArray;
@@ -269,29 +278,35 @@ var NormalCardGroup = CardGroup.extend({
return true;
},
layoutAttached: function(cardData, y, height, layoutVars) {
for (var i = 0; i < cardData.attachedCards.length; i++) {
var attachedCardData = cardData.attachedCards[i].data("card");
var attachedCardWidth = attachedCardData.getWidthForMaxDimension(height);
this.layoutAttached(attachedCardData, y, height, layoutVars);
this.layoutCard(cardData.attachedCards[i], this.x + layoutVars.x, this.y + y, attachedCardWidth, attachedCardData.getHeightForWidth(attachedCardWidth), layoutVars.index);
layoutVars.x += Math.floor(attachedCardWidth * 0.2);
layoutVars.index++;
}
},
layoutInRow: function(cardsToLayout, height) {
if (this.maxCardHeight != null)
height = Math.min(this.maxCardHeight, height);
var x = 0;
var row = 0;
var layoutVars = {};
layoutVars.x = 0;
var y = Math.floor((this.height - height) / 2);
for (var cardIndex in cardsToLayout) {
var index = 10;
layoutVars.index = 10;
var cardElem = cardsToLayout[cardIndex];
var cardData = cardElem.data("card");
var cardWidth = cardData.getWidthForMaxDimension(height);
for (var i = 0; i < cardData.attachedCards.length; i++) {
var attachedCardData = cardData.attachedCards[i].data("card");
var attachedCardWidth = attachedCardData.getWidthForMaxDimension(height);
this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, attachedCardWidth, attachedCardData.getHeightForWidth(attachedCardWidth), index);
x += Math.floor(attachedCardWidth * 0.2);
index++;
}
this.layoutCard(cardElem, this.x + x, this.y + y, cardWidth, cardData.getHeightForWidth(cardWidth), index);
x += cardWidth;
x += this.padding;
this.layoutAttached(cardData, y, height, layoutVars)
this.layoutCard(cardElem, this.x + layoutVars.x, this.y + y, cardWidth, cardData.getHeightForWidth(cardWidth), layoutVars.index);
layoutVars.x += cardWidth;
layoutVars.x += this.padding;
}
},
@@ -300,38 +315,31 @@ var NormalCardGroup = CardGroup.extend({
if (this.maxCardHeight != null)
rowHeight = Math.min(this.maxCardHeight, rowHeight);
var yBias = Math.floor((this.height - (rowHeight * rowCount) - (this.padding * (rowCount - 1))) / 2);
var x = 0;
var layoutVars = {};
layoutVars.x = 0;
var row = 0;
var y = yBias;
for (var cardIndex in cardsToLayout) {
var index = 10;
layoutVars.index = 10;
var cardElem = cardsToLayout[cardIndex];
var cardData = cardElem.data("card");
var cardWidth = cardData.getWidthForMaxDimension(rowHeight);
var attachmentWidths = 0;
for (var i = 0; i < cardData.attachedCards.length; i++)
attachmentWidths += cardData.attachedCards[i].data("card").getWidthForMaxDimension(rowHeight) * 0.2;
var attachmentWidths = this.getAttachedCardsWidth(rowHeight, cardData) * 0.2;
var cardWidthWithAttachments = cardWidth + attachmentWidths;
if (x + cardWidthWithAttachments > this.width) {
if (layoutVars.x + cardWidthWithAttachments > this.width) {
row++;
x = 0;
layoutVars.x = 0;
y = yBias + row * (rowHeight + this.padding);
}
for (var i = 0; i < cardData.attachedCards.length; i++) {
var attachedCardData = cardData.attachedCards[i].data("card");
var attachedCardWidth = attachedCardData.getWidthForMaxDimension(rowHeight);
this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, attachedCardWidth, attachedCardData.getHeightForWidth(attachedCardWidth), index);
x += Math.floor(attachedCardWidth * 0.2);
index++;
}
this.layoutCard(cardElem, this.x + x, this.y + y, cardWidth, cardData.getHeightForWidth(cardWidth), index);
x += cardWidth;
if (x > this.width)
this.layoutAttached(cardData, y, rowHeight, layoutVars);
this.layoutCard(cardElem, this.x + layoutVars.x, this.y + y, cardWidth, cardData.getHeightForWidth(cardWidth), layoutVars.index);
layoutVars.x += cardWidth;
if (layoutVars.x > this.width)
return false;
x += this.padding;
layoutVars.x += this.padding;
}
return true;