forked from External/mage
Fixed NPE errors for some cards (#5471)
This commit is contained in:
parent
cbfdcd12c1
commit
8c7df840f3
21 changed files with 136 additions and 186 deletions
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.abilities.effects;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
|
|
@ -19,6 +17,8 @@ import mage.players.Player;
|
|||
import mage.target.Target;
|
||||
import mage.target.common.TargetCardInGraveyard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Cards with the Aura subtype don't change the zone they are in, if there is no
|
||||
* valid target on the battlefield. Also, when entering the battlefield and it
|
||||
|
|
@ -60,6 +60,9 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
Card card = game.getCard(event.getTargetId());
|
||||
UUID sourceId = event.getSourceId();
|
||||
UUID controllerId = event.getPlayerId();
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()) != null) {
|
||||
card = card.getSecondCardFace();
|
||||
|
|
@ -149,7 +152,6 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
Player targetPlayer = game.getPlayer(targetId);
|
||||
if (targetCard != null || targetPermanent != null || targetPlayer != null) {
|
||||
card = game.getCard(event.getTargetId());
|
||||
card.removeFromZone(game, fromZone, sourceId);
|
||||
PermanentCard permanent = new PermanentCard(card, (controllingPlayer == null ? card.getOwnerId() : controllingPlayer.getId()), game);
|
||||
ZoneChangeEvent zoneChangeEvent = new ZoneChangeEvent(permanent, controllerId, fromZone, Zone.BATTLEFIELD);
|
||||
|
|
@ -184,14 +186,12 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD
|
||||
&& (((ZoneChangeEvent) event).getFromZone() != Zone.STACK)) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null && (card.isEnchantment() && card.hasSubtype(SubType.AURA, game)
|
||||
return card != null && (card.isEnchantment() && card.hasSubtype(SubType.AURA, game)
|
||||
|| // in case of transformable enchantments
|
||||
(game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()) != null
|
||||
&& card.getSecondCardFace() != null
|
||||
&& card.getSecondCardFace().isEnchantment()
|
||||
&& card.getSecondCardFace().hasSubtype(SubType.AURA, game)))) {
|
||||
return true;
|
||||
}
|
||||
&& card.getSecondCardFace() != null
|
||||
&& card.getSecondCardFace().isEnchantment()
|
||||
&& card.getSecondCardFace().hasSubtype(SubType.AURA, game)));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue