From 2dba0ca8292a29dcc75949034dd5946d526985d2 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Thu, 30 Jun 2011 15:07:38 +0400 Subject: [PATCH] Fixed Issue 169 --- Mage/src/mage/abilities/Ability.java | 2 +- Mage/src/mage/game/permanent/PermanentImpl.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Mage/src/mage/abilities/Ability.java b/Mage/src/mage/abilities/Ability.java index c77c2fec38f..eecd2a47a4c 100644 --- a/Mage/src/mage/abilities/Ability.java +++ b/Mage/src/mage/abilities/Ability.java @@ -188,7 +188,7 @@ public interface Ability extends Serializable { public Effects getEffects(); /** - * Retrieves the effects of the specified {@link Effecttype type} that are + * Retrieves the effects of the specified {@link EffectType type} that are * put into place by the resolution of this ability. * * @param effectType The {@link EffectType type} to search for. diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index ed36cf137da..3a93512cf77 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -57,6 +57,7 @@ public abstract class PermanentImpl> extends CardImpl protected boolean flipped; protected UUID originalControllerId; protected UUID controllerId; + protected UUID beforeResetControllerId; protected int damage; protected boolean controlledFromStartOfTurn; protected int turnsOnBattlefield; @@ -115,6 +116,7 @@ public abstract class PermanentImpl> extends CardImpl @Override public void reset(Game game) { + this.beforeResetControllerId = this.controllerId; this.controllerId = originalControllerId; this.maxBlocks = 1; } @@ -351,8 +353,14 @@ public abstract class PermanentImpl> extends CardImpl if (!controllerId.equals(this.controllerId)) { Player newController = game.getPlayer(controllerId); if (newController != null && (!newController.hasLeft() || !newController.hasLost())) { - this.removeFromCombat(game); - this.controlledFromStartOfTurn = false; + // changeControllerId can be called by continuous effect + // so it will lead to this.controlledFromStartOfTurn set to false over and over + // because of reset(game) method called before applying effect as state-based action + // that changes this.controllerId to original one (actually owner) + if (controllerId != beforeResetControllerId) { + this.removeFromCombat(game); + this.controlledFromStartOfTurn = false; + } this.controllerId = controllerId; this.abilities.setControllerId(controllerId); return true;