* Canopy Cover - FIxed possible null pointer exception (fixes #2874).

This commit is contained in:
LevelX2 2017-02-17 23:49:03 +01:00
parent e6be0577bb
commit 88eeb2e0e1

View file

@ -59,7 +59,7 @@ public class CanopyCover extends CardImpl {
private static final FilterObject filter = new FilterStackObject("spells or abilities your opponents control"); private static final FilterObject filter = new FilterStackObject("spells or abilities your opponents control");
public CanopyCover(UUID ownerId, CardSetInfo setInfo) { public CanopyCover(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}");
this.subtype.add("Aura"); this.subtype.add("Aura");
// Enchant creature // Enchant creature
@ -70,7 +70,7 @@ public class CanopyCover extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// Enchanted creature can't be blocked except by creatures with flying or reach. (!this is a static ability of the enchantment) // Enchanted creature can't be blocked except by creatures with flying or reach. (!this is a static ability of the enchantment)
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new OrchardSpiritEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CanopyCoverEffect()));
// Enchanted creature can't be the target of spells or abilities your opponents control. // Enchanted creature can't be the target of spells or abilities your opponents control.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeTargetedAttachedEffect(filter, Duration.WhileOnBattlefield, AttachmentType.AURA, TargetController.OPPONENT))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeTargetedAttachedEffect(filter, Duration.WhileOnBattlefield, AttachmentType.AURA, TargetController.OPPONENT)));
@ -86,14 +86,14 @@ public class CanopyCover extends CardImpl {
} }
} }
class OrchardSpiritEffect extends RestrictionEffect { class CanopyCoverEffect extends RestrictionEffect {
public OrchardSpiritEffect() { public CanopyCoverEffect() {
super(Duration.WhileOnBattlefield); super(Duration.WhileOnBattlefield);
staticText = "Enchanted creature can't be blocked except by creatures with flying or reach"; staticText = "Enchanted creature can't be blocked except by creatures with flying or reach";
} }
public OrchardSpiritEffect(final OrchardSpiritEffect effect) { public CanopyCoverEffect(final CanopyCoverEffect effect) {
super(effect); super(effect);
} }
@ -102,7 +102,7 @@ class OrchardSpiritEffect extends RestrictionEffect {
Permanent equipment = game.getPermanent(source.getSourceId()); Permanent equipment = game.getPermanent(source.getSourceId());
if (equipment != null && equipment.getAttachedTo() != null) { if (equipment != null && equipment.getAttachedTo() != null) {
Permanent equipped = game.getPermanent(equipment.getAttachedTo()); Permanent equipped = game.getPermanent(equipment.getAttachedTo());
if (permanent.getId().equals(equipped.getId())) { if (equipped != null && permanent.getId().equals(equipped.getId())) {
return true; return true;
} }
} }
@ -115,7 +115,7 @@ class OrchardSpiritEffect extends RestrictionEffect {
} }
@Override @Override
public OrchardSpiritEffect copy() { public CanopyCoverEffect copy() {
return new OrchardSpiritEffect(this); return new CanopyCoverEffect(this);
} }
} }