}
}
// Add optimal basic lands to deck.
while (deck.getCards().size() < deckSize) {
ColoredManaSymbol bestColor = null;
//Default to a color in the allowed colors
if (allowedColors != null && !allowedColors.isEmpty()) {
bestColor = allowedColors.get(new Random().nextInt(allowedColors.size()));
}
int lowestRatio = Integer.MAX_VALUE;
for (final ColoredManaSymbol color : ColoredManaSymbol.values()) {
final Integer count = colorCount.get(color.toString());
if (count != null && count > 0) {
final int source = colorSource.get(color.toString());
final int ratio;
if (source < MIN_SOURCE) {
ratio = source - count;
} else {
ratio = source * 100 / count;
}
if (ratio < lowestRatio) {
lowestRatio = ratio;
bestColor = color;
}
}
}
final Card landCard = callback.getBestBasicLand(bestColor, setsToUse);
Integer count = colorSource.get(bestColor.toString());
count++;
colorSource.put(bestColor.toString(), count);
deck.getCards().add(landCard);
}
}