Fixed potentional NPE error

This commit is contained in:
Oleg Agafonov 2019-05-03 19:10:17 +04:00
parent c1dea3456c
commit 878d602b58

View file

@ -42,12 +42,14 @@ public class DragonOnTheBattlefieldWhileSpellWasCastWatcher extends Watcher {
// revealed a Dragon card or controlled a Dragon as you cast the spell
if (spell != null) {
boolean revealedOrOnBattlefield = false;
if (spell.getSpellAbility() != null) {
for (Cost cost : spell.getSpellAbility().getCosts()) {
if (cost instanceof RevealTargetFromHandCost) {
revealedOrOnBattlefield = ((RevealTargetFromHandCost) cost).getNumberRevealedCards() > 0;
break;
}
}
}
if (!revealedOrOnBattlefield) {
revealedOrOnBattlefield = game.getBattlefield().countAll(filter, spell.getControllerId(), game) > 0;
}