mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* 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:
parent
1caaad831e
commit
de71d9b194
3 changed files with 21 additions and 16 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue