New deck generator part three.
parent
8513395f6a
commit
0a2164020a
|
@ -48,9 +48,11 @@ public class DeckGenerator {
|
|||
final int maxCreatures=(spells*3)/4;
|
||||
final int maxColorless=spells/6;
|
||||
final int maxHigh=spells/6;
|
||||
final int maxOther=(spells-maxHigh)/2;
|
||||
final int maxCost[]=new int[]{maxOther,maxOther+1,maxHigh};
|
||||
int countCreatures=0;
|
||||
int countColorless=0;
|
||||
int countHigh=0;
|
||||
int countCost[]=new int[3];
|
||||
|
||||
// Add spells to deck.
|
||||
while (deck.size()<spells) {
|
||||
|
@ -66,21 +68,19 @@ public class DeckGenerator {
|
|||
if (colorless&&countColorless>=maxColorless) {
|
||||
continue;
|
||||
}
|
||||
final boolean high=cardDefinition.getConvertedCost()>=5;
|
||||
if (high&&countHigh>=maxHigh) {
|
||||
final int bucket=cardDefinition.getCostBucket();
|
||||
if (countCost[bucket]>=maxCost[bucket]) {
|
||||
continue;
|
||||
}
|
||||
deck.add(cardDefinition);
|
||||
spellCards.remove(index);
|
||||
countCost[bucket]++;
|
||||
if (creature) {
|
||||
countCreatures++;
|
||||
}
|
||||
if (colorless) {
|
||||
countColorless++;
|
||||
}
|
||||
if (high) {
|
||||
countHigh++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -320,6 +320,21 @@ public class MagicCardDefinition {
|
|||
return convertedCost;
|
||||
}
|
||||
|
||||
public int getCostBucket() {
|
||||
|
||||
switch (convertedCost) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return 0;
|
||||
case 3:
|
||||
case 4:
|
||||
return 1;
|
||||
default:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasX() {
|
||||
|
||||
return cost.hasX();
|
||||
|
|
Loading…
Reference in New Issue