* Abeyance - Fixed possible null pointer exception.

This commit is contained in:
LevelX2 2017-04-18 23:36:06 +02:00
parent a4afdb8d3f
commit e475ad9df7

View file

@ -27,6 +27,8 @@
*/ */
package mage.cards.a; package mage.cards.a;
import java.util.Optional;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
@ -41,9 +43,6 @@ import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import java.util.Optional;
import java.util.UUID;
/** /**
* *
* @author fireshoes * @author fireshoes
@ -51,7 +50,7 @@ import java.util.UUID;
public class Abeyance extends CardImpl { public class Abeyance extends CardImpl {
public Abeyance(UUID ownerId, CardSetInfo setInfo) { public Abeyance(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{W}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}");
// Until end of turn, target player can't cast instant or sorcery spells, and that player can't activate abilities that aren't mana abilities. // Until end of turn, target player can't cast instant or sorcery spells, and that player can't activate abilities that aren't mana abilities.
this.getSpellAbility().addEffect(new AbeyanceEffect()); this.getSpellAbility().addEffect(new AbeyanceEffect());
@ -103,7 +102,7 @@ class AbeyanceEffect extends ContinuousRuleModifyingEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getPlayerId().equals(source.getFirstTarget())) { if (source.getFirstTarget() != null && source.getFirstTarget().equals(event.getPlayerId())) {
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
if (event.getType() == GameEvent.EventType.CAST_SPELL) { if (event.getType() == GameEvent.EventType.CAST_SPELL) {
if (object.isInstant() || object.isSorcery()) { if (object.isInstant() || object.isSorcery()) {