From 159e36eabe4b3c357ab33e0751004fdb26c733e2 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 25 Apr 2015 20:49:05 +0200 Subject: [PATCH] * Fixed a bug that attach effects were not stopped during resolution if the object to attach does no longer exist - added fix. --- .../effects/common/AttachEffect.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Mage/src/mage/abilities/effects/common/AttachEffect.java b/Mage/src/mage/abilities/effects/common/AttachEffect.java index a94d9edeadd..4e5c446712a 100644 --- a/Mage/src/mage/abilities/effects/common/AttachEffect.java +++ b/Mage/src/mage/abilities/effects/common/AttachEffect.java @@ -62,16 +62,19 @@ public class AttachEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent sourcePermanent = (Permanent)source.getSourceObjectIfItStillExists(game); + Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null) { - Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); - if (permanent != null) { - return permanent.addAttachment(source.getSourceId(), game); - } - else { - Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); - if (player != null) { - return player.addAttachment(source.getSourceId(), game); + int zcc = game.getState().getZoneChangeCounter(sourcePermanent.getId()); + if (zcc == source.getSourceObjectZoneChangeCounter() || zcc == source.getSourceObjectZoneChangeCounter() + 1) { + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (permanent != null) { + return permanent.addAttachment(source.getSourceId(), game); + } + else { + Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); + if (player != null) { + return player.addAttachment(source.getSourceId(), game); + } } } }