From 7a1245e2fec2dc0d8b6d93c32303df1241f85277 Mon Sep 17 00:00:00 2001 From: LevelX2 <ludwig.hirth@online.de> Date: Mon, 31 Jul 2017 20:42:32 +0200 Subject: [PATCH] Fixed a problem of DiesTriggeredAbility that produced null pointer exception. --- .../common/DiesTriggeredAbility.java | 2 +- .../BoostAllOfChosenSubtypeEffect.java | 114 +++++++++--------- 2 files changed, 60 insertions(+), 56 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/common/DiesTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DiesTriggeredAbility.java index 6496e8ade8..d7f880ce11 100644 --- a/Mage/src/main/java/mage/abilities/common/DiesTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DiesTriggeredAbility.java @@ -64,7 +64,7 @@ public class DiesTriggeredAbility extends ZoneChangeTriggeredAbility { return false; } // check now it is in graveyard - if (before.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(source.getId())) { + if (before.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(sourceId)) { Zone after = game.getState().getZone(sourceId); return after != null && Zone.GRAVEYARD.match(after); } else { diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostAllOfChosenSubtypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostAllOfChosenSubtypeEffect.java index 08223c5779..5420bd0cf5 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostAllOfChosenSubtypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostAllOfChosenSubtypeEffect.java @@ -1,55 +1,59 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package mage.abilities.effects.common.continuous; - -import mage.abilities.Ability; -import mage.constants.Duration; -import mage.constants.SubType; -import mage.filter.common.FilterCreaturePermanent; -import mage.game.Game; -import mage.game.permanent.Permanent; - -/** - * - * @author LevelX2 - */ -public class BoostAllOfChosenSubtypeEffect extends BoostAllEffect { - - SubType subtype = null; - - public BoostAllOfChosenSubtypeEffect(int power, int toughness, Duration duration, boolean excludeSource) { - super(power, toughness, duration, new FilterCreaturePermanent("All creatures of the chosen type"), excludeSource); - } - - public BoostAllOfChosenSubtypeEffect(int power, int toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) { - super(power, toughness, duration, filter, excludeSource); - } - - public BoostAllOfChosenSubtypeEffect(final BoostAllOfChosenSubtypeEffect effect) { - super(effect); - this.subtype = effect.subtype; - } - - @Override - public BoostAllOfChosenSubtypeEffect copy() { - return new BoostAllOfChosenSubtypeEffect(this); - } - - @Override - protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) { - if (subtype != null) { - return permanent.hasSubtype(subtype, game); - } - return false; - } - - @Override - protected void setRuntimeData(Ability source, Game game) { - String s = (String) game.getState().getValue(source.getSourceId() + "_type"); - subtype = SubType.byDescription(s); - } - -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.abilities.effects.common.continuous; + +import mage.abilities.Ability; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.filter.common.FilterCreaturePermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author LevelX2 + */ +public class BoostAllOfChosenSubtypeEffect extends BoostAllEffect { + + SubType subtype = null; + + public BoostAllOfChosenSubtypeEffect(int power, int toughness, Duration duration, boolean excludeSource) { + super(power, toughness, duration, new FilterCreaturePermanent("All creatures of the chosen type"), excludeSource); + } + + public BoostAllOfChosenSubtypeEffect(int power, int toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) { + super(power, toughness, duration, filter, excludeSource); + } + + public BoostAllOfChosenSubtypeEffect(final BoostAllOfChosenSubtypeEffect effect) { + super(effect); + this.subtype = effect.subtype; + } + + @Override + public BoostAllOfChosenSubtypeEffect copy() { + return new BoostAllOfChosenSubtypeEffect(this); + } + + @Override + protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) { + if (subtype != null) { + return permanent.hasSubtype(subtype, game); + } + return false; + } + + @Override + protected void setRuntimeData(Ability source, Game game) { + String s = (String) game.getState().getValue(source.getSourceId() + "_type"); + if (subtype != null) { + subtype = SubType.byDescription(s); + } else { + discard(); + } + } + +}