From 1263607862230140de6716168b97bea7ec9421d1 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 10 Mar 2013 02:31:14 +0100 Subject: [PATCH] Fixed a bug that abilities of creatures weren't applied correct after the creature was controlled by opponent and the controll effect ended. Test for this bug. --- .../MasterOfThePearlTridentTest.java | 32 +++++++++++++++++++ .../mage/game/permanent/PermanentImpl.java | 5 +++ 2 files changed, 37 insertions(+) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/MasterOfThePearlTridentTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/MasterOfThePearlTridentTest.java index e6e7f1248e..f3d618dec2 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/MasterOfThePearlTridentTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/MasterOfThePearlTridentTest.java @@ -110,4 +110,36 @@ public class MasterOfThePearlTridentTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Merfolk of the Pearl Trident", 0); assertPermanentCount(playerB, "Llanowar Elves", 0); } + + /* + * Control of Master changes to player B in turn 2, after + */ + @Test + public void testLooseAndGainControl() { + addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 2); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Master of the Pearl Trident"); + addCard(Constants.Zone.HAND, playerA, "Merfolk of the Pearl Trident"); + + addCard(Constants.Zone.BATTLEFIELD, playerB, "Mountain", 5); + addCard(Constants.Zone.HAND, playerB, "Zealous Conscripts"); + + castSpell(2, Constants.PhaseStep.PRECOMBAT_MAIN, playerB, "Zealous Conscripts"); + + castSpell(3, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Merfolk of the Pearl Trident"); + setStopAt(3, Constants.PhaseStep.POSTCOMBAT_MAIN); + + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + assertPermanentCount(playerA, "Master of the Pearl Trident", 1); + assertPermanentCount(playerA, "Merfolk of the Pearl Trident", 1); + assertPowerToughness(playerA, "Merfolk of the Pearl Trident", 2, 2); + + assertPermanentCount(playerB, "Zealous Conscripts", 1); + + } + + } diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index 537cc5c8d8..b2b7ec5c99 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -486,6 +486,11 @@ public abstract class PermanentImpl> extends CardImpl public void checkControlChanged(Game game) { if (this.controllerChanged) { game.fireEvent(new GameEvent(EventType.LOST_CONTROL, objectId, objectId, beforeResetControllerId)); + // reset the original controller to abilities and ContinuousEffects + if (controllerId.equals(originalControllerId)) { + this.abilities.setControllerId(controllerId); + game.getContinuousEffects().setController(this.objectId, controllerId); + } game.fireEvent(new GameEvent(EventType.GAINED_CONTROL, objectId, objectId, controllerId)); } }