From 4f69306749c4dbe2b3958e69798e06305d93570c Mon Sep 17 00:00:00 2001
From: Thomas Contis <thomas@contis.org>
Date: Sat, 14 Apr 2018 22:11:09 -0400
Subject: [PATCH 1/3] Implemented Word of Undoing (Ice Age)

---
 Mage.Sets/src/mage/cards/w/WordOfUndoing.java | 113 ++++++++++++++++++
 Mage.Sets/src/mage/sets/IceAge.java           |   1 +
 Mage.Sets/src/mage/sets/MastersEdition.java   |   1 +
 3 files changed, 115 insertions(+)
 create mode 100644 Mage.Sets/src/mage/cards/w/WordOfUndoing.java

diff --git a/Mage.Sets/src/mage/cards/w/WordOfUndoing.java b/Mage.Sets/src/mage/cards/w/WordOfUndoing.java
new file mode 100644
index 0000000000..c6efb119e0
--- /dev/null
+++ b/Mage.Sets/src/mage/cards/w/WordOfUndoing.java
@@ -0,0 +1,113 @@
+/*
+ *  Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without modification, are
+ *  permitted provided that the following conditions are met:
+ *
+ *     1. Redistributions of source code must retain the above copyright notice, this list of
+ *        conditions and the following disclaimer.
+ *
+ *     2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *        of conditions and the following disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ *  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
+ *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ *  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ *  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  The views and conclusions contained in the software and documentation are those of the
+ *  authors and should not be interpreted as representing official policies, either expressed
+ *  or implied, of BetaSteward_at_googlemail.com.
+ */
+package mage.cards.w;
+
+import java.util.LinkedList;
+import java.util.UUID;
+import mage.abilities.Ability;
+import mage.abilities.Mode;
+import mage.abilities.effects.OneShotEffect;
+import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
+import mage.cards.CardImpl;
+import mage.cards.CardSetInfo;
+import mage.constants.CardType;
+import mage.constants.SubType;
+import mage.constants.ComparisonType;
+import mage.constants.Outcome;
+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.permanent.Permanent;
+import mage.players.Player;
+import mage.target.common.TargetCardInYourGraveyard;
+import mage.target.common.TargetControlledCreaturePermanent;
+import mage.target.common.TargetCreaturePermanent;
+
+/**
+ *
+ * @author tcontis
+ */
+public class WordOfUndoing extends CardImpl {
+
+    public WordOfUndoing(UUID ownerId, CardSetInfo setInfo) {
+        super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{U}");
+
+        //Return target creature and all white Auras you own attached to it to their owners’ hands.
+        this.getSpellAbility().addEffect(new WordOfUndoingReturnToHandEffect());
+        this.getSpellAbility().addTarget(new TargetCreaturePermanent());
+
+    }
+
+    public WordOfUndoing(final WordOfUndoing card) {
+        super(card);
+    }
+
+    @Override
+    public WordOfUndoing copy() {
+        return new WordOfUndoing(this);
+    }
+}
+
+class WordOfUndoingReturnToHandEffect extends OneShotEffect {
+
+    public WordOfUndoingReturnToHandEffect() {
+        super(Outcome.ReturnToHand);
+        this.staticText = "Return target creature and all white Auras you own attached to it to their owners’ hands.";
+    }
+
+    public WordOfUndoingReturnToHandEffect(final WordOfUndoingReturnToHandEffect effect) {
+        super(effect);
+    }
+
+    @Override
+    public WordOfUndoingReturnToHandEffect copy() {
+        return new WordOfUndoingReturnToHandEffect(this);
+    }
+
+    @Override
+    public boolean apply(Game game, Ability source) {
+        Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
+        if (target != null) {
+            LinkedList<UUID> attachments = new LinkedList<>();
+            attachments.addAll(target.getAttachments());
+            for (UUID attachmentId : attachments) {
+                Permanent attachment = game.getPermanent(attachmentId);
+                if (attachment != null && attachment.getControllerId().equals(source.getControllerId())
+                        && attachment.hasSubtype(SubType.AURA, game) && attachment.getColor(game).isWhite()) {
+                    attachment.moveToZone(Zone.HAND, source.getSourceId(), game, false);
+                }
+            }
+            target.moveToZone(Zone.HAND, source.getSourceId(), game, false);
+            return true;
+        }
+        return false;
+    }
+}
+
diff --git a/Mage.Sets/src/mage/sets/IceAge.java b/Mage.Sets/src/mage/sets/IceAge.java
index 37048084b9..feb951334b 100644
--- a/Mage.Sets/src/mage/sets/IceAge.java
+++ b/Mage.Sets/src/mage/sets/IceAge.java
@@ -362,6 +362,7 @@ public class IceAge extends ExpansionSet {
         cards.add(new SetCardInfo("Withering Wisps", 56, Rarity.UNCOMMON, mage.cards.w.WitheringWisps.class));
         cards.add(new SetCardInfo("Woolly Mammoths", 166, Rarity.COMMON, mage.cards.w.WoollyMammoths.class));
         cards.add(new SetCardInfo("Word of Blasting", 224, Rarity.UNCOMMON, mage.cards.w.WordOfBlasting.class));
+        cards.add(new SetCardInfo("Word of Undoing", 108, Rarity.COMMON, mage.cards.w.WordOfUndoing.class));
         cards.add(new SetCardInfo("Wrath of Marit Lage", 109, Rarity.RARE, mage.cards.w.WrathOfMaritLage.class));
         cards.add(new SetCardInfo("Yavimaya Gnats", 168, Rarity.UNCOMMON, mage.cards.y.YavimayaGnats.class));
         cards.add(new SetCardInfo("Zuran Enchanter", 110, Rarity.COMMON, mage.cards.z.ZuranEnchanter.class));
diff --git a/Mage.Sets/src/mage/sets/MastersEdition.java b/Mage.Sets/src/mage/sets/MastersEdition.java
index a1939fe06f..9abd2a7110 100644
--- a/Mage.Sets/src/mage/sets/MastersEdition.java
+++ b/Mage.Sets/src/mage/sets/MastersEdition.java
@@ -251,6 +251,7 @@ public class MastersEdition extends ExpansionSet {
         cards.add(new SetCardInfo("Winds of Change", 111, Rarity.UNCOMMON, mage.cards.w.WindsOfChange.class));
         cards.add(new SetCardInfo("Winter Blast", 138, Rarity.UNCOMMON, mage.cards.w.WinterBlast.class));
         cards.add(new SetCardInfo("Winter Orb", 173, Rarity.RARE, mage.cards.w.WinterOrb.class));
+        cards.add(new SetCardInfo("Word of Undoing", 56, Rarity.COMMON, mage.cards.w.WordOfUndoing.class));
         cards.add(new SetCardInfo("Wyluli Wolf", 139, Rarity.COMMON, mage.cards.w.WyluliWolf.class));
         cards.add(new SetCardInfo("Yavimaya Ants", 140, Rarity.UNCOMMON, mage.cards.y.YavimayaAnts.class));
         cards.add(new SetCardInfo("Ydwen Efreet", 112, Rarity.RARE, mage.cards.y.YdwenEfreet.class));

From 9da1495e5e9e3baeb853bd226d08042639f29564 Mon Sep 17 00:00:00 2001
From: Thomas Contis <thomas@contis.org>
Date: Sat, 14 Apr 2018 22:33:58 -0400
Subject: [PATCH 2/3] Implemented Woolly Spider (Ice Age)

---
 Mage.Sets/src/mage/cards/w/WoollySpider.java  | 105 ++++++++++++++++++
 Mage.Sets/src/mage/sets/IceAge.java           |   1 +
 Mage.Sets/src/mage/sets/MastersEditionII.java |   1 +
 3 files changed, 107 insertions(+)
 create mode 100644 Mage.Sets/src/mage/cards/w/WoollySpider.java

diff --git a/Mage.Sets/src/mage/cards/w/WoollySpider.java b/Mage.Sets/src/mage/cards/w/WoollySpider.java
new file mode 100644
index 0000000000..1b50ef0b89
--- /dev/null
+++ b/Mage.Sets/src/mage/cards/w/WoollySpider.java
@@ -0,0 +1,105 @@
+/*
+ *  Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without modification, are
+ *  permitted provided that the following conditions are met:
+ *
+ *     1. Redistributions of source code must retain the above copyright notice, this list of
+ *        conditions and the following disclaimer.
+ *
+ *     2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *        of conditions and the following disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ *  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
+ *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ *  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ *  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  The views and conclusions contained in the software and documentation are those of the
+ *  authors and should not be interpreted as representing official policies, either expressed
+ *  or implied, of BetaSteward_at_googlemail.com.
+ */
+package mage.cards.w;
+
+import java.util.UUID;
+import mage.MageInt;
+import mage.abilities.TriggeredAbilityImpl;
+import mage.abilities.effects.Effect;
+import mage.abilities.effects.common.continuous.BoostSourceEffect;
+import mage.abilities.keyword.FlyingAbility;
+import mage.abilities.keyword.ReachAbility;
+import mage.cards.CardImpl;
+import mage.cards.CardSetInfo;
+import mage.constants.CardType;
+import mage.constants.SubType;
+import mage.constants.Duration;
+import mage.constants.Zone;
+import mage.game.Game;
+import mage.game.events.GameEvent;
+import mage.game.events.GameEvent.EventType;
+
+/**
+ *
+ * @author tcontis
+ */
+public class WoollySpider extends CardImpl {
+
+    public WoollySpider(UUID ownerId, CardSetInfo setInfo) {
+        super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{G}{G}");
+        this.subtype.add(SubType.SPIDER);
+
+        this.power = new MageInt(2);
+        this.toughness = new MageInt(3);
+
+        // Reach
+        this.addAbility(ReachAbility.getInstance());
+        // Whenever Woolly Spider blocks a creature with flying, Woolly Spider gets +0/+2 until end of turn.
+        this.addAbility(new BlocksCreatureWithFlyingTriggeredAbility(new BoostSourceEffect(0, 2, Duration.EndOfTurn), false));
+    }
+
+    public WoollySpider(final WoollySpider card) {
+        super(card);
+    }
+
+    @Override
+    public WoollySpider copy() {
+        return new WoollySpider(this);
+    }
+}
+
+class BlocksCreatureWithFlyingTriggeredAbility extends TriggeredAbilityImpl {
+
+    public BlocksCreatureWithFlyingTriggeredAbility(Effect effect, boolean optional) {
+        super(Zone.BATTLEFIELD, effect, optional);
+    }
+
+    public BlocksCreatureWithFlyingTriggeredAbility(final BlocksCreatureWithFlyingTriggeredAbility ability) {
+        super(ability);
+    }
+
+    @Override
+    public boolean checkEventType(GameEvent event, Game game) {
+        return event.getType() == EventType.BLOCKER_DECLARED;
+    }
+
+    @Override
+    public boolean checkTrigger(GameEvent event, Game game) {
+        return event.getSourceId().equals(this.getSourceId()) && game.getPermanent(event.getTargetId()).getAbilities().containsKey(FlyingAbility.getInstance().getId());
+    }
+
+    @Override
+    public String getRule() {
+        return "Whenever {this} blocks a creature with flying, " + super.getRule();
+    }
+
+    @Override
+    public BlocksCreatureWithFlyingTriggeredAbility copy() {
+        return new BlocksCreatureWithFlyingTriggeredAbility(this);
+    }
+}
\ No newline at end of file
diff --git a/Mage.Sets/src/mage/sets/IceAge.java b/Mage.Sets/src/mage/sets/IceAge.java
index feb951334b..f1b14f59a1 100644
--- a/Mage.Sets/src/mage/sets/IceAge.java
+++ b/Mage.Sets/src/mage/sets/IceAge.java
@@ -361,6 +361,7 @@ public class IceAge extends ExpansionSet {
         cards.add(new SetCardInfo("Wings of Aesthir", 383, Rarity.UNCOMMON, mage.cards.w.WingsOfAesthir.class));
         cards.add(new SetCardInfo("Withering Wisps", 56, Rarity.UNCOMMON, mage.cards.w.WitheringWisps.class));
         cards.add(new SetCardInfo("Woolly Mammoths", 166, Rarity.COMMON, mage.cards.w.WoollyMammoths.class));
+        cards.add(new SetCardInfo("Woolly Spider", 279, Rarity.COMMON, mage.cards.w.WoollySpider.class));
         cards.add(new SetCardInfo("Word of Blasting", 224, Rarity.UNCOMMON, mage.cards.w.WordOfBlasting.class));
         cards.add(new SetCardInfo("Word of Undoing", 108, Rarity.COMMON, mage.cards.w.WordOfUndoing.class));
         cards.add(new SetCardInfo("Wrath of Marit Lage", 109, Rarity.RARE, mage.cards.w.WrathOfMaritLage.class));
diff --git a/Mage.Sets/src/mage/sets/MastersEditionII.java b/Mage.Sets/src/mage/sets/MastersEditionII.java
index 3091a05e18..784a0aff50 100644
--- a/Mage.Sets/src/mage/sets/MastersEditionII.java
+++ b/Mage.Sets/src/mage/sets/MastersEditionII.java
@@ -277,6 +277,7 @@ public class MastersEditionII extends ExpansionSet {
         cards.add(new SetCardInfo("Withering Wisps", 114, Rarity.UNCOMMON, mage.cards.w.WitheringWisps.class));
         cards.add(new SetCardInfo("Wolf Pack", 187, Rarity.RARE, mage.cards.w.WolfPack.class));
         cards.add(new SetCardInfo("Woolly Mammoths", 188, Rarity.COMMON, mage.cards.w.WoollyMammoths.class));
+        cards.add(new SetCardInfo("Woolly Spider", 189, Rarity.UNCOMMON, mage.cards.w.WoollySpider.class));
         cards.add(new SetCardInfo("Yavimaya Ancients", 190, Rarity.UNCOMMON, mage.cards.y.YavimayaAncients.class));
         cards.add(new SetCardInfo("Zuran Spellcaster", 76, Rarity.COMMON, mage.cards.z.ZuranSpellcaster.class));
     }

From 279759078c307bb6f794d92f9a86797e17e8e3fd Mon Sep 17 00:00:00 2001
From: Thomas Contis <thomas@contis.org>
Date: Sun, 15 Apr 2018 08:55:22 -0400
Subject: [PATCH 3/3] Used Sets in Word of Undoing

---
 Mage.Sets/src/mage/cards/w/WordOfUndoing.java | 23 ++++++++-----------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/Mage.Sets/src/mage/cards/w/WordOfUndoing.java b/Mage.Sets/src/mage/cards/w/WordOfUndoing.java
index c6efb119e0..07f5e31a49 100644
--- a/Mage.Sets/src/mage/cards/w/WordOfUndoing.java
+++ b/Mage.Sets/src/mage/cards/w/WordOfUndoing.java
@@ -27,27 +27,21 @@
  */
 package mage.cards.w;
 
-import java.util.LinkedList;
+import java.util.LinkedHashSet;
+import java.util.Set;
 import java.util.UUID;
 import mage.abilities.Ability;
-import mage.abilities.Mode;
 import mage.abilities.effects.OneShotEffect;
-import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
+import mage.cards.Card;
 import mage.cards.CardImpl;
 import mage.cards.CardSetInfo;
 import mage.constants.CardType;
 import mage.constants.SubType;
-import mage.constants.ComparisonType;
 import mage.constants.Outcome;
 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.permanent.Permanent;
 import mage.players.Player;
-import mage.target.common.TargetCardInYourGraveyard;
-import mage.target.common.TargetControlledCreaturePermanent;
 import mage.target.common.TargetCreaturePermanent;
 
 /**
@@ -93,18 +87,19 @@ class WordOfUndoingReturnToHandEffect extends OneShotEffect {
 
     @Override
     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));
         if (target != null) {
-            LinkedList<UUID> attachments = new LinkedList<>();
-            attachments.addAll(target.getAttachments());
-            for (UUID attachmentId : attachments) {
+            for (UUID attachmentId : target.getAttachments()) {
                 Permanent attachment = game.getPermanent(attachmentId);
                 if (attachment != null && attachment.getControllerId().equals(source.getControllerId())
                         && 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 false;