- NPE guard.

This commit is contained in:
Agetian
2018-11-29 16:17:33 +03:00
parent 9b99314e51
commit e9bcd254c3

View File

@@ -107,11 +107,13 @@ public class MustBlockAi extends SpellAbilityAi {
if (source.hasKeyword(Keyword.PROVOKE) && blocker.isTapped()) { if (source.hasKeyword(Keyword.PROVOKE) && blocker.isTapped()) {
// Don't provoke if the attack is potentially lethal // Don't provoke if the attack is potentially lethal
Combat combat = ai.getGame().getCombat(); Combat combat = ai.getGame().getCombat();
Player defender = combat.getDefenderPlayerByAttacker(source); if (combat != null) {
if (combat != null && combat.getAttackingPlayer().equals(ai) Player defender = combat.getDefenderPlayerByAttacker(source);
&& defender.canLoseLife() && !defender.cantLoseForZeroOrLessLife() if (defender != null && combat.getAttackingPlayer().equals(ai)
&& ComputerUtilCombat.lifeThatWouldRemain(defender, combat) <= 0) { && defender.canLoseLife() && !defender.cantLoseForZeroOrLessLife()
return false; && ComputerUtilCombat.lifeThatWouldRemain(defender, combat) <= 0) {
return false;
}
} }
} }