From 609b5af2febbfb7f3f68b75ce003f5b99840d93f Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 9 Aug 2014 15:27:39 +0200 Subject: [PATCH] Fixed a bug in TargetSpell that allowed a spell to select itself as target (#491). --- Mage/src/mage/target/TargetSpell.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Mage/src/mage/target/TargetSpell.java b/Mage/src/mage/target/TargetSpell.java index 7e87627f9fe..ec8dd9c6435 100644 --- a/Mage/src/mage/target/TargetSpell.java +++ b/Mage/src/mage/target/TargetSpell.java @@ -91,13 +91,12 @@ public class TargetSpell extends TargetObject { @Override public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - return canChoose(sourceControllerId, game); - } - - @Override - public boolean canChoose(UUID sourceControllerId, Game game) { int count = 0; for (StackObject stackObject: game.getStack()) { + // rule 114.4. A spell or ability on the stack is an illegal target for itself. + if (sourceId != null && sourceId.equals(stackObject.getSourceId())) { + continue; + } if (canBeChosen(stackObject, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) { @@ -108,6 +107,11 @@ public class TargetSpell extends TargetObject { return false; } + @Override + public boolean canChoose(UUID sourceControllerId, Game game) { + return canChoose(null, sourceControllerId, game); + } + @Override public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { return possibleTargets(sourceControllerId, game);