mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
will generate 80 lands out of 20 avaliable in print run correctly
This commit is contained in:
@@ -71,13 +71,22 @@ public class PrintSheet {
|
|||||||
|
|
||||||
public List<CardPrinted> random(int number, boolean wantUnique) {
|
public List<CardPrinted> random(int number, boolean wantUnique) {
|
||||||
List<CardPrinted> result = new ArrayList<CardPrinted>();
|
List<CardPrinted> result = new ArrayList<CardPrinted>();
|
||||||
|
|
||||||
int totalWeight = cardsWithWeights.countAll();
|
int totalWeight = cardsWithWeights.countAll();
|
||||||
if( totalWeight == 0) {
|
if( totalWeight == 0) {
|
||||||
System.err.println("No cards were found on sheet " + name);
|
System.err.println("No cards were found on sheet " + name);
|
||||||
return result;
|
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++) {
|
for(int iC = 0; iC < number; iC++) {
|
||||||
int index = MyRandom.getRandom().nextInt(totalWeight);
|
int index = MyRandom.getRandom().nextInt(totalWeight);
|
||||||
CardPrinted toAdd = fetchRoulette(0, index, wantUnique ? result : null);
|
CardPrinted toAdd = fetchRoulette(0, index, wantUnique ? result : null);
|
||||||
@@ -98,4 +107,5 @@ public class PrintSheet {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user