Fixed NPE in CantCounterSourceEffect (fixed #295).

This commit is contained in:
LevelX2 2013-07-25 00:25:47 +02:00
parent 87f8ac44ee
commit d85070ea4a

View file

@ -29,10 +29,11 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import java.util.UUID; import java.util.UUID;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
@ -70,9 +71,12 @@ public class CantCounterSourceEffect extends ReplacementEffectImpl<CantCounterSo
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.COUNTER) { if (event.getType() == EventType.COUNTER) {
UUID spellId = game.getCard(source.getSourceId()).getSpellAbility().getId(); Card card = game.getCard(source.getSourceId());
if (event.getTargetId().equals(spellId)) { if (card != null) {
return true; UUID spellId = card.getSpellAbility().getId();
if (event.getTargetId().equals(spellId)) {
return true;
}
} }
} }
return false; return false;