mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Merge pull request #3261 from ingmargoudt/fix_cyclediscardwatcher
fix for shadow of the grave
This commit is contained in:
commit
7f1da83783
2 changed files with 9 additions and 11 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<UUID, Cards> 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
|
||||
|
|
Loading…
Reference in a new issue