diff --git a/Mage.Sets/src/mage/sets/darkascension/DungeonGeists.java b/Mage.Sets/src/mage/sets/darkascension/DungeonGeists.java index ed3e6386de..a430fef4b3 100644 --- a/Mage.Sets/src/mage/sets/darkascension/DungeonGeists.java +++ b/Mage.Sets/src/mage/sets/darkascension/DungeonGeists.java @@ -45,7 +45,6 @@ import mage.game.events.GameEvent; import mage.game.events.ZoneChangeEvent; import mage.target.Target; import mage.target.common.TargetCreaturePermanent; -import mage.watchers.Watcher; import mage.watchers.WatcherImpl; import java.util.UUID; @@ -121,16 +120,28 @@ class DungeonGeistsEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - //don't replace untap event if control of this has been lost - Watcher watcher = game.getState().getWatchers().get("ControlLost", source.getSourceId()); - if (watcher == null || !watcher.conditionMet()) { - if (game.getTurn().getStepType() == Constants.PhaseStep.UNTAP && event.getType() == GameEvent.EventType.UNTAP) { - if (event.getTargetId().equals(targetPointer.getFirst(source))) { - return true; - } + if (event.getType() == GameEvent.EventType.LOST_CONTROL) { + if (event.getPlayerId().equals(source.getControllerId()) && event.getTargetId().equals(source.getSourceId())) { + this.used = true; + return false; } } - return false; + if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId())) { + ZoneChangeEvent zEvent = (ZoneChangeEvent)event; + if (zEvent.getFromZone() == Zone.BATTLEFIELD) { + this.used = true; + return false; + } + } + + + if (game.getTurn().getStepType() == Constants.PhaseStep.UNTAP && event.getType() == GameEvent.EventType.UNTAP) { + if (event.getTargetId().equals(targetPointer.getFirst(source))) { + return true; + } + } + + return false; } } @@ -148,13 +159,16 @@ class DungeonGeistsWatcher extends WatcherImpl { public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.LOST_CONTROL && event.getPlayerId().equals(controllerId) && event.getTargetId().equals(sourceId)) { condition = true; + game.replaceEvent(event); return; } if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(sourceId)) { ZoneChangeEvent zEvent = (ZoneChangeEvent)event; if (zEvent.getFromZone() == Zone.BATTLEFIELD) { - condition = false; - } + condition = true; + game.replaceEvent(event); + return; + } } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/DungeonGeistsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/DungeonGeistsTest.java index fac278cfad..fa9241e4e4 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/DungeonGeistsTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/DungeonGeistsTest.java @@ -69,4 +69,31 @@ public class DungeonGeistsTest extends CardTestPlayerBase { assertTapped("Craw Wurm", true); } + @Test + public void testWithBlink() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 4); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Plains", 4); + addCard(Constants.Zone.HAND, playerA, "Dungeon Geists"); + addCard(Constants.Zone.HAND, playerA, "Cloudshift"); + addCard(Constants.Zone.BATTLEFIELD, playerB, "Craw Wurm"); + addCard(Constants.Zone.BATTLEFIELD, playerB, "Elite Vanguard"); + + addTarget(playerA, "Craw Wurm"); // first target Craw Wurm + addTarget(playerA, "Elite Vanguard"); // after Cloudshift effect (return back to battlefield) target Elite Vanguard + + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Dungeon Geists"); + castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Cloudshift", "Dungeon Geists"); + setStopAt(2, Constants.PhaseStep.DRAW); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + assertPermanentCount(playerA, "Dungeon Geists", 1); + assertPermanentCount(playerB, "Craw Wurm", 1); + assertPermanentCount(playerB, "Elite Vanguard", 1); + assertTapped("Dungeon Geists", false); + assertTapped("Elite Vanguard", true); + assertTapped("Craw Wurm", false); + } + }