Added Singleton format option - if true every card in booster draft is different. Mainly for cube support.

This commit is contained in:
skiera
2011-10-27 00:50:45 +00:00
parent 5f31055bcf
commit 923e625a2f
3 changed files with 28 additions and 2 deletions

View File

@@ -127,6 +127,10 @@ public class BoosterGenerator {
}
private List<CardPrinted> pickRandomCards(final List<CardPrinted> source, final int count) {
return pickRandomCards(source, count, false);
}
private List<CardPrinted> pickRandomCards(final List<CardPrinted> source, final int count, boolean singleton) {
int listSize = source == null ? 0 : source.size();
if (count <= 0 || listSize == 0) {
return emptyList;
@@ -140,7 +144,13 @@ public class BoosterGenerator {
index = 0;
}
result.add(source.get(index));
if (!singleton) {
index++;
} else {
source.remove(index);
listSize--;
}
}
return result;
}
@@ -178,6 +188,7 @@ public class BoosterGenerator {
return result;
}
/**
* Gets the booster pack.
*
@@ -187,6 +198,15 @@ public class BoosterGenerator {
return getBoosterPack(numCommons, numUncommons, numRareSlots, 0, 0, numSpecials, numDoubleFaced, 0, 0);
}
public final List<CardPrinted> getSingletonBoosterPack( final int nAnyCard) {
List<CardPrinted> temp = new ArrayList<CardPrinted>();
temp.addAll(pickRandomCards(allButLands, nAnyCard, true));
return temp;
}
/**
* So many parameters are needed for custom limited cardpools,.
*

View File

@@ -144,7 +144,11 @@ public final class BoosterDraft_1 implements BoosterDraft {
Lambda1<List<CardPrinted>, BoosterGenerator> fnPick = new Lambda1<List<CardPrinted>, BoosterGenerator>() {
@Override public List<CardPrinted> apply(BoosterGenerator pack) {
if ( draft.IgnoreRarity ) {
if (!draft.Singleton) {
return pack.getBoosterPack(0, 0, 0, 0, 0, 0, 0, draft.NumCards, 0);
} else {
return pack.getSingletonBoosterPack(draft.NumCards);
}
}
return pack.getBoosterPack(draft.NumCommons, draft.NumUncommons, 0, draft.NumRares, draft.NumMythics, draft.NumSpecials, 0, 0, 0);
}

View File

@@ -15,6 +15,7 @@ class CustomLimited {
public String Type;
public String DeckFile;
public Boolean IgnoreRarity;
public Boolean Singleton = false;
public int NumCards = 15;
public int NumSpecials = 0;
public int NumMythics = 1;
@@ -40,6 +41,7 @@ class CustomLimited {
if (key.equalsIgnoreCase("Type")) { cd.Type = value; }
if (key.equalsIgnoreCase("DeckFile")) { cd.DeckFile = value; }
if (key.equalsIgnoreCase("IgnoreRarity")) { cd.IgnoreRarity = value.equals("True"); }
if (key.equalsIgnoreCase("Singleton")) { cd.Singleton = value.equals("True"); }
if (key.equalsIgnoreCase("LandSetCode")) { cd.LandSetCode = value; }
if (key.equalsIgnoreCase("NumCards")) { cd.NumCards = Integer.parseInt(value); }