diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/OblivionRingTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/OblivionRingTest.java index 5f3ed2d1d4..258f46376d 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/OblivionRingTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/OblivionRingTest.java @@ -2,7 +2,6 @@ package org.mage.test.cards.triggers; import mage.Constants; import org.junit.Test; -import org.mage.test.serverside.base.CardTestBase; import org.mage.test.serverside.base.CardTestPlayerBase; /** @@ -77,4 +76,27 @@ public class OblivionRingTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Oblivion Ring", 0); assertPermanentCount(playerB, "Craw Wurm", 1); } + + /** + * Tests that when Oblivion Ring gets destroyed planeswalker returns with new counters and can be used second time at the same turn + */ + @Test + public void testExilePlaneswalker() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Plains", 5); + addCard(Constants.Zone.HAND, playerA, "Oblivion Ring"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Jace Beleren"); + addCard(Constants.Zone.HAND, playerA, "Revoke Existence"); + + activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "-1: Target player draws 1 card", playerA); + castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Oblivion Ring"); + castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Revoke Existence", "Oblivion Ring"); + activateAbility(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "-1: Target player draws 1 card", playerA); + + setStopAt(1, Constants.PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, "Oblivion Ring", 0); + assertPermanentCount(playerA, "Jace Beleren", 1); // returns back + assertHandCount(playerA, 2); // can use ability twice + } } diff --git a/Mage/src/mage/abilities/effects/EntersBattlefieldEffect.java b/Mage/src/mage/abilities/effects/EntersBattlefieldEffect.java index 4bfe46e945..a1e1e43793 100644 --- a/Mage/src/mage/abilities/effects/EntersBattlefieldEffect.java +++ b/Mage/src/mage/abilities/effects/EntersBattlefieldEffect.java @@ -69,8 +69,10 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl> extends MageObjectImpl } game.rememberLKI(objectId, event.getFromZone(), this); } + updateZoneChangeCounter(); switch (event.getToZone()) { case GRAVEYARD: game.getPlayer(ownerId).putInGraveyard(this, game, !flag); @@ -276,6 +277,8 @@ public abstract class CardImpl> extends MageObjectImpl case BATTLEFIELD: PermanentCard permanent = new PermanentCard(this, ownerId); game.addPermanent(permanent); + game.setZone(objectId, Zone.BATTLEFIELD); + game.applyEffects(); permanent.entersBattlefield(sourceId, game); game.applyEffects(); if (flag) @@ -287,7 +290,6 @@ public abstract class CardImpl> extends MageObjectImpl return false; } setControllerId(ownerId); - updateZoneChangeCounter(); game.setZone(objectId, event.getToZone()); game.fireEvent(event); return game.getState().getZone(objectId) == toZone;