From 923e625a2f6c30dbe669b8710e4748071a84d99e Mon Sep 17 00:00:00 2001 From: skiera Date: Thu, 27 Oct 2011 00:50:45 +0000 Subject: [PATCH] Added Singleton format option - if true every card in booster draft is different. Mainly for cube support. --- .../java/forge/card/BoosterGenerator.java | 22 ++++++++++++++++++- .../forge/game/limited/BoosterDraft_1.java | 6 ++++- .../forge/game/limited/CustomLimited.java | 2 ++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main/java/forge/card/BoosterGenerator.java b/src/main/java/forge/card/BoosterGenerator.java index b1508f2f7cc..9bec5d7f9b4 100644 --- a/src/main/java/forge/card/BoosterGenerator.java +++ b/src/main/java/forge/card/BoosterGenerator.java @@ -127,6 +127,10 @@ public class BoosterGenerator { } private List pickRandomCards(final List source, final int count) { + return pickRandomCards(source, count, false); + } + + private List pickRandomCards(final List 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)); - 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 getSingletonBoosterPack( final int nAnyCard) { + List temp = new ArrayList(); + + temp.addAll(pickRandomCards(allButLands, nAnyCard, true)); + + return temp; + } + + /** * So many parameters are needed for custom limited cardpools,. * diff --git a/src/main/java/forge/game/limited/BoosterDraft_1.java b/src/main/java/forge/game/limited/BoosterDraft_1.java index 84330f91ef5..4465c36c054 100644 --- a/src/main/java/forge/game/limited/BoosterDraft_1.java +++ b/src/main/java/forge/game/limited/BoosterDraft_1.java @@ -144,7 +144,11 @@ public final class BoosterDraft_1 implements BoosterDraft { Lambda1, BoosterGenerator> fnPick = new Lambda1, BoosterGenerator>() { @Override public List apply(BoosterGenerator pack) { if ( draft.IgnoreRarity ) { - return pack.getBoosterPack(0, 0, 0, 0, 0, 0, 0, draft.NumCards, 0); + 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); } diff --git a/src/main/java/forge/game/limited/CustomLimited.java b/src/main/java/forge/game/limited/CustomLimited.java index 7269d3791a9..d8ace10cebf 100644 --- a/src/main/java/forge/game/limited/CustomLimited.java +++ b/src/main/java/forge/game/limited/CustomLimited.java @@ -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); }