Fixed a bug in TargetSpell that allowed a spell to select itself as target (#491).

This commit is contained in:
LevelX2 2014-08-09 15:27:39 +02:00
parent 2ca945fabf
commit 609b5af2fe

View file

@ -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<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
return possibleTargets(sourceControllerId, game);