diff --git a/Mage/src/mage/abilities/effects/common/PreventDamageByTargetEffect.java b/Mage/src/mage/abilities/effects/common/PreventDamageByTargetEffect.java index 8f8547b7cf..7552f393ea 100644 --- a/Mage/src/mage/abilities/effects/common/PreventDamageByTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/PreventDamageByTargetEffect.java @@ -68,6 +68,9 @@ public class PreventDamageByTargetEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (!this.used && super.applies(event, source, game)) { + if (!game.getState().getStack().isEmpty()) { + + } return this.getTargetPointer().getTargets(game, source).contains(event.getSourceId()); } return false; diff --git a/Mage/src/mage/target/TargetImpl.java b/Mage/src/mage/target/TargetImpl.java index 785a8aa538..8c32a57a89 100644 --- a/Mage/src/mage/target/TargetImpl.java +++ b/Mage/src/mage/target/TargetImpl.java @@ -83,6 +83,7 @@ public abstract class TargetImpl implements Target { this.targets.putAll(target.targets); this.zoneChangeCounters.putAll(target.zoneChangeCounters); this.atRandom = target.atRandom; + this.notTarget = target.notTarget; } @Override @@ -228,7 +229,7 @@ public abstract class TargetImpl implements Target { if (maxNumberOfTargets == 0 || targets.size() < maxNumberOfTargets) { if (!targets.containsKey(id)) { if (source != null) { - if (!game.replaceEvent(GameEvent.getEvent(EventType.TARGET, id, source.getSourceId(), source.getControllerId()))) { + if (!skipEvent && !game.replaceEvent(GameEvent.getEvent(EventType.TARGET, id, source.getSourceId(), source.getControllerId()))) { targets.put(id, 0); rememberZoneChangeCounter(id, game); chosen = targets.size() >= minNumberOfTargets; @@ -267,7 +268,7 @@ public abstract class TargetImpl implements Target { amount += targets.get(id); } if (source != null) { - if (!game.replaceEvent(GameEvent.getEvent(EventType.TARGET, id, source.getId(), source.getControllerId()))) { + if (!skipEvent && !game.replaceEvent(GameEvent.getEvent(EventType.TARGET, id, source.getId(), source.getControllerId()))) { targets.put(id, amount); rememberZoneChangeCounter(id, game); chosen = targets.size() >= minNumberOfTargets; @@ -337,7 +338,7 @@ public abstract class TargetImpl implements Target { continue; // it's not legal so continue to have a look at other targeted objects } } - if (game.replaceEvent(GameEvent.getEvent(EventType.TARGET, targetId, source.getId(), source.getControllerId()))) { + if (!notTarget && game.replaceEvent(GameEvent.getEvent(EventType.TARGET, targetId, source.getId(), source.getControllerId()))) { replacedTargets++; continue; } diff --git a/Mage/src/mage/target/TargetSource.java b/Mage/src/mage/target/TargetSource.java index d33b526ede..53cee0231b 100644 --- a/Mage/src/mage/target/TargetSource.java +++ b/Mage/src/mage/target/TargetSource.java @@ -63,17 +63,14 @@ public class TargetSource extends TargetObject { } public TargetSource(int minNumTargets, int maxNumTargets, FilterObject filter) { - this.minNumberOfTargets = minNumTargets; - this.maxNumberOfTargets = maxNumTargets; - this.zone = Zone.ALL; + super(minNumTargets, maxNumTargets, Zone.ALL, true); this.filter = filter; - this.targetName = filter.getMessage(); + this.targetName = filter.getMessage(); } public TargetSource(final TargetSource target) { super(target); this.filter = target.filter.copy(); - setNotTarget(true); } @Override @@ -83,17 +80,21 @@ public class TargetSource extends TargetObject { @Override public void add(UUID id, Game game) { + addTarget(id, null, game); + } + + @Override + public void addTarget(UUID id, Ability source, Game game) { if (targets.size() < maxNumberOfTargets) { - if (!targets.containsKey(id)) { - MageObject object = game.getObject(id); - if (object != null && object instanceof StackObject) { - targets.put(((StackObject) object).getSourceId(), 0); - } - else { - targets.put(id, 0); - } + MageObject object = game.getObject(id); + if (object != null && object instanceof StackObject) { + addTarget(((StackObject) object).getSourceId(), source, game, notTarget); + } + else { + addTarget(id, source, game, notTarget); } } + } @Override