Fixed NPE

This commit is contained in:
Oleg Agafonov 2020-02-29 12:49:29 +04:00
parent fe0557127b
commit e421e5fac1
5 changed files with 40 additions and 41 deletions

View file

@ -1,7 +1,7 @@
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -17,8 +17,9 @@ import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.UUID;
/**
*
* @author MarcoMarin
*/
public final class ArgothianPixies extends CardImpl {
@ -74,7 +75,8 @@ class ArgothianPixiesPreventDamageFromArtifactsEffect extends PreventionEffectIm
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (super.applies(event, source, game)) {
if (game.getObject(event.getSourceId()).getCardType().contains(CardType.ARTIFACT)) {
MageObject sourceObject = game.getObject(event.getSourceId());
if (sourceObject != null && sourceObject.getCardType().contains(CardType.ARTIFACT)) {
return (event.getTargetId().equals(source.getSourceId()));
}
}

View file

@ -1,8 +1,7 @@
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.PreventAllDamageToSourceEffect;
@ -15,14 +14,15 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.UUID;
/**
*
* @author MarcoMarin
*/
public final class ArgothianTreefolk extends CardImpl {
public ArgothianTreefolk(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}");
this.subtype.add(SubType.TREEFOLK);
this.power = new MageInt(3);
this.toughness = new MageInt(5);
@ -45,11 +45,11 @@ class PreventDamageToSourceByCardTypeEffect extends PreventAllDamageToSourceEffe
private CardType cardType;
public PreventDamageToSourceByCardTypeEffect(){
public PreventDamageToSourceByCardTypeEffect() {
this(null);
}
public PreventDamageToSourceByCardTypeEffect(CardType cardT){
public PreventDamageToSourceByCardTypeEffect(CardType cardT) {
super(Duration.WhileOnBattlefield);
staticText = "Prevent all damage that would be dealt to {this} by artifact sources";
cardType = cardT;
@ -58,10 +58,9 @@ class PreventDamageToSourceByCardTypeEffect extends PreventAllDamageToSourceEffe
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (super.applies(event, source, game)) {
if (game.getObject(event.getSourceId()).getCardType().contains(cardType)){
if (event.getTargetId().equals(source.getSourceId())) {
return true;
}
MageObject sourceObject = game.getObject(event.getSourceId());
if (sourceObject != null && sourceObject.getCardType().contains(cardType)) {
return event.getTargetId().equals(source.getSourceId());
}
}
return false;

View file

@ -1,4 +1,3 @@
package mage.cards.b;
import mage.MageObject;
@ -22,7 +21,6 @@ import java.util.Objects;
import java.util.UUID;
/**
*
* @author ciaccona007
*/
public final class BrandOfIllOmen extends CardImpl {
@ -95,11 +93,10 @@ class BrandOfIllOmenEffect extends ContinuousRuleModifyingEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent brand = game.getPermanent(source.getSourceId());
if (brand != null && brand.getAttachedTo() != null) {
MageObject sourceObject = game.getObject(event.getSourceId());
if (sourceObject != null && brand != null && brand.getAttachedTo() != null) {
UUID enchantedController = game.getPermanent(brand.getAttachedTo()).getControllerId();
if(Objects.equals(enchantedController, event.getPlayerId()) && game.getObject(event.getSourceId()).isCreature()) {
return true;
}
return Objects.equals(enchantedController, event.getPlayerId()) && sourceObject.isCreature();
}
return false;
}

View file

@ -1,7 +1,7 @@
package mage.cards.d;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.PreventAllDamageToSourceEffect;
@ -19,7 +19,6 @@ import mage.game.events.GameEvent;
import java.util.UUID;
/**
*
* @author MarcoMarin
*/
public final class DesertNomads extends CardImpl {
@ -31,7 +30,7 @@ public final class DesertNomads extends CardImpl {
}
public DesertNomads(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.NOMAD);
this.power = new MageInt(2);
@ -58,7 +57,7 @@ class PreventDamageToSourceBySubtypeEffect extends PreventAllDamageToSourceEffec
private SubType subtype;
public PreventDamageToSourceBySubtypeEffect(SubType sub){
public PreventDamageToSourceBySubtypeEffect(SubType sub) {
super(Duration.WhileOnBattlefield);
subtype = sub;
staticText = "Prevent all damage that would be dealt to {this} by " + subtype.getDescription();
@ -67,10 +66,9 @@ class PreventDamageToSourceBySubtypeEffect extends PreventAllDamageToSourceEffec
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (super.applies(event, source, game)) {
if (game.getObject(event.getSourceId()).hasSubtype(subtype, game)){
if (event.getTargetId().equals(source.getSourceId())) {
return true;
}
MageObject sourceObject = game.getObject(event.getSourceId());
if (sourceObject != null && sourceObject.hasSubtype(subtype, game)) {
return event.getTargetId().equals(source.getSourceId());
}
}
return false;

View file

@ -1,23 +1,24 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.PreventAllDamageToSourceEffect;
import mage.abilities.effects.common.combat.MustBeBlockedByAllSourceEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class MarblePriest extends CardImpl {
@ -66,9 +67,11 @@ class MarblePriestPreventionEffect extends PreventAllDamageToSourceEffect {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
MageObject sourceObject = game.getObject(event.getSourceId());
return super.applies(event, source, game)
&& event.getFlag()
&& game.getObject(event.getSourceId()).hasSubtype(SubType.WALL, game)
&& sourceObject != null
&& sourceObject.hasSubtype(SubType.WALL, game)
&& event.getTargetId().equals(source.getSourceId());
}
}