will generate 80 lands out of 20 avaliable in print run correctly

This commit is contained in:
Maxmtg
2013-04-26 04:25:17 +00:00
parent 5019f4455b
commit d5e6848069

View File

@@ -71,13 +71,22 @@ public class PrintSheet {
public List<CardPrinted> random(int number, boolean wantUnique) {
List<CardPrinted> result = new ArrayList<CardPrinted>();
int totalWeight = cardsWithWeights.countAll();
if( totalWeight == 0) {
System.err.println("No cards were found on sheet " + name);
return result;
}
// If they ask for 40 unique basic lands (to make a fatpack) out of 20 distinct possible, add the whole print run N times.
int uniqueCards = cardsWithWeights.countDistinct();
while ( number >= uniqueCards ) {
for(Entry<CardPrinted, Integer> kv : cardsWithWeights) {
result.add(kv.getKey());
}
number -= uniqueCards;
}
for(int iC = 0; iC < number; iC++) {
int index = MyRandom.getRandom().nextInt(totalWeight);
CardPrinted toAdd = fetchRoulette(0, index, wantUnique ? result : null);
@@ -98,4 +107,5 @@ public class PrintSheet {
}
}