Adding errata overlay to changed cards.

This commit is contained in:
marcins78@gmail.com
2012-04-16 14:49:15 +00:00
parent a14c39f6b4
commit 6f1b05e33c
8 changed files with 103 additions and 88 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -145,10 +145,10 @@ var GempLotrDeckBuildingUI = Class.extend({
if (confirm("Do you wish to save this deck?"))
that.saveDeck(false);
}, {
"404": function() {
alert("Couldn't find the deck to rename on the server.");
}
});
"404": function() {
alert("Couldn't find the deck to rename on the server.");
}
});
}
});
@@ -244,11 +244,11 @@ var GempLotrDeckBuildingUI = Class.extend({
this.infoDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
var swipeOptions = {
threshold: 20,
@@ -296,14 +296,14 @@ var GempLotrDeckBuildingUI = Class.extend({
if (that.deckListDialog == null) {
that.deckListDialog = $("<div></div>")
.dialog({
title: "Your stored decks",
autoOpen: false,
closeOnEscape: true,
resizable: true,
width: 400,
height: 400,
modal: true
});
title: "Your stored decks",
autoOpen: false,
closeOnEscape: true,
resizable: true,
width: 400,
height: 400,
modal: true
});
}
that.deckListDialog.html("");
@@ -418,14 +418,14 @@ var GempLotrDeckBuildingUI = Class.extend({
if (this.selectionDialog == null) {
this.selectionDialog = $("<div></div>")
.dialog({
title: "Choose one",
autoOpen: false,
closeOnEscape: true,
resizable: true,
width: 400,
height: 200,
modal: true
});
title: "Choose one",
autoOpen: false,
closeOnEscape: true,
resizable: true,
width: 400,
height: 200,
modal: true
});
this.selectionGroup = new NormalCardGroup(this.selectionDialog, function(card) {
return true;
@@ -440,7 +440,7 @@ var GempLotrDeckBuildingUI = Class.extend({
var blueprintIds = selection.split("|");
for (var i = 0; i < blueprintIds.length; i++) {
var card = new Card(blueprintIds[i], "selection", "selection" + i, "player");
var cardDiv = createCardDiv(card.imageUrl, null, card.isFoil(), false, card.isPack());
var cardDiv = createCardDiv(card.imageUrl, null, card.isFoil(), false, card.isPack(), card.hasErrata());
cardDiv.data("card", card);
cardDiv.addClass("cardToSelect");
this.selectionDialog.append(cardDiv);
@@ -565,7 +565,7 @@ var GempLotrDeckBuildingUI = Class.extend({
addCardToContainer: function(blueprintId, zone, container, tokens) {
var card = new Card(blueprintId, zone, "deck", "player");
var cardDiv = createCardDiv(card.imageUrl, null, card.isFoil(), tokens, card.isPack());
var cardDiv = createCardDiv(card.imageUrl, null, card.isFoil(), tokens, card.isPack(), card.hasErrata());
cardDiv.data("card", card);
container.append(cardDiv);
return cardDiv;
@@ -662,10 +662,10 @@ var GempLotrDeckBuildingUI = Class.extend({
that.checkDeckStatsDirty();
}, that.checkDirtyInterval);
}, {
"400": function() {
alert("Invalid deck for getting stats.");
}
});
"400": function() {
alert("Invalid deck for getting stats.");
}
});
} else {
$("#deckStats").html("Deck has no Ring, Ring-bearer or all 9 sites");
setTimeout(
@@ -753,14 +753,14 @@ var GempLotrDeckBuildingUI = Class.extend({
if (blueprintId.substr(0, 3) == "(S)") {
var card = new Card(blueprintId, "pack", "collection", "player");
card.tokens = {"count":count};
var cardDiv = createCardDiv(card.imageUrl, null, false, true, true);
var cardDiv = createCardDiv(card.imageUrl, null, false, true, true, false);
cardDiv.data("card", card);
cardDiv.data("selection", contents);
cardDiv.addClass("selectionInCollection");
} else {
var card = new Card(blueprintId, "pack", "collection", "player");
card.tokens = {"count":count};
var cardDiv = createCardDiv(card.imageUrl, null, false, true, true);
var cardDiv = createCardDiv(card.imageUrl, null, false, true, true, false);
cardDiv.data("card", card);
cardDiv.addClass("packInCollection");
}
@@ -775,7 +775,7 @@ var GempLotrDeckBuildingUI = Class.extend({
countInDeck++;
});
card.tokens = {"count":count - countInDeck};
var cardDiv = createCardDiv(card.imageUrl, null, card.isFoil());
var cardDiv = createCardDiv(card.imageUrl, null, card.isFoil(), true, false, card.hasErrata());
cardDiv.data("card", card);
cardDiv.addClass("cardInCollection");
this.normalCollectionDiv.append(cardDiv);

View File

@@ -48,7 +48,7 @@ function deliveryService(xml) {
var count = packElem.getAttribute("count");
var card = new Card(blueprintId, "delivery", "deliveryPack" + i, "player");
card.tokens = {"count":count};
var cardDiv = createCardDiv(card.imageUrl, null, card.isFoil(), true, true);
var cardDiv = createCardDiv(card.imageUrl, null, card.isFoil(), true, true, false);
cardDiv.data("card", card);
deliveryDialogs[collectionName].append(cardDiv);
}
@@ -60,7 +60,7 @@ function deliveryService(xml) {
var count = cardElem.getAttribute("count");
var card = new Card(blueprintId, "delivery", "deliveryCard" + i, "player");
card.tokens = {"count":count};
var cardDiv = createCardDiv(card.imageUrl, null, card.isFoil());
var cardDiv = createCardDiv(card.imageUrl, null, card.isFoil(), true, false, card.hasErrata());
cardDiv.data("card", card);
deliveryDialogs[collectionName].append(cardDiv);
}

View File

@@ -218,7 +218,7 @@ var GameAnimations = Class.extend({
else
card = new Card(blueprintId, zone, cardId, participantId);
var cardDiv = that.game.createCardDiv(card, null, card.isFoil());
var cardDiv = that.game.createCardDiv(card, null, card.isFoil(), card.hasErrata());
if (zone == "DISCARD")
that.game.discardPileDialogs[participantId].append(cardDiv);
else if (zone == "DEAD")

View File

@@ -659,21 +659,21 @@ var GempLotrGameUI = Class.extend({
initializeDialogs: function() {
this.smallDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: false,
resizable: false,
width: 400,
height: 200
});
autoOpen: false,
closeOnEscape: false,
resizable: false,
width: 400,
height: 200
});
this.cardActionDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: false,
resizable: true,
width: 600,
height: 300
});
autoOpen: false,
closeOnEscape: false,
resizable: true,
width: 600,
height: 300
});
var that = this;
@@ -688,11 +688,11 @@ var GempLotrGameUI = Class.extend({
this.infoDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
var swipeOptions = {
threshold: 20,
@@ -1203,12 +1203,12 @@ var GempLotrGameUI = Class.extend({
if (!this.replayMode) {
this.smallDialog.dialog("option", "buttons",
{
"OK": function() {
$(this).dialog("close");
that.decisionFunction(id, $("#integerDecision").val());
}
});
{
"OK": function() {
$(this).dialog("close");
that.decisionFunction(id, $("#integerDecision").val());
}
});
}
$("#integerDecision").SpinnerControl({ type: 'range',
@@ -1246,12 +1246,12 @@ var GempLotrGameUI = Class.extend({
if (!this.replayMode) {
this.smallDialog.dialog("option", "buttons",
{
"OK": function() {
that.smallDialog.dialog("close");
that.decisionFunction(id, $("#multipleChoiceDecision").val());
}
});
{
"OK": function() {
that.smallDialog.dialog("close");
that.decisionFunction(id, $("#multipleChoiceDecision").val());
}
});
}
} else {
this.smallDialog.append("<br />");
@@ -1355,8 +1355,8 @@ var GempLotrGameUI = Class.extend({
}
},
createCardDiv: function(card, text, foil) {
var cardDiv = createCardDiv(card.imageUrl, text, foil);
createCardDiv: function(card, text) {
var cardDiv = createCardDiv(card.imageUrl, text, card.isFoil(), true, false, card.hasErrata());
cardDiv.data("card", card);
@@ -1419,7 +1419,7 @@ var GempLotrGameUI = Class.extend({
if (selectable[i] == "true")
selectableCardIds.push(cardId);
var card = new Card(blueprintId, "SPECIAL", cardId, this.selfParticipantId);
var card = new Card(blueprintId, "SPECIAL", cardId, null);
var cardDiv = this.createCardDiv(card);
@@ -1568,7 +1568,7 @@ var GempLotrGameUI = Class.extend({
} else {
hasVirtual = true;
cardIds[i] = "extra" + cardId;
var card = new Card(blueprintId, "EXTRA", "extra" + cardId, this.selfParticipantId);
var card = new Card(blueprintId, "EXTRA", "extra" + cardId, null);
var cardDiv = that.createCardDiv(card);
$(cardDiv).css({opacity: "0.8"});
@@ -1644,8 +1644,8 @@ var GempLotrGameUI = Class.extend({
$(div).find('LI.hover').removeClass('hover');
$(this).parent().addClass('hover');
}).mouseout(function() {
$(div).find('LI.hover').removeClass('hover');
});
$(div).find('LI.hover').removeClass('hover');
});
var getRidOfContextMenu = function() {
$(div).remove();
@@ -1693,7 +1693,7 @@ var GempLotrGameUI = Class.extend({
var blueprintId = blueprintIds[i];
cardIds.push("temp" + i);
var card = new Card(blueprintId, "SPECIAL", "temp" + i, this.selfParticipantId);
var card = new Card(blueprintId, "SPECIAL", "temp" + i, null);
var cardDiv = this.createCardDiv(card, actionTexts[i]);

View File

@@ -353,6 +353,7 @@ function layoutCardElem(cardElem, x, y, width, height, index) {
if (tokenOverlay.length > 0)
tokenOverlay.css({position: "absolute", left: 0 + "px", top: 0 + "px", width: width, height: height});
$(".errataOverlay", cardElem).css({position: "absolute", left: 0 + "px", top: 0 + "px", width: width, height: height});
$(".foilOverlay", cardElem).css({position: "absolute", left: 0 + "px", top: 0 + "px", width: width, height: height});
var maxDimension = Math.max(width, height);

View File

@@ -103,6 +103,7 @@ var Card = Class.extend({
owner: null,
siteNumber: null,
attachedCards: null,
errata: null,
init: function(blueprintId, zone, cardId, owner, siteNumber) {
this.blueprintId = blueprintId;
@@ -129,12 +130,15 @@ var Card = Class.extend({
var cardFromCache = cardCache[this.blueprintId];
this.horizontal = cardFromCache.horizontal;
this.imageUrl = cardFromCache.imageUrl;
this.errata = cardFromCache.errata;
} else {
this.imageUrl = this.getUrlByBlueprintId(this.blueprintId);
this.horizontal = this.isHorizontal(this.blueprintId);
this.errata = this.getErrata(this.blueprintId) != null;
cardCache[this.blueprintId] = {
imageUrl: this.imageUrl,
horizontal: this.horizontal
horizontal: this.horizontal,
errata: this.errata
};
}
}
@@ -148,6 +152,10 @@ var Card = Class.extend({
return this.foil;
},
hasErrata: function() {
return this.errata;
},
isPack: function() {
return packBlueprints[this.blueprintId] != null;
},
@@ -308,8 +316,14 @@ var Card = Class.extend({
}
});
function createCardDiv(image, text, foil, tokens, noBorder) {
function createCardDiv(image, text, foil, tokens, noBorder, errata) {
var cardDiv = $("<div class='card'><img src='" + image + "' width='100%' height='100%'>" + ((text != null) ? text : "") + "</div>");
if (errata) {
var errataDiv = $("<div class='errataOverlay'><img src='/gemp-lotr/images/errata-vertical.png' width='100%' height='100%'></div>");
cardDiv.append(errataDiv);
}
if (foil) {
var foilDiv = $("<div class='foilOverlay'><img src='/gemp-lotr/images/foil.gif' width='100%' height='100%'></div>");
cardDiv.append(foilDiv);

View File

@@ -70,20 +70,20 @@ var GempLotrMerchantUI = Class.extend({
this.infoDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
title: "Card information"
});
this.questionDialog = $("<div></div>")
.dialog({
autoOpen: false,
closeOnEscape: true,
resizable: false,
modal: true,
title: "Merchant operation"
});
autoOpen: false,
closeOnEscape: true,
resizable: false,
modal: true,
title: "Merchant operation"
});
var swipeOptions = {
threshold: 20,
@@ -225,13 +225,13 @@ var GempLotrMerchantUI = Class.extend({
if (type == "pack") {
card = new Card(blueprintId, "merchant", "collection", "player");
cardDiv = createCardDiv(card.imageUrl, null, false, true, true);
cardDiv = createCardDiv(card.imageUrl, null, false, true, true, false);
cardDiv.data("card", card);
cardDiv.data("sizeListeners", sizeListeners);
this.cardsDiv.append(cardDiv);
} else if (type == "card") {
card = new Card(blueprintId, "merchant", "collection", "player");
cardDiv = createCardDiv(card.imageUrl, null, card.isFoil());
cardDiv = createCardDiv(card.imageUrl, null, card.isFoil(), true, false, card.hasErrata());
cardDiv.data("card", card);
cardDiv.data("sizeListeners", sizeListeners);
this.cardsDiv.append(cardDiv);