[ZNR] Fix NPE for Yasharn. Closes
@@ -144,16 +144,22 @@ class YasharnImplacableEarthEffect extends ContinuousRuleModifyingEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
- boolean canTargetLand = true;
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
- if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY
- || event.getType() == GameEvent.EventType.CAST_SPELL) {
- if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) {
- if (permanent == null) {
+ if (event.getType() != GameEvent.EventType.ACTIVATE_ABILITY
+ && event.getType() != GameEvent.EventType.CAST_SPELL) {
return false;
}
+
+ if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY || permanent == null) {
+ return false;
}
+
+ boolean canTargetLand = true;
Optional<Ability> ability = game.getAbility(event.getTargetId(), event.getSourceId());
+ if (!ability.isPresent()) {
+ return false;
+ }
+
for (Cost cost : ability.get().getCosts()) {
if (cost instanceof PayLifeCost
|| cost instanceof PayVariableLifeCost) {
@@ -225,7 +231,6 @@ class YasharnImplacableEarthEffect extends ContinuousRuleModifyingEffectImpl {
return !canTargetLand; // must be nonland target
}
}
- }
return false;
}
}
