From 90e9a21aa50fb944c00f189f85f7084a0a4aa216 Mon Sep 17 00:00:00 2001
From: LevelX2 <ludwig.hirth@online.de>
Date: Thu, 26 Apr 2018 17:30:44 +0200
Subject: [PATCH] * Replaced some wrong card movement handling.

---
 Mage.Sets/src/mage/cards/s/SummonersEgg.java  | 19 +++----
 Mage.Sets/src/mage/cards/s/SynodSanctum.java  | 22 ++------
 .../src/mage/cards/t/TeleminPerformance.java  | 50 +++++++++++--------
 .../main/java/mage/filter/StaticFilters.java  |  5 ++
 4 files changed, 47 insertions(+), 49 deletions(-)

diff --git a/Mage.Sets/src/mage/cards/s/SummonersEgg.java b/Mage.Sets/src/mage/cards/s/SummonersEgg.java
index 23e86cfdc8..ea98343ce9 100644
--- a/Mage.Sets/src/mage/cards/s/SummonersEgg.java
+++ b/Mage.Sets/src/mage/cards/s/SummonersEgg.java
@@ -37,10 +37,10 @@ import mage.cards.Card;
 import mage.cards.CardImpl;
 import mage.cards.CardSetInfo;
 import mage.constants.CardType;
-import mage.constants.SubType;
 import mage.constants.Outcome;
+import mage.constants.SubType;
 import mage.constants.Zone;
-import mage.filter.FilterCard;
+import mage.filter.StaticFilters;
 import mage.game.Game;
 import mage.game.permanent.Permanent;
 import mage.players.Player;
