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
|
|
@ -151,6 +151,7 @@ public abstract class StackObjImpl implements StackObject {
|
|||
*/
|
||||
private Target chooseNewTarget(Player targetController, Ability ability, Mode mode, Target target, boolean forceChange, FilterPermanent filterNewTarget, Game game) {
|
||||
Target newTarget = target.copy();
|
||||
newTarget.setEventReporting(false);
|
||||
if (!targetController.getId().equals(getControllerId())) {
|
||||
newTarget.setTargetController(targetController.getId()); // target controller for the change is different from spell controller
|
||||
newTarget.setAbilityController(getControllerId());
|
||||
|
|
@ -199,6 +200,7 @@ public abstract class StackObjImpl implements StackObject {
|
|||
} else {
|
||||
// build a target definition with exactly one possible target to select that replaces old target
|
||||
Target tempTarget = target.copy();
|
||||
tempTarget.setEventReporting(false);
|
||||
if (target instanceof TargetAmount) {
|
||||
((TargetAmount) tempTarget).setAmountDefinition(StaticValue.get(target.getTargetAmount(targetId)));
|
||||
}
|
||||
|
|
@ -215,7 +217,7 @@ public abstract class StackObjImpl implements StackObject {
|
|||
if (!tempTarget.chooseTarget(outcome, getControllerId(), ability, game)) {
|
||||
if (targetController.chooseUse(Outcome.Benefit, "No target object selected. Reset to original target?", ability, game)) {
|
||||
// use previous target no target was selected
|
||||
newTarget.addTarget(targetId, target.getTargetAmount(targetId), ability, game, false);
|
||||
newTarget.addTarget(targetId, target.getTargetAmount(targetId), ability, game, true);
|
||||
} else {
|
||||
again = true;
|
||||
}
|
||||
|
|
@ -225,12 +227,12 @@ public abstract class StackObjImpl implements StackObject {
|
|||
if (targetController.isHuman()) {
|
||||
if (targetController.chooseUse(Outcome.Benefit, "This target was already selected from origin spell. Reset to original target?", ability, game)) {
|
||||
// use previous target no target was selected
|
||||
newTarget.addTarget(targetId, target.getTargetAmount(targetId), ability, game, false);
|
||||
newTarget.addTarget(targetId, target.getTargetAmount(targetId), ability, game, true);
|
||||
} else {
|
||||
again = true;
|
||||
}
|
||||
} else {
|
||||
newTarget.addTarget(targetId, target.getTargetAmount(targetId), ability, game, false);
|
||||
newTarget.addTarget(targetId, target.getTargetAmount(targetId), ability, game, true);
|
||||
}
|
||||
} else if (!target.canTarget(getControllerId(), tempTarget.getFirstTarget(), ability, game)) {
|
||||
if (targetController.isHuman()) {
|
||||
|
|
@ -238,7 +240,7 @@ public abstract class StackObjImpl implements StackObject {
|
|||
again = true;
|
||||
} else {
|
||||
// keep the old
|
||||
newTarget.addTarget(targetId, target.getTargetAmount(targetId), ability, game, false);
|
||||
newTarget.addTarget(targetId, target.getTargetAmount(targetId), ability, game, true);
|
||||
}
|
||||
} else if (newTarget.getFirstTarget() != null && filterNewTarget != null) {
|
||||
Permanent newTargetPermanent = game.getPermanent(newTarget.getFirstTarget());
|
||||
|
|
@ -248,14 +250,14 @@ public abstract class StackObjImpl implements StackObject {
|
|||
}
|
||||
} else {
|
||||
// valid target was selected, add it to the new target definition
|
||||
newTarget.addTarget(tempTarget.getFirstTarget(), target.getTargetAmount(targetId), ability, game, false);
|
||||
newTarget.addTarget(tempTarget.getFirstTarget(), target.getTargetAmount(targetId), ability, game, true);
|
||||
}
|
||||
}
|
||||
} while (again && targetController.canRespond());
|
||||
}
|
||||
} // keep the target
|
||||
else {
|
||||
newTarget.addTarget(targetId, target.getTargetAmount(targetId), ability, game, false);
|
||||
newTarget.addTarget(targetId, target.getTargetAmount(targetId), ability, game, true);
|
||||
}
|
||||
}
|
||||
return newTarget;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue