From 5ff00b2c5cebce01a09f4ebbc910147be44036be Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Wed, 31 Jul 2013 06:54:25 +0000 Subject: [PATCH] fix some possible NPEs (when combat = null) --- .../java/forge/game/combat/CombatUtil.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/forge/game/combat/CombatUtil.java b/src/main/java/forge/game/combat/CombatUtil.java index 17be0c7978d..8b1eb4f82eb 100644 --- a/src/main/java/forge/game/combat/CombatUtil.java +++ b/src/main/java/forge/game/combat/CombatUtil.java @@ -180,14 +180,16 @@ public class CombatUtil { return true; } - 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 - Player attacked = combat.getDefendingPlayerRelatedTo(attacker); - if (attacked != null && attacked != defendingPlayer) { - return false; + if ( combat != null ) { + 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 + Player attacked = combat.getDefendingPlayerRelatedTo(attacker); + if (attacked != null && attacked != defendingPlayer) { + return false; + } } 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) { - if ((attacker == null) || (blocker == null)) { + if (attacker == null || blocker == null) { return false; }