From 5cbc4e5703d809801c2d9a4ce6c92671f85e241a Mon Sep 17 00:00:00 2001 From: elcnesh Date: Mon, 9 Jun 2014 20:30:23 +0000 Subject: [PATCH] Fix NPE in AI decision on giving attacking creature protection. --- .../java/forge/ai/AiAttackController.java | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index 0a25b4a5cbc..62f43bbbcda 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -1083,43 +1083,44 @@ public class AiAttackController { if (choices.contains("artifacts")) { artifact = "artifacts"; } - if (!choices.contains(color)) { - color = null; - } - for (Card c : oppList) { - if (!c.isArtifact()) { - artifact = null; - } - switch (color) { - case "black": - if (!c.isBlack()) { - color = null; - } - break; - case "blue": - if (!c.isBlue()) { - color = null; - } - break; - case "green": - if (!c.isGreen()) { - color = null; - } - break; - case "red": - if (!c.isRed()) { - color = null; - } - break; - case "white": - if (!c.isWhite()) { - color = null; - } - break; - } - if (color == null && artifact == null) { - return null; - } + if (choices.contains(color)) { + for (Card c : oppList) { + if (!c.isArtifact()) { + artifact = null; + } + switch (color) { + case "black": + if (!c.isBlack()) { + color = null; + } + break; + case "blue": + if (!c.isBlue()) { + color = null; + } + break; + case "green": + if (!c.isGreen()) { + color = null; + } + break; + case "red": + if (!c.isRed()) { + color = null; + } + break; + case "white": + if (!c.isWhite()) { + color = null; + } + break; + } + if (color == null && artifact == null) { + return null; + } + } + } else { + color = null; } if (color != null) { return color;