* Shadow of the Grave - Some minor adjustments.

This commit is contained in:
LevelX2 2017-04-28 11:18:26 +02:00
parent 7f1da83783
commit 33f6c629c2
2 changed files with 10 additions and 14 deletions

View file

@ -84,13 +84,13 @@ class ShadowOfTheGraveEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
CardsCycledOrDiscardedThisTurnWatcher watcher = (CardsCycledOrDiscardedThisTurnWatcher) game.getState().getWatchers().get("CardsCycledOrDiscardedThisTurnWatcher"); CardsCycledOrDiscardedThisTurnWatcher watcher = (CardsCycledOrDiscardedThisTurnWatcher) game.getState()
.getWatchers().get(CardsCycledOrDiscardedThisTurnWatcher.class.getName());
if (controller != null if (controller != null
&& watcher != null) { && watcher != null) {
for (Card card : watcher.getCardsCycledOrDiscardedThisTurn(controller.getId()).getCards(game)) { for (Card card : watcher.getCardsCycledOrDiscardedThisTurn(controller.getId()).getCards(game)) {
if (card != null if (game.getState().getZone(card.getId()) == Zone.GRAVEYARD //must come from their graveyard
&& game.getState().getZone(card.getId()) == Zone.GRAVEYARD //must come from their graveyard && card.getOwnerId().equals(controller.getId())) { //confirm ownership, but it should not be possible to get not ownwd cards here
&& card.getOwnerId().equals(controller.getId())) { //confirm ownership
controller.moveCardToHandWithInfo(card, source.getId(), game, true); controller.moveCardToHandWithInfo(card, source.getId(), game, true);
} }
} }

View file

@ -31,7 +31,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
@ -50,28 +49,25 @@ public class CardsCycledOrDiscardedThisTurnWatcher extends Watcher {
private final Map<UUID, Cards> cycledOrDiscardedCardsThisTurn = new HashMap<>(); private final Map<UUID, Cards> cycledOrDiscardedCardsThisTurn = new HashMap<>();
public CardsCycledOrDiscardedThisTurnWatcher() { public CardsCycledOrDiscardedThisTurnWatcher() {
super("CardsCycledOrDiscardedThisTurnWatcher", WatcherScope.GAME); super(CardsCycledOrDiscardedThisTurnWatcher.class.getName(), WatcherScope.GAME);
} }
public CardsCycledOrDiscardedThisTurnWatcher(final CardsCycledOrDiscardedThisTurnWatcher watcher) { public CardsCycledOrDiscardedThisTurnWatcher(final CardsCycledOrDiscardedThisTurnWatcher watcher) {
super(watcher); super(watcher);
for (Entry<UUID, Cards> entry : watcher.cycledOrDiscardedCardsThisTurn.entrySet()) { for (Entry<UUID, Cards> entry : watcher.cycledOrDiscardedCardsThisTurn.entrySet()) {
cycledOrDiscardedCardsThisTurn.put(entry.getKey(), entry.getValue()); cycledOrDiscardedCardsThisTurn.put(entry.getKey(), entry.getValue().copy());
} }
} }
@Override @Override
public void watch(GameEvent event, Game game) { public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.UNTAP_STEP_PRE) {
reset();
}
if (event.getType() == GameEvent.EventType.CYCLED_CARD if (event.getType() == GameEvent.EventType.CYCLED_CARD
|| event.getType() == GameEvent.EventType.DISCARDED_CARD) { || event.getType() == GameEvent.EventType.DISCARDED_CARD) {
UUID playerId = event.getPlayerId(); if (event.getPlayerId() != null) {
if (playerId != null
&& game.getCard(event.getTargetId()) != null) {
Card card = game.getCard(event.getTargetId()); Card card = game.getCard(event.getTargetId());
getCardsCycledOrDiscardedThisTurn(playerId).add(card); if (card != null) {
getCardsCycledOrDiscardedThisTurn(event.getPlayerId()).add(card);
}
} }
} }
} }