@@ -54,7 +54,7 @@ import mage.util.CardUtil;
 public class SummonersEgg extends CardImpl {
 
     public SummonersEgg(UUID ownerId, CardSetInfo setInfo) {
-        super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{4}");
+        super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{4}");
         this.subtype.add(SubType.CONSTRUCT);
         this.power = new MageInt(0);
         this.toughness = new MageInt(4);
@@ -90,9 +90,9 @@ class SummonersEggImprintEffect extends OneShotEffect {
     public boolean apply(Game game, Ability source) {
         Player controller = game.getPlayer(source.getControllerId());
         Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
-        if (controller != null) {
+        if (controller != null && sourcePermanent != null) {
             if (!controller.getHand().isEmpty()) {
-                TargetCard target = new TargetCard(Zone.HAND, new FilterCard());
+                TargetCard target = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD);
                 if (target.canChoose(source.getSourceId(), source.getControllerId(), game)
                         && controller.choose(Outcome.Benefit, controller.getHand(), target, game)) {
                     Card card = controller.getHand().get(target.getFirstTarget(), game);
@@ -100,11 +100,8 @@ class SummonersEggImprintEffect extends OneShotEffect {
                         card.setFaceDown(true, game);
                         controller.moveCardsToExile(card, source, game, false, source.getSourceId(), sourcePermanent.getIdName() + " (Imprint)");
                         card.setFaceDown(true, game);
-                        Permanent permanent = game.getPermanent(source.getSourceId());
-                        if (permanent != null) {
-                            permanent.imprint(card.getId(), game);
-                            permanent.addInfo("imprint", CardUtil.addToolTipMarkTags("[Imprinted card]"), game);
-                        }
+                        sourcePermanent.imprint(card.getId(), game);
+                        sourcePermanent.addInfo("imprint", CardUtil.addToolTipMarkTags("[Imprinted card]"), game);
                     }
                 }
             }
@@ -150,7 +147,7 @@ class SummonersEggPutOntoBattlefieldEffect extends OneShotEffect {
                     //If it's a creature card,
                     if (imprintedCard.isCreature()) {
                         //put it onto the battlefield under your control
-                        imprintedCard.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), source.getControllerId());
+                        controller.moveCards(imprintedCard, Zone.BATTLEFIELD, source, game);
                     }
                 }
             }
diff --git a/Mage.Sets/src/mage/cards/s/SynodSanctum.java b/Mage.Sets/src/mage/cards/s/SynodSanctum.java
index b6d3b6f3a3..765a6348be 100644
--- a/Mage.Sets/src/mage/cards/s/SynodSanctum.java
+++ b/Mage.Sets/src/mage/cards/s/SynodSanctum.java
@@ -35,7 +35,6 @@ import mage.abilities.costs.common.SacrificeSourceCost;
 import mage.abilities.costs.common.TapSourceCost;
 import mage.abilities.costs.mana.ManaCostsImpl;
 import mage.abilities.effects.OneShotEffect;
-import mage.cards.Card;
 import mage.cards.CardImpl;
 import mage.cards.CardSetInfo;
 import mage.constants.CardType;
@@ -142,24 +141,13 @@ class SynodSanctumEffect2 extends OneShotEffect {
     @Override
     public boolean apply(Game game, Ability source) {
         UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
-        if (exileId == null) {
-            return false;
+        ExileZone exileZone = game.getExile().getExileZone(exileId);
+        if (exileZone == null) {
+            return true;
         }
-        ExileZone exile = game.getExile().getExileZone(exileId);
-        if (exile == null) {
-            return false;
-        }
-
         Player controller = game.getPlayer(source.getControllerId());
-        MageObject sourceObject = game.getObject(source.getSourceId());
-        boolean allReturned = true;
-        if (controller != null && sourceObject != null) {
-            for (Card card : exile.getCards(game)) {
-                if (!card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), controller.getId())) {
-                    allReturned = false;
-                }
-            }
-            return allReturned;
+        if (controller != null) {
+            return controller.moveCards(exileZone, Zone.BATTLEFIELD, source, game);
         }
         return false;
     }
diff --git a/Mage.Sets/src/mage/cards/t/TeleminPerformance.java b/Mage.Sets/src/mage/cards/t/TeleminPerformance.java
index b8e9c0347f..6be3dbef0b 100644
--- a/Mage.Sets/src/mage/cards/t/TeleminPerformance.java
+++ b/Mage.Sets/src/mage/cards/t/TeleminPerformance.java
@@ -28,6 +28,7 @@
 package mage.cards.t;
 
 import java.util.UUID;
+import mage.MageObject;
 import mage.abilities.Ability;
 import mage.abilities.effects.OneShotEffect;
 import mage.cards.Card;
@@ -48,8 +49,7 @@ import mage.target.common.TargetOpponent;
 public class TeleminPerformance extends CardImpl {
 
     public TeleminPerformance(UUID ownerId, CardSetInfo setInfo) {
-        super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{U}{U}");
-
+        super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}{U}");
 
         // Target opponent reveals cards from the top of their library until he or she reveals a creature card. That player puts all noncreature cards revealed this way into their graveyard, then you put the creature card onto the battlefield under your control.
         this.getSpellAbility().addEffect(new TeleminPerformanceEffect());
@@ -85,28 +85,36 @@ class TeleminPerformanceEffect extends OneShotEffect {
 
     @Override
     public boolean apply(Game game, Ability source) {
-        Card creature = null;
-        Player opponent = game.getPlayer(source.getFirstTarget());
-        CardsImpl cards = new CardsImpl();
-        boolean creatureFound = false;
-        while (opponent.getLibrary().hasCards() && !creatureFound) {
-            Card card = opponent.getLibrary().removeFromTop(game);
-            if (card != null) {
-                if (card.isCreature()) {
-                    creature = card;
-                    creatureFound = true;
+        Player controller = game.getPlayer(source.getControllerId());
+        MageObject sourceObject = game.getObject(source.getSourceId());
+        if (controller != null && sourceObject != null) {
+            Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
+            if (opponent != null) {
+                Card creature = null;
+                CardsImpl cards = new CardsImpl();
+                boolean creatureFound = false;
+                while (opponent.getLibrary().hasCards() && !creatureFound) {
+                    Card card = opponent.getLibrary().removeFromTop(game);
+                    if (card != null) {
+                        if (card.isCreature()) {
+                            creature = card;
+                            creatureFound = true;
+                        }
+                        if (!creatureFound) {
+                            cards.add(card);
+                        }
+                    }
                 }
-                if (!creatureFound) {
-                    cards.add(card);
+                if (!cards.isEmpty()) {
+                    opponent.revealCards(sourceObject.getIdName(), cards, game);
+                    opponent.moveCards(cards, Zone.GRAVEYARD, source, game);
+                }
+                game.applyEffects();
+                if (creature != null) {
+                    controller.moveCards(creature, Zone.BATTLEFIELD, source, game);
                 }
             }
-        }
-        if (!cards.isEmpty()) {            
-            opponent.revealCards("Telemin Performance", cards, game);
-            opponent.moveCards(cards, Zone.GRAVEYARD, source, game);
-        }
-        if (creature != null) {
-            return creature.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
+            return true;
         }
         return false;
     }
diff --git a/Mage/src/main/java/mage/filter/StaticFilters.java b/Mage/src/main/java/mage/filter/StaticFilters.java
index 0533f7cbfd..5e0dee3d5c 100644
--- a/Mage/src/main/java/mage/filter/StaticFilters.java
+++ b/Mage/src/main/java/mage/filter/StaticFilters.java
@@ -41,6 +41,11 @@ public final class StaticFilters {
     static {
         FILTER_ENCHANTMENT_PERMANENT.setLockedFilter(true);
     }
+    public static final FilterCard FILTER_CARD = new FilterCard("card");
+
+    static {
+        FILTER_CARD.setLockedFilter(true);
+    }
 
     public static final FilterCard FILTER_CARD_CARDS = new FilterCard("cards");