* Burrenton Forge-Tender - Fixed that damage prevention did not work for sources that were stack objects. This was a common problem of TargetSource class.

This commit is contained in:
LevelX2 2014-07-24 16:30:58 +02:00
parent 1caaad831e
commit de71d9b194
3 changed files with 21 additions and 16 deletions

View file

@ -68,6 +68,9 @@ public class PreventDamageByTargetEffect extends PreventionEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (!this.used && super.applies(event, source, game)) { if (!this.used && super.applies(event, source, game)) {
if (!game.getState().getStack().isEmpty()) {
}
return this.getTargetPointer().getTargets(game, source).contains(event.getSourceId()); return this.getTargetPointer().getTargets(game, source).contains(event.getSourceId());
} }
return false; return false;

View file

@ -83,6 +83,7 @@ public abstract class TargetImpl implements Target {
this.targets.putAll(target.targets); this.targets.putAll(target.targets);
this.zoneChangeCounters.putAll(target.zoneChangeCounters); this.zoneChangeCounters.putAll(target.zoneChangeCounters);
this.atRandom = target.atRandom; this.atRandom = target.atRandom;
this.notTarget = target.notTarget;
} }
@Override @Override
@ -228,7 +229,7 @@ public abstract class TargetImpl implements Target {
if (maxNumberOfTargets == 0 || targets.size() < maxNumberOfTargets) { if (maxNumberOfTargets == 0 || targets.size() < maxNumberOfTargets) {
if (!targets.containsKey(id)) { if (!targets.containsKey(id)) {
if (source != null) { 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); targets.put(id, 0);
rememberZoneChangeCounter(id, game); rememberZoneChangeCounter(id, game);
chosen = targets.size() >= minNumberOfTargets; chosen = targets.size() >= minNumberOfTargets;
@ -267,7 +268,7 @@ public abstract class TargetImpl implements Target {
amount += targets.get(id); amount += targets.get(id);
} }
if (source != null) { 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); targets.put(id, amount);
rememberZoneChangeCounter(id, game); rememberZoneChangeCounter(id, game);
chosen = targets.size() >= minNumberOfTargets; 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 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++; replacedTargets++;
continue; continue;
} }

View file

@ -63,9 +63,7 @@ public class TargetSource extends TargetObject {
} }
public TargetSource(int minNumTargets, int maxNumTargets, FilterObject filter) { public TargetSource(int minNumTargets, int maxNumTargets, FilterObject filter) {
this.minNumberOfTargets = minNumTargets; super(minNumTargets, maxNumTargets, Zone.ALL, true);
this.maxNumberOfTargets = maxNumTargets;
this.zone = Zone.ALL;
this.filter = filter; this.filter = filter;
this.targetName = filter.getMessage(); this.targetName = filter.getMessage();
} }
@ -73,7 +71,6 @@ public class TargetSource extends TargetObject {
public TargetSource(final TargetSource target) { public TargetSource(final TargetSource target) {
super(target); super(target);
this.filter = target.filter.copy(); this.filter = target.filter.copy();
setNotTarget(true);
} }
@Override @Override
@ -83,17 +80,21 @@ public class TargetSource extends TargetObject {
@Override @Override
public void add(UUID id, Game game) { 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.size() < maxNumberOfTargets) {
if (!targets.containsKey(id)) { MageObject object = game.getObject(id);
MageObject object = game.getObject(id); if (object != null && object instanceof StackObject) {
if (object != null && object instanceof StackObject) { addTarget(((StackObject) object).getSourceId(), source, game, notTarget);
targets.put(((StackObject) object).getSourceId(), 0); }
} else {
else { addTarget(id, source, game, notTarget);
targets.put(id, 0);
}
} }
} }
} }
@Override @Override