Enhanced deck generator: monocolor decks, card pool 3 times bigger, bonus for multicolored cards, no duplicate cards.

This commit is contained in:
magenoxx 2011-05-20 16:40:16 +04:00
parent 1eb65e8d13
commit 935bf45c57
3 changed files with 33 additions and 19 deletions

View file

@ -39,8 +39,13 @@ public class DeckBuilder {
deck = new Deck();
final Collection<MageScoredCard> remainingCards = new ArrayList<MageScoredCard>();
Set<String> names = new HashSet<String>();
for (final Card card : spellCardPool) {
if (names.contains(card.getName())) {
continue;
}
remainingCards.add(new MageScoredCard(card, allowedColors, callback));
names.add(card.getName());
}
int min = 0;
for (int index = 0; index < DECK_COUNT.length; index++) {
@ -228,6 +233,8 @@ public class DeckBuilder {
int converted = card.getManaCost().convertedManaCost();
final Map<String, Integer> singleCount = new HashMap<String, Integer>();
int maxSingleCount = 0;
int multicolor = 0;
Set<String> colors = new HashSet<String>();
for (String symbol : card.getManaCost().getSymbols()) {
int count = 0;
symbol = symbol.replace("{", "").replace("}", "");
@ -240,6 +247,9 @@ public class DeckBuilder {
if (count == 0) {
return -30;
}
if (!colors.contains(symbol)) {
multicolor += 1;
}
Integer typeCount = singleCount.get(symbol);
if (typeCount == null) {
typeCount = new Integer(0);
@ -249,8 +259,9 @@ public class DeckBuilder {
maxSingleCount = Math.max(maxSingleCount, typeCount);
}
}
int multicolorBonus = multicolor > 1 ? 30 : 0;
maxSingleCount = Math.min(maxSingleCount, SINGLE_PENALTY.length - 1);
return 2 * converted + 3 * (10 - SINGLE_PENALTY[maxSingleCount]/*-DOUBLE_PENALTY[doubleCount]*/);
return 2 * converted + 3 * (10 - SINGLE_PENALTY[maxSingleCount]/*-DOUBLE_PENALTY[doubleCount]*/) + multicolorBonus;
}
public int getScore() {