Used Sets in Word of Undoing

This commit is contained in:
Thomas Contis 2018-04-15 08:55:22 -04:00
parent 9da1495e5e
commit 279759078c

View file

@ -27,27 +27,21 @@
*/ */
package mage.cards.w; package mage.cards.w;
import java.util.LinkedList; import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.ComparisonType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
/** /**
@ -93,18 +87,19 @@ class WordOfUndoingReturnToHandEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Set<Card> attachments = new LinkedHashSet<>();
Player player = game.getPlayer(source.getControllerId());
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) { if (target != null) {
LinkedList<UUID> attachments = new LinkedList<>(); for (UUID attachmentId : target.getAttachments()) {
attachments.addAll(target.getAttachments());
for (UUID attachmentId : attachments) {
Permanent attachment = game.getPermanent(attachmentId); Permanent attachment = game.getPermanent(attachmentId);
if (attachment != null && attachment.getControllerId().equals(source.getControllerId()) if (attachment != null && attachment.getControllerId().equals(source.getControllerId())
&& attachment.hasSubtype(SubType.AURA, game) && attachment.getColor(game).isWhite()) { && attachment.hasSubtype(SubType.AURA, game) && attachment.getColor(game).isWhite()) {
attachment.moveToZone(Zone.HAND, source.getSourceId(), game, false); attachments.add(attachment);
} }
} }
target.moveToZone(Zone.HAND, source.getSourceId(), game, false); attachments.add(target);
player.moveCards(attachments, Zone.HAND, source, game);
return true; return true;
} }
return false; return false;