From da163305c417bfdba73d366cdf932a2a00d6e28c Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Tue, 18 Oct 2011 13:17:17 +0000 Subject: [PATCH] Fixing the new GameStats --- .../com/gempukku/lotro/filters/Filters.java | 2 + .../lotro/logic/timing/GameStats.java | 18 +- .../src/main/webapp/js/gameAnimations.js | 173 +++++++++--------- 3 files changed, 100 insertions(+), 93 deletions(-) diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/filters/Filters.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/filters/Filters.java index 0cb84603f..b45fa1c36 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/filters/Filters.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/filters/Filters.java @@ -469,6 +469,8 @@ public class Filters { } private static Filter changeToFilter(Filterable filter) { + if (filter == null) + return null; if (filter instanceof Filter) return (Filter) filter; else if (filter instanceof PhysicalCard) diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/GameStats.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/GameStats.java index 0ff7275e6..5b99b0b25 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/GameStats.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/GameStats.java @@ -2,6 +2,7 @@ package com.gempukku.lotro.logic.timing; import com.gempukku.lotro.common.Zone; import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.PlayerOrder; import java.util.HashMap; import java.util.Map; @@ -61,13 +62,16 @@ public class GameStats { } Map> newZoneSizes = new HashMap>(); - for (String player : game.getGameState().getPlayerOrder().getAllPlayers()) { - final HashMap playerZoneSizes = new HashMap(); - playerZoneSizes.put(Zone.HAND, game.getGameState().getHand(player).size()); - playerZoneSizes.put(Zone.DECK, game.getGameState().getDeck(player).size()); - playerZoneSizes.put(Zone.DISCARD, game.getGameState().getDiscard(player).size()); - playerZoneSizes.put(Zone.DEAD, game.getGameState().getDeadPile(player).size()); - newZoneSizes.put(player, playerZoneSizes); + PlayerOrder playerOrder = game.getGameState().getPlayerOrder(); + if (playerOrder != null) { + for (String player : playerOrder.getAllPlayers()) { + final HashMap playerZoneSizes = new HashMap(); + playerZoneSizes.put(Zone.HAND, game.getGameState().getHand(player).size()); + playerZoneSizes.put(Zone.DECK, game.getGameState().getDeck(player).size()); + playerZoneSizes.put(Zone.DISCARD, game.getGameState().getDiscard(player).size()); + playerZoneSizes.put(Zone.DEAD, game.getGameState().getDeadPile(player).size()); + newZoneSizes.put(player, playerZoneSizes); + } } if (!newZoneSizes.equals(_zoneSizes)) { diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameAnimations.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameAnimations.js index 427ec77eb..1ed77d25e 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameAnimations.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameAnimations.js @@ -32,40 +32,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(); @@ -103,26 +103,26 @@ var GameAnimations = Class.extend({ 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}); + { + 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}); + { + 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); @@ -136,7 +136,7 @@ var GameAnimations = Class.extend({ $(this).remove(); } } - ); + ); next(); }); } @@ -206,29 +206,29 @@ 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( - { - opacity: 1}, - { - duration: that.putCardIntoPlayDuration / 8, - easing: "linear", - step: function(now, fx) { - layoutCardElem(cardDiv, - (gameWidth / 2 - cardWidth / 4) - now * (cardWidth / 4), - gameHeight * (3 / 8) - now * (gameHeight / 8), - cardWidth / 2 + now * (cardWidth / 2), - cardHeight / 2 + now * (cardHeight / 2), 100); - }, - complete: next}); + { + opacity: 1}, + { + duration: that.putCardIntoPlayDuration / 8, + easing: "linear", + step: function(now, fx) { + layoutCardElem(cardDiv, + (gameWidth / 2 - cardWidth / 4) - now * (cardWidth / 4), + gameHeight * (3 / 8) - now * (gameHeight / 8), + cardWidth / 2 + now * (cardWidth / 2), + cardHeight / 2 + now * (cardHeight / 2), 100); + }, + complete: next}); }).queue( function(next) { setTimeout(next, that.putCardIntoPlayDuration * (5 / 8)); @@ -243,20 +243,20 @@ var GameAnimations = Class.extend({ var startHeight = cardDiv.height(); $(cardDiv).animate( - { - left: oldValues["left"]}, - { - duration: that.putCardIntoPlayDuration / 4, - easing: "linear", - step: function(now, fx) { - var state = fx.state; - layoutCardElem(cardDiv, - startLeft + (oldValues["left"] - startLeft) * state, - startTop + (oldValues["top"] - startTop) * state, - startWidth + (oldValues["width"] - startWidth) * state, - startHeight + (oldValues["height"] - startHeight) * state, 100); - }, - complete: next}); + { + left: oldValues["left"]}, + { + duration: that.putCardIntoPlayDuration / 4, + easing: "linear", + step: function(now, fx) { + var state = fx.state; + layoutCardElem(cardDiv, + startLeft + (oldValues["left"] - startLeft) * state, + startTop + (oldValues["top"] - startTop) * state, + startWidth + (oldValues["width"] - startWidth) * state, + startHeight + (oldValues["height"] - startHeight) * state, 100); + }, + complete: next}); }).queue( function(next) { var cardDiv = $(".card:cardId(" + cardId + ")"); @@ -292,7 +292,7 @@ var GameAnimations = Class.extend({ if (index != -1) cardData.attachedCards.splice(index, 1); } - ); + ); var card = $(".card:cardId(" + cardId + ")"); var cardData = card.data("card"); @@ -335,7 +335,7 @@ var GameAnimations = Class.extend({ if (index != -1) cardData.attachedCards.splice(index, 1); } - ); + ); } card.remove(); @@ -564,9 +564,10 @@ var GameAnimations = Class.extend({ $("#deadPile" + that.game.getPlayerIndex(playerId)).text("Dead pile: " + dead); $("#deck" + that.game.getPlayerIndex(playerId)).text("Deck: " + deck); } - - that.game.fpStrengthDiv.text(element.getAttribute("fellowshipStrength")); - that.game.shadowStrengthDiv.text(element.getAttribute("shadowStrength")); + if (that.game.fpStrengthDiv != null) + that.game.fpStrengthDiv.text(element.getAttribute("fellowshipStrength")); + if (that.game.shadowStrengthDiv != null) + that.game.shadowStrengthDiv.text(element.getAttribute("shadowStrength")); next(); });