forked from External/mage
Only fire one Targetted event per target
This specifically addresses changing the target of a spell or ability on the stack. Fixes https://github.com/magefree/mage/issues/6158
This commit is contained in:
parent
a8d8f4e621
commit
b6af571779
4 changed files with 22 additions and 50 deletions
|
|
@ -37,6 +37,7 @@ public abstract class TargetImpl implements Target {
|
|||
|
||||
protected int targetTag; // can be set if other target check is needed (AnotherTargetPredicate)
|
||||
protected String chooseHint = null; // UI choose hints after target name
|
||||
protected boolean shouldReportEvents = true;
|
||||
|
||||
@Override
|
||||
public abstract TargetImpl copy();
|
||||
|
|
@ -65,6 +66,7 @@ public abstract class TargetImpl implements Target {
|
|||
this.abilityController = target.abilityController;
|
||||
this.targetTag = target.targetTag;
|
||||
this.chooseHint = target.chooseHint;
|
||||
this.shouldReportEvents = target.shouldReportEvents;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -213,12 +215,12 @@ public abstract class TargetImpl implements Target {
|
|||
//20100423 - 113.3
|
||||
if (getMaxNumberOfTargets() == 0 || targets.size() < getMaxNumberOfTargets()) {
|
||||
if (!targets.containsKey(id)) {
|
||||
if (source != null && !skipEvent) {
|
||||
if (source != null && !skipEvent && shouldReportEvents) {
|
||||
if (!game.replaceEvent(GameEvent.getEvent(EventType.TARGET, id, source.getSourceId(), source.getControllerId()))) {
|
||||
targets.put(id, 0);
|
||||
rememberZoneChangeCounter(id, game);
|
||||
chosen = targets.size() >= getNumberOfTargets();
|
||||
if (!skipEvent) {
|
||||
if (!skipEvent && shouldReportEvents) {
|
||||
game.addSimultaneousEvent(GameEvent.getEvent(EventType.TARGETED, id, source.getSourceId(), source.getControllerId()));
|
||||
}
|
||||
}
|
||||
|
|
@ -251,12 +253,12 @@ public abstract class TargetImpl implements Target {
|
|||
if (targets.containsKey(id)) {
|
||||
amount += targets.get(id);
|
||||
}
|
||||
if (source != null && !skipEvent) {
|
||||
if (source != null && !skipEvent && shouldReportEvents) {
|
||||
if (!game.replaceEvent(GameEvent.getEvent(EventType.TARGET, id, source.getSourceId(), source.getControllerId()))) {
|
||||
targets.put(id, amount);
|
||||
rememberZoneChangeCounter(id, game);
|
||||
chosen = targets.size() >= getNumberOfTargets();
|
||||
if (!skipEvent) {
|
||||
if (!skipEvent && shouldReportEvents) {
|
||||
game.fireEvent(GameEvent.getEvent(EventType.TARGETED, id, source.getSourceId(), source.getControllerId()));
|
||||
}
|
||||
}
|
||||
|
|
@ -551,4 +553,9 @@ public abstract class TargetImpl implements Target {
|
|||
this.chooseHint = chooseHint;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEventReporting(boolean shouldReport) {
|
||||
this.shouldReportEvents = shouldReport;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue