- NPE prevention in ControlGainAi.

This commit is contained in:
Agetian
2017-09-13 16:41:10 +00:00
parent 37ebb5731d
commit 452bdd7b4f
2 changed files with 16 additions and 10 deletions

View File

@@ -227,16 +227,18 @@ public class ControlGainAi extends SpellAbilityAi {
t = ComputerUtilCard.getMostExpensivePermanentAI(list, sa, true); t = ComputerUtilCard.getMostExpensivePermanentAI(list, sa, true);
} }
if (t.isCreature()) if (t != null) {
creatures--; if (t.isCreature())
if (t.isPlaneswalker()) creatures--;
planeswalkers--; if (t.isPlaneswalker())
if (t.isLand()) planeswalkers--;
lands--; if (t.isLand())
if (t.isArtifact()) lands--;
artifacts--; if (t.isArtifact())
if (t.isEnchantment()) artifacts--;
enchantments--; if (t.isEnchantment())
enchantments--;
}
if (!sa.canTarget(t)) { if (!sa.canTarget(t)) {
list.remove(t); list.remove(t);

View File

@@ -889,6 +889,10 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
} }
public final boolean canTarget(final GameObject entity) { public final boolean canTarget(final GameObject entity) {
if (entity == null) {
return false;
}
final TargetRestrictions tr = getTargetRestrictions(); final TargetRestrictions tr = getTargetRestrictions();
// Restriction related to this ability // Restriction related to this ability