fix some possible NPEs (when combat = null)

This commit is contained in:
Maxmtg
2013-07-31 06:54:25 +00:00
parent a0d37f7edd
commit 5ff00b2c5c

View File

@@ -180,14 +180,16 @@ public class CombatUtil {
return true; return true;
} }
if (attacker.hasStartOfKeyword("CantBeBlockedByAmount GT") && !combat.getBlockers(attacker).isEmpty()) { if ( combat != null ) {
return false; if (attacker.hasStartOfKeyword("CantBeBlockedByAmount GT") && !combat.getBlockers(attacker).isEmpty()) {
} return false;
}
// Rule 802.4a: A player can block only creatures attacking him or a planeswalker he controls // Rule 802.4a: A player can block only creatures attacking him or a planeswalker he controls
Player attacked = combat.getDefendingPlayerRelatedTo(attacker); Player attacked = combat.getDefendingPlayerRelatedTo(attacker);
if (attacked != null && attacked != defendingPlayer) { if (attacked != null && attacked != defendingPlayer) {
return false; return false;
}
} }
return CombatUtil.canBeBlocked(attacker, defendingPlayer); return CombatUtil.canBeBlocked(attacker, defendingPlayer);
} }
@@ -493,7 +495,7 @@ public class CombatUtil {
*/ */
public static boolean canBlock(final Card attacker, final Card blocker, final Combat combat) { public static boolean canBlock(final Card attacker, final Card blocker, final Combat combat) {
if ((attacker == null) || (blocker == null)) { if (attacker == null || blocker == null) {
return false; return false;
} }