mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Shadow of the Grave - Some minor adjustments.
This commit is contained in:
parent
7f1da83783
commit
33f6c629c2
2 changed files with 10 additions and 14 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue