From e3fb596d04a141c9dc04dd7c7c53bde4d890b42f Mon Sep 17 00:00:00 2001 From: Sloth Date: Wed, 14 Dec 2011 10:41:12 +0000 Subject: [PATCH] - Made sure the AI will not miss an on-color card when building draft decks. --- src/main/java/forge/game/limited/BoosterDraftAI.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/forge/game/limited/BoosterDraftAI.java b/src/main/java/forge/game/limited/BoosterDraftAI.java index 27e8b6005e8..2373f1a08de 100644 --- a/src/main/java/forge/game/limited/BoosterDraftAI.java +++ b/src/main/java/forge/game/limited/BoosterDraftAI.java @@ -420,8 +420,12 @@ public class BoosterDraftAI { // 2.Try to fill up to 22 with on-color non-creature cards int ii = 0; - while (cardsNeeded > 0 && others.size() > 1) { - final Card c = others.get(MyRandom.getRandom().nextInt(others.size() - 1)); + while (cardsNeeded > 0 && others.size() > 0) { + int index = 0; + if (others.size() > 1) { + index = MyRandom.getRandom().nextInt(others.size() - 1); + } + final Card c = others.get(index); // out.addMain(c.getName()); outList.add(c);