diff --git a/Mage.Sets/src/mage/cards/s/ShadowOfTheGrave.java b/Mage.Sets/src/mage/cards/s/ShadowOfTheGrave.java index 417732d13a..adea148f58 100644 --- a/Mage.Sets/src/mage/cards/s/ShadowOfTheGrave.java +++ b/Mage.Sets/src/mage/cards/s/ShadowOfTheGrave.java @@ -86,12 +86,11 @@ class ShadowOfTheGraveEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); CardsCycledOrDiscardedThisTurnWatcher watcher = (CardsCycledOrDiscardedThisTurnWatcher) game.getState().getWatchers().get("CardsCycledOrDiscardedThisTurnWatcher"); if (controller != null - && watcher != null - && watcher.getCardsCycledOrDiscardedThisTurn(controller.getId()) != null) { + && watcher != null) { for (Card card : watcher.getCardsCycledOrDiscardedThisTurn(controller.getId()).getCards(game)) { if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD //must come from their graveyard - && card.getOwnerId() == controller.getId()) { //confirm ownership + && card.getOwnerId().equals(controller.getId())) { //confirm ownership controller.moveCardToHandWithInfo(card, source.getId(), game, true); } } diff --git a/Mage/src/main/java/mage/watchers/common/CardsCycledOrDiscardedThisTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/CardsCycledOrDiscardedThisTurnWatcher.java index b54118f03d..a4a8c29a12 100644 --- a/Mage/src/main/java/mage/watchers/common/CardsCycledOrDiscardedThisTurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CardsCycledOrDiscardedThisTurnWatcher.java @@ -31,6 +31,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.UUID; + import mage.cards.Card; import mage.cards.Cards; import mage.cards.CardsImpl; @@ -41,12 +42,12 @@ import mage.watchers.Watcher; /** * Stores cards that were cycled or discarded by any player this turn. + * * @author jeffwadsworth */ public class CardsCycledOrDiscardedThisTurnWatcher extends Watcher { - + private final Map cycledOrDiscardedCardsThisTurn = new HashMap<>(); - Cards cards = new CardsImpl(); public CardsCycledOrDiscardedThisTurnWatcher() { super("CardsCycledOrDiscardedThisTurnWatcher", WatcherScope.GAME); @@ -67,24 +68,22 @@ public class CardsCycledOrDiscardedThisTurnWatcher extends Watcher { if (event.getType() == GameEvent.EventType.CYCLED_CARD || event.getType() == GameEvent.EventType.DISCARDED_CARD) { UUID playerId = event.getPlayerId(); - if (playerId != null + if (playerId != null && game.getCard(event.getTargetId()) != null) { Card card = game.getCard(event.getTargetId()); - cards.add(card); - cycledOrDiscardedCardsThisTurn.putIfAbsent(playerId, cards); + getCardsCycledOrDiscardedThisTurn(playerId).add(card); } } } - public Cards getCardsCycledOrDiscardedThisTurn(UUID playerId) { - return cycledOrDiscardedCardsThisTurn.get(playerId); + public Cards getCardsCycledOrDiscardedThisTurn(UUID playerId) { + return cycledOrDiscardedCardsThisTurn.getOrDefault(playerId, new CardsImpl()); } @Override public void reset() { super.reset(); cycledOrDiscardedCardsThisTurn.clear(); - cards.clear(); } @Override