* Spell Pierce - Fixed bug that caused "java.lang.ClassCastException: mage.filter.predicate.ObjectPlayer cannot be cast to mage.filter.predicate.ObjectSourcePlayer" error.

This commit is contained in:
LevelX2 2014-03-21 17:45:10 +01:00
parent ebd3c4ba89
commit 74285be8a4
2 changed files with 13 additions and 12 deletions

View file

@ -29,14 +29,13 @@
package mage.sets.zendikar;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.CounterUnlessPaysEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.AnotherCardPredicate;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.target.TargetSpell;
@ -46,17 +45,19 @@ import mage.target.TargetSpell;
*/
public class SpellPierce extends CardImpl<SpellPierce> {
private static final FilterSpell filter = new FilterSpell("noncreature spell");
static {
filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE)));
filter.add(new AnotherCardPredicate());
}
public SpellPierce(UUID ownerId) {
super(ownerId, 67, "Spell Pierce", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{U}");
this.expansionSetCode = "ZEN";
this.color.setBlue(true);
// Counter target noncreature spell unless its controller pays .
this.getSpellAbility().addTarget(new TargetSpell(filter));
this.getSpellAbility().addEffect(new CounterUnlessPaysEffect(new GenericManaCost(2)));
}

View file

@ -28,17 +28,16 @@
package mage.target;
import mage.constants.Zone;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -80,7 +79,7 @@ public class TargetSpell extends TargetObject<TargetSpell> {
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
// rule 114.4. A spell or ability on the stack is an illegal target for itself.
if (source != null && source.getId().equals(id)) {
if (source == null || source.getId().equals(id)) {
return false;
}
Spell spell = game.getStack().getSpell(id);
@ -101,8 +100,9 @@ public class TargetSpell extends TargetObject<TargetSpell> {
for (StackObject stackObject: game.getStack()) {
if (canBeChosen(stackObject, sourceControllerId, game)) {
count++;
if (count >= this.minNumberOfTargets)
if (count >= this.minNumberOfTargets) {
return true;
}
}
}
return false;
@ -115,7 +115,7 @@ public class TargetSpell extends TargetObject<TargetSpell> {
@Override
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<UUID>();
Set<UUID> possibleTargets = new HashSet<>();
for (StackObject stackObject: game.getStack()) {
if (canBeChosen(stackObject, sourceControllerId, game)) {
possibleTargets.add(stackObject.getId());