mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Fixed NPE
This commit is contained in:
parent
fe0557127b
commit
e421e5fac1
5 changed files with 40 additions and 41 deletions
|
@ -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 {
|
||||
|
@ -40,7 +41,7 @@ public final class ArgothianPixies extends CardImpl {
|
|||
new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
|
||||
|
||||
// Prevent all damage that would be dealt to Argothian Pixies by artifact creatures.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
|
||||
new ArgothianPixiesPreventDamageFromArtifactsEffect(Duration.WhileOnBattlefield)));
|
||||
|
||||
}
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
@ -42,26 +42,25 @@ public final class ArgothianTreefolk extends CardImpl {
|
|||
}
|
||||
|
||||
class PreventDamageToSourceByCardTypeEffect extends PreventAllDamageToSourceEffect {
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@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;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.cards.b;
|
||||
|
||||
import mage.MageObject;
|
||||
|
@ -22,14 +21,13 @@ import java.util.Objects;
|
|||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ciaccona007
|
||||
*/
|
||||
public final class BrandOfIllOmen extends CardImpl {
|
||||
|
||||
public BrandOfIllOmen(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}");
|
||||
|
||||
|
||||
this.subtype.add(SubType.AURA);
|
||||
|
||||
// Enchant creature
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,11 +19,10 @@ import mage.game.events.GameEvent;
|
|||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author MarcoMarin
|
||||
*/
|
||||
public final class DesertNomads extends CardImpl {
|
||||
|
||||
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent("desert");
|
||||
|
||||
static {
|
||||
|
@ -31,15 +30,15 @@ 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);
|
||||
this.toughness = new MageInt(2);
|
||||
|
||||
// Desertwalk
|
||||
this.addAbility(new LandwalkAbility(filter));
|
||||
|
||||
this.addAbility(new LandwalkAbility(filter));
|
||||
|
||||
// Prevent all damage that would be dealt to Desert Nomads by Deserts.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventDamageToSourceBySubtypeEffect(SubType.DESERT)));
|
||||
}
|
||||
|
@ -55,22 +54,21 @@ public final class DesertNomads extends CardImpl {
|
|||
}
|
||||
|
||||
class PreventDamageToSourceBySubtypeEffect extends PreventAllDamageToSourceEffect {
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue