Lets hope this will add animation to everything, even if card affects multiple other cards.
This commit is contained in:
@@ -31,7 +31,7 @@ public class GameEvent {
|
||||
private Phase _phase;
|
||||
private Integer _count;
|
||||
private Token _token;
|
||||
private int[] _opposingCardIds;
|
||||
private int[] _otherCardIds;
|
||||
|
||||
public GameEvent(Type type) {
|
||||
_type = type;
|
||||
@@ -86,12 +86,12 @@ public class GameEvent {
|
||||
return this;
|
||||
}
|
||||
|
||||
public int[] getOpposingCardIds() {
|
||||
return _opposingCardIds;
|
||||
public int[] getOtherCardIds() {
|
||||
return _otherCardIds;
|
||||
}
|
||||
|
||||
public GameEvent opposingCardIds(int[] opposingCardIds) {
|
||||
_opposingCardIds = opposingCardIds;
|
||||
public GameEvent otherCardIds(int[] otherCardIds) {
|
||||
_otherCardIds = otherCardIds;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,16 +29,19 @@ public class GatheringParticipantCommunicationChannel implements GameStateListen
|
||||
_events.add(new GameEvent(PARTICIPANT).participantId(_self).allParticipantIds(participantIds));
|
||||
}
|
||||
|
||||
private int[] getCardIds(List<PhysicalCard> minions) {
|
||||
int[] result = new int[minions.size()];
|
||||
for (int i = 0; i < result.length; i++)
|
||||
result[i] = minions.get(i).getCardId();
|
||||
private int[] getCardIds(Collection<PhysicalCard> cards) {
|
||||
int[] result = new int[cards.size()];
|
||||
int index = 0;
|
||||
for (PhysicalCard card : cards) {
|
||||
result[index] = card.getCardId();
|
||||
index++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAssignment(PhysicalCard freePeople, List<PhysicalCard> minions) {
|
||||
_events.add(new GameEvent(ADD_ASSIGNMENT).cardId(freePeople.getCardId()).opposingCardIds(getCardIds(minions)));
|
||||
_events.add(new GameEvent(ADD_ASSIGNMENT).cardId(freePeople.getCardId()).otherCardIds(getCardIds(minions)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,7 +51,7 @@ public class GatheringParticipantCommunicationChannel implements GameStateListen
|
||||
|
||||
@Override
|
||||
public void startSkirmish(PhysicalCard freePeople, List<PhysicalCard> minions) {
|
||||
GameEvent gameEvent = new GameEvent(START_SKIRMISH).opposingCardIds(getCardIds(minions));
|
||||
GameEvent gameEvent = new GameEvent(START_SKIRMISH).otherCardIds(getCardIds(minions));
|
||||
if (freePeople != null)
|
||||
gameEvent.cardId(freePeople.getCardId());
|
||||
_events.add(gameEvent);
|
||||
@@ -120,9 +123,8 @@ public class GatheringParticipantCommunicationChannel implements GameStateListen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cardAffectedByCard(String playerPerforming, PhysicalCard card, Collection<PhysicalCard> affectedCard) {
|
||||
// TODO
|
||||
// _events.add(new GameEvent(CARD_AFFECTS_CARD).card(card).targetCardId(affectedCard.getCardId()));
|
||||
public void cardAffectedByCard(String playerPerforming, PhysicalCard card, Collection<PhysicalCard> affectedCards) {
|
||||
_events.add(new GameEvent(CARD_AFFECTS_CARD).participantId(playerPerforming).card(card).otherCardIds(getCardIds(affectedCards)));
|
||||
}
|
||||
|
||||
public void eventPlayed(PhysicalCard card) {
|
||||
|
||||
@@ -741,15 +741,15 @@ public class ServerResource {
|
||||
eventElem.setAttribute("token", gameEvent.getToken().name());
|
||||
if (gameEvent.getCount() != null)
|
||||
eventElem.setAttribute("count", gameEvent.getCount().toString());
|
||||
if (gameEvent.getOpposingCardIds() != null) {
|
||||
if (gameEvent.getOtherCardIds() != null) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (int cardId : gameEvent.getOpposingCardIds()) {
|
||||
for (int cardId : gameEvent.getOtherCardIds()) {
|
||||
if (!first) sb.append(",");
|
||||
sb.append(cardId);
|
||||
first = false;
|
||||
}
|
||||
eventElem.setAttribute("opposingCardIds", sb.toString());
|
||||
eventElem.setAttribute("otherCardIds", sb.toString());
|
||||
}
|
||||
if (gameEvent.getMessage() != null)
|
||||
eventElem.setAttribute("message", gameEvent.getMessage());
|
||||
|
||||
@@ -30,40 +30,40 @@ var GameAnimations = Class.extend({
|
||||
var cardWidth = card.getWidthForHeight(cardHeight);
|
||||
|
||||
$(cardDiv).css(
|
||||
{
|
||||
position: "absolute",
|
||||
left: (gameWidth / 2 - cardWidth / 4),
|
||||
top: gameHeight * (3 / 8),
|
||||
width: cardWidth / 2,
|
||||
height: cardHeight / 2,
|
||||
"z-index": 100,
|
||||
opacity: 0});
|
||||
{
|
||||
position: "absolute",
|
||||
left: (gameWidth / 2 - cardWidth / 4),
|
||||
top: gameHeight * (3 / 8),
|
||||
width: cardWidth / 2,
|
||||
height: cardHeight / 2,
|
||||
"z-index": 100,
|
||||
opacity: 0});
|
||||
|
||||
$(cardDiv).animate(
|
||||
{
|
||||
left: "-=" + cardWidth / 4,
|
||||
top: "-=" + (gameHeight / 8),
|
||||
width: "+=" + (cardWidth / 2),
|
||||
height: "+=" + (cardHeight / 2),
|
||||
opacity: 1},
|
||||
{
|
||||
duration: that.playEventDuration / 8,
|
||||
easing: "linear",
|
||||
queue: false,
|
||||
complete: next});
|
||||
{
|
||||
left: "-=" + cardWidth / 4,
|
||||
top: "-=" + (gameHeight / 8),
|
||||
width: "+=" + (cardWidth / 2),
|
||||
height: "+=" + (cardHeight / 2),
|
||||
opacity: 1},
|
||||
{
|
||||
duration: that.playEventDuration / 8,
|
||||
easing: "linear",
|
||||
queue: false,
|
||||
complete: next});
|
||||
}).queue(
|
||||
function(next) {
|
||||
setTimeout(next, that.playEventDuration * (5 / 8));
|
||||
}).queue(
|
||||
function(next) {
|
||||
$(cardDiv).animate(
|
||||
{
|
||||
opacity: 0},
|
||||
{
|
||||
duration: that.playEventDuration / 4,
|
||||
easing: "easeOutQuart",
|
||||
queue: false,
|
||||
complete: next});
|
||||
{
|
||||
opacity: 0},
|
||||
{
|
||||
duration: that.playEventDuration / 4,
|
||||
easing: "easeOutQuart",
|
||||
queue: false,
|
||||
complete: next});
|
||||
}).queue(
|
||||
function(next) {
|
||||
$(cardDiv).remove();
|
||||
@@ -77,51 +77,62 @@ var GameAnimations = Class.extend({
|
||||
|
||||
var participantId = element.getAttribute("participantId");
|
||||
var blueprintId = element.getAttribute("blueprintId");
|
||||
var targetCardId = element.getAttribute("targetCardId");
|
||||
var targetCardIds = element.getAttribute("otherCardIds").split(",");
|
||||
|
||||
// Play-out card affects card animation only if it's not the player who initiated it
|
||||
if (this.game.spectatorMode || (participantId != this.game.bottomPlayerId)) {
|
||||
var card = new Card(blueprintId, "ANIMATION", "anim", participantId);
|
||||
var cardDiv = createSimpleCardDiv(card.imageUrl);
|
||||
|
||||
$("#main").queue(
|
||||
function(next) {
|
||||
var targetCard = $(".card:cardId(" + targetCardId + ")");
|
||||
if (targetCard.length > 0) {
|
||||
cardDiv.data("card", card);
|
||||
$("#main").append(cardDiv);
|
||||
for (var i = 0; i < targetCardIds.length; i++) {
|
||||
var targetCardId = targetCardIds[i];
|
||||
|
||||
targetCard = targetCard[0];
|
||||
var targetCardWidth = $(targetCard).width();
|
||||
var targetCardHeight = $(targetCard).height();
|
||||
var card = new Card(blueprintId, "ANIMATION", "anim" + i, participantId);
|
||||
var cardDiv = createSimpleCardDiv(card.imageUrl);
|
||||
|
||||
$(cardDiv).css(
|
||||
{
|
||||
position: "absolute",
|
||||
left: $(targetCard).position().left,
|
||||
top: $(targetCard).position().top,
|
||||
width: targetCardWidth,
|
||||
height: targetCardHeight,
|
||||
"z-index": 100,
|
||||
opacity: 1});
|
||||
$(cardDiv).animate(
|
||||
{
|
||||
opacity: 0,
|
||||
left: "-=" + (targetCardWidth / 2),
|
||||
top: "-=" + (targetCardHeight / 2),
|
||||
width: "+=" + targetCardWidth,
|
||||
height: "+=" + targetCardHeight},
|
||||
{
|
||||
duration: that.cardAffectsCardDuration,
|
||||
easing: "easeInQuart",
|
||||
queue: false,
|
||||
complete: next});
|
||||
} else {
|
||||
next();
|
||||
var targetCard = $(".card:cardId(" + targetCardId + ")");
|
||||
if (targetCard.length > 0) {
|
||||
cardDiv.data("card", card);
|
||||
$("#main").append(cardDiv);
|
||||
|
||||
targetCard = targetCard[0];
|
||||
var targetCardWidth = $(targetCard).width();
|
||||
var targetCardHeight = $(targetCard).height();
|
||||
|
||||
$(cardDiv).css(
|
||||
{
|
||||
position: "absolute",
|
||||
left: $(targetCard).position().left,
|
||||
top: $(targetCard).position().top,
|
||||
width: targetCardWidth,
|
||||
height: targetCardHeight,
|
||||
"z-index": 100,
|
||||
opacity: 1});
|
||||
$(cardDiv).animate(
|
||||
{
|
||||
opacity: 0,
|
||||
left: "-=" + (targetCardWidth / 2),
|
||||
top: "-=" + (targetCardHeight / 2),
|
||||
width: "+=" + targetCardWidth,
|
||||
height: "+=" + targetCardHeight},
|
||||
{
|
||||
duration: that.cardAffectsCardDuration,
|
||||
easing: "easeInQuart",
|
||||
queue: false,
|
||||
complete: null});
|
||||
}
|
||||
|
||||
setTimeout(next, that.cardAffectsCardDuration);
|
||||
}
|
||||
}).queue(
|
||||
function(next) {
|
||||
$(cardDiv).remove();
|
||||
$(".card").each(
|
||||
function() {
|
||||
var cardData = $(this).data("card");
|
||||
if (cardData.zone == "ANIMATION") {
|
||||
$(this).remove();
|
||||
}
|
||||
}
|
||||
);
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -265,21 +265,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;
|
||||
|
||||
@@ -291,15 +291,15 @@ var GempLotrGameUI = Class.extend({
|
||||
|
||||
this.infoDialog = $("<div></div>")
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
closeOnEscape: true,
|
||||
resizable: true,
|
||||
title: "Card information",
|
||||
minHeight: 80,
|
||||
minWidth: 200,
|
||||
width: 600,
|
||||
height: 300
|
||||
});
|
||||
autoOpen: false,
|
||||
closeOnEscape: true,
|
||||
resizable: true,
|
||||
title: "Card information",
|
||||
minHeight: 80,
|
||||
minWidth: 200,
|
||||
width: 600,
|
||||
height: 300
|
||||
});
|
||||
|
||||
var swipeOptions = {
|
||||
threshold: 20,
|
||||
@@ -592,9 +592,9 @@ var GempLotrGameUI = Class.extend({
|
||||
else if (zone == "DISCARD")
|
||||
$("#discard" + this.getPlayerIndex(playerId)).text("Discard: " + count);
|
||||
else if (zone == "DEAD")
|
||||
$("#deadPile" + this.getPlayerIndex(playerId)).text("Dead pile: " + count);
|
||||
else if (zone == "DECK")
|
||||
$("#deck" + this.getPlayerIndex(playerId)).text("Deck: " + count);
|
||||
$("#deadPile" + this.getPlayerIndex(playerId)).text("Dead pile: " + count);
|
||||
else if (zone == "DECK")
|
||||
$("#deck" + this.getPlayerIndex(playerId)).text("Deck: " + count);
|
||||
},
|
||||
|
||||
playerPosition: function(element) {
|
||||
@@ -652,7 +652,7 @@ var GempLotrGameUI = Class.extend({
|
||||
|
||||
startSkirmish: function(element) {
|
||||
var cardId = element.getAttribute("cardId");
|
||||
var opposingCardIds = element.getAttribute("opposingCardIds").split(",");
|
||||
var opposingCardIds = element.getAttribute("otherCardIds").split(",");
|
||||
|
||||
$(".card:cardId(" + opposingCardIds + ")").each(function() {
|
||||
$(this).data("card").skirmish = true;
|
||||
@@ -700,7 +700,7 @@ var GempLotrGameUI = Class.extend({
|
||||
|
||||
addAssignment: function(element) {
|
||||
var cardId = element.getAttribute("cardId");
|
||||
var opposingCardIds = element.getAttribute("opposingCardIds").split(",");
|
||||
var opposingCardIds = element.getAttribute("otherCardIds").split(",");
|
||||
|
||||
for (var i = 0; i < opposingCardIds.length; i++) {
|
||||
if ($(".card:cardId(" + opposingCardIds[i] + ")").data("card").assign != cardId)
|
||||
@@ -753,7 +753,7 @@ var GempLotrGameUI = Class.extend({
|
||||
if (index != -1)
|
||||
cardData.attachedCards.splice(index, 1);
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
var card = $(".card:cardId(" + cardId + ")");
|
||||
var cardData = card.data("card");
|
||||
@@ -874,7 +874,7 @@ var GempLotrGameUI = Class.extend({
|
||||
if (index != -1)
|
||||
cardData.attachedCards.splice(index, 1);
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
card.remove();
|
||||
@@ -946,13 +946,13 @@ var GempLotrGameUI = Class.extend({
|
||||
this.smallDialog
|
||||
.html(text + "<br /><input id='integerDecision' type='text' value='0'>")
|
||||
.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',
|
||||
typedata: {
|
||||
@@ -984,13 +984,13 @@ var GempLotrGameUI = Class.extend({
|
||||
this.smallDialog
|
||||
.html(html)
|
||||
.dialog("option", "buttons",
|
||||
{
|
||||
"OK": function() {
|
||||
$(this).dialog("close");
|
||||
that.decisionFunction(id, $("#multipleChoiceDecision").val());
|
||||
}
|
||||
}
|
||||
);
|
||||
{
|
||||
"OK": function() {
|
||||
$(this).dialog("close");
|
||||
that.decisionFunction(id, $("#multipleChoiceDecision").val());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
this.smallDialog.dialog("open");
|
||||
},
|
||||
@@ -1234,12 +1234,13 @@ var GempLotrGameUI = Class.extend({
|
||||
var y = event.pageY;
|
||||
$(div).css({left: x, top: y}).fadeIn(150);
|
||||
|
||||
$(div).find('A').mouseover(function() {
|
||||
$(div).find('LI.hover').removeClass('hover');
|
||||
$(this).parent().addClass('hover');
|
||||
}).mouseout(function() {
|
||||
$(div).find('LI.hover').removeClass('hover');
|
||||
});
|
||||
$(div).find('A').mouseover(
|
||||
function() {
|
||||
$(div).find('LI.hover').removeClass('hover');
|
||||
$(this).parent().addClass('hover');
|
||||
}).mouseout(function() {
|
||||
$(div).find('LI.hover').removeClass('hover');
|
||||
});
|
||||
|
||||
var getRidOfContextMenu = function() {
|
||||
$(div).remove();
|
||||
|
||||
Reference in New Issue
Block a user