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