diff --git a/Mage/src/mage/abilities/AbilitiesImpl.java b/Mage/src/mage/abilities/AbilitiesImpl.java index b557cc3f97..7a678196c3 100644 --- a/Mage/src/mage/abilities/AbilitiesImpl.java +++ b/Mage/src/mage/abilities/AbilitiesImpl.java @@ -239,7 +239,7 @@ public class AbilitiesImpl extends ArrayList implements Ab @Override public boolean contains(T ability) { for (T test: this) { - if (ability.getId().equals(test.getId()) || ability.getRule().equals(test.getRule())) { + if (ability.getId().equals(test.getId())/* || ability.getRule().equals(test.getRule())*/) { return true; } } diff --git a/Mage/src/mage/abilities/effects/ContinuousEffects.java b/Mage/src/mage/abilities/effects/ContinuousEffects.java index 998e33847f..09e813879a 100644 --- a/Mage/src/mage/abilities/effects/ContinuousEffects.java +++ b/Mage/src/mage/abilities/effects/ContinuousEffects.java @@ -371,6 +371,10 @@ public class ContinuousEffects implements Serializable { for (ContinuousEffect effect: layer) { effect.apply(Layer.CopyEffects_1, SubLayer.NA, layeredEffects.getAbility(effect.getId()), game); } + + //Reload layerEffect + layerEffects = getLayeredEffects(game); + layer = filterLayeredEffects(layerEffects, Layer.ControlChangingEffects_2); for (ContinuousEffect effect: layer) { effect.apply(Layer.ControlChangingEffects_2, SubLayer.NA, layeredEffects.getAbility(effect.getId()), game); @@ -395,6 +399,9 @@ public class ContinuousEffects implements Serializable { } } + //Reload layerEffect + layerEffects = getLayeredEffects(game); + layer = filterLayeredEffects(layerEffects, Layer.PTChangingEffects_7); for (ContinuousEffect effect: layer) { effect.apply(Layer.PTChangingEffects_7, SubLayer.SetPT_7b, layeredEffects.getAbility(effect.getId()), game); diff --git a/Mage/src/mage/abilities/effects/common/CopyEffect.java b/Mage/src/mage/abilities/effects/common/CopyEffect.java index c688b4c45d..3429ed6e8b 100644 --- a/Mage/src/mage/abilities/effects/common/CopyEffect.java +++ b/Mage/src/mage/abilities/effects/common/CopyEffect.java @@ -36,6 +36,7 @@ import mage.game.Game; import mage.game.permanent.Permanent; import java.util.UUID; +import mage.cards.Card; /** * @@ -48,19 +49,36 @@ public class CopyEffect extends ContinuousEffectImpl { */ private MageObject target; private UUID sourceId; + private int zoneChangeCounter; public CopyEffect(Permanent target, UUID sourceId) { - super(Duration.WhileOnBattlefield, Layer.CopyEffects_1, SubLayer.NA, Outcome.BecomeCreature); + super(Duration.Custom, Layer.CopyEffects_1, SubLayer.NA, Outcome.BecomeCreature); this.target = target; this.sourceId = sourceId; + this.zoneChangeCounter = 0; } public CopyEffect(final CopyEffect effect) { super(effect); this.target = effect.target.copy(); this.sourceId = effect.sourceId; + this.zoneChangeCounter = effect.zoneChangeCounter; } + @Override + public void init(Ability source, Game game) { + super.init(source, game); + Permanent permanent = game.getPermanent(this.sourceId); + if(permanent != null) { + Card card = game.getCard(this.sourceId); + if(card != null) + { + this.zoneChangeCounter = card.getZoneChangeCounter(); + } + } + } + + @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(this.sourceId); @@ -115,4 +133,17 @@ public class CopyEffect extends ContinuousEffectImpl { public UUID getSourceId() { return sourceId; } + + @Override + public boolean isInactive(Ability source, Game game) { + Permanent permanent = game.getPermanent(this.sourceId); + if(permanent != null) { + Card card = game.getCard(this.sourceId); + if(card != null) + { + return this.zoneChangeCounter != card.getZoneChangeCounter(); + } + } + return true; + } } diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index f18c422cf9..a7b6333fbb 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -852,7 +852,7 @@ public abstract class GameImpl> implements Game, Serializa if (effect instanceof CopyEffect) { CopyEffect copyEffect = (CopyEffect) effect; // there is another copy effect that our targetPermanent copies stats from - if (copyEffect.getSourceId().equals(copyFromPermanent.getId())) { + if (!copyEffect.isInactive(null, this) && copyEffect.getSourceId().equals(copyFromPermanent.getId())) { MageObject object = ((CopyEffect) effect).getTarget(); if (object instanceof Permanent) { // so we will use original card instead of target @@ -866,7 +866,7 @@ public abstract class GameImpl> implements Game, Serializa } } - state.addEffect(newEffect, newAbility); + state.addEffect(newEffect, copyToPermanent.getId(), newAbility); } @Override