diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/leagueAdmin.html b/gemp-lotr/gemp-lotr-async/src/main/web/leagueAdmin.html
index c6df83a44..d3836f1a1 100644
--- a/gemp-lotr/gemp-lotr-async/src/main/web/leagueAdmin.html
+++ b/gemp-lotr/gemp-lotr-async/src/main/web/leagueAdmin.html
@@ -204,6 +204,8 @@
Format:
Series duration in days:
diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/draft2/builder/StartingPoolBuilder.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/draft2/builder/StartingPoolBuilder.java
index 814586d64..af0691e94 100644
--- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/draft2/builder/StartingPoolBuilder.java
+++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/draft2/builder/StartingPoolBuilder.java
@@ -2,21 +2,21 @@ package com.gempukku.lotro.draft2.builder;
import com.gempukku.lotro.game.CardCollection;
import com.gempukku.lotro.game.DefaultCardCollection;
+import com.google.common.collect.Iterators;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Random;
+import java.util.*;
public class StartingPoolBuilder {
public CardCollectionProducer buildCardCollectionProducer(JSONObject startingPool) {
String cardCollectionProducerType = (String) startingPool.get("type");
if (cardCollectionProducerType.equals("randomCardPool")) {
return buildRandomCardPool((JSONObject) startingPool.get("data"));
+ } else if (cardCollectionProducerType.equals("boosterDraftRun")) {
+ return buildBoosterDraftRun((JSONObject) startingPool.get("data"));
}
- throw new RuntimeException("Unknown cardCollectionProducer type: "+cardCollectionProducerType);
+ throw new RuntimeException("Unknown cardCollectionProducer type: " + cardCollectionProducerType);
}
private CardCollectionProducer buildRandomCardPool(JSONObject randomCardPool) {
@@ -43,4 +43,57 @@ public class StartingPoolBuilder {
}
};
}
+
+ private CardCollectionProducer buildBoosterDraftRun(JSONObject boosterDraftRun) {
+ final int runLengthInput = ((Number) boosterDraftRun.get("runLength")).intValue();
+ final JSONArray coreCards = (JSONArray) boosterDraftRun.get("coreCards");
+ final JSONArray freePeoplesRuns = (JSONArray) boosterDraftRun.get("freePeoplesRuns");
+ final JSONArray shadowRuns = (JSONArray) boosterDraftRun.get("shadowRuns");
+
+ return new CardCollectionProducer() {
+ @Override
+ public CardCollection getCardCollection(long seed) {
+ Random rnd = new Random(seed);
+ List freePeoplesRun = ((List>) freePeoplesRuns).get(rnd.nextInt(freePeoplesRuns.size()));
+ List shadowRun = ((List>) shadowRuns).get(rnd.nextInt(shadowRuns.size()));
+
+ int freePeopleLength = freePeoplesRun.size();
+ int shadowLength = shadowRun.size();
+
+ int runLength;
+ if (freePeopleLength > 0 && shadowLength > 0) {
+ runLength = Math.min(runLengthInput, Math.min(freePeopleLength, shadowLength));
+ } else if (freePeopleLength > 0) {
+ runLength = Math.min(runLengthInput, freePeopleLength);
+ } else {
+ runLength = Math.min(runLengthInput, shadowLength);
+ }
+
+ int freePeopleStart = rnd.nextInt(freePeopleLength);
+ int shadowStart = rnd.nextInt(shadowLength);
+
+ Iterator freePeopleIterator = getCyclingIterator(freePeoplesRun, freePeopleStart, runLength);
+ Iterator shadowIterator = getCyclingIterator(shadowRun, shadowStart, runLength);
+
+ final DefaultCardCollection draftCollection = new DefaultCardCollection();
+
+ for (String coreCard : (List) coreCards) {
+ draftCollection.addItem(coreCard, 1);
+ }
+ while (freePeopleIterator.hasNext()) {
+ draftCollection.addItem(freePeopleIterator.next(), 1);
+ }
+ while (shadowIterator.hasNext()) {
+ draftCollection.addItem(shadowIterator.next(), 1);
+ }
+ return draftCollection;
+ }
+ };
+ }
+
+ private static Iterator getCyclingIterator(List list, int start, int length) {
+ Iterator cycleListIterator = Iterators.cycle(list);
+ Iterators.skip(cycleListIterator, start);
+ return Iterators.limit(cycleListIterator, length);
+ }
}
diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/draft2/builder/startingPoolBuilder2.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/draft2/builder/startingPoolBuilder2.java
deleted file mode 100644
index e658f5474..000000000
--- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/draft2/builder/startingPoolBuilder2.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package com.gempukku.lotro.draft2.builder;
-
-import com.gempukku.lotro.game.CardCollection;
-import com.gempukku.lotro.game.DefaultCardCollection;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Random;
-
-public class StartingPoolBuilder {
- public CardCollectionProducer buildCardCollectionProducer(JSONObject startingPool) {
- String cardCollectionProducerType = (String) startingPool.get("type");
- if (cardCollectionProducerType.equals("randomCardPool")) {
- return buildRandomCardPool((JSONObject) startingPool.get("data"));
- } else if (cardCollectionProducerType.equals("boosterDraftRun")) {
- return buildBoosterDraftRun((JSONObject) startingPool.get("data"));
- }
- throw new RuntimeException("Unknown cardCollectionProducer type: "+cardCollectionProducerType);
- }
-
- private CardCollectionProducer buildRandomCardPool(JSONObject randomCardPool) {
- JSONArray cardPools = (JSONArray) randomCardPool.get("randomResult");
-
- final List cardCollections = new ArrayList();
- Iterator iterator = cardPools.iterator();
- while (iterator.hasNext()) {
- JSONArray cards = iterator.next();
-
- DefaultCardCollection cardCollection = new DefaultCardCollection();
- Iterator cardIterator = cards.iterator();
- while (cardIterator.hasNext()) {
- cardCollection.addItem(cardIterator.next(), 1);
- }
- cardCollections.add(cardCollection);
- }
-
- return new CardCollectionProducer() {
- @Override
- public CardCollection getCardCollection(long seed) {
- Random rnd = new Random(seed);
- return cardCollections.get(rnd.nextInt(cardCollections.size()));
- }
- };
- }
-
- private CardCollectionProducer buildBoosterDraftRun(JSONObject boosterDraftRun) {
- final int runLengthInput = ((Number) boosterDraftRun.get("runLength")).intValue();
- final JSONArray coreCards = (JSONArray) boosterDraftRun.get("coreCards");
- JSONArray freePeoplesRuns = (JSONArray) boosterDraftRun.get("freePeoplesRuns");
- JSONArray shadowRuns = (JSONArray) boosterDraftRun.get("shadowRuns");
-
- final List> freePeoplesRunList = new ArrayList>();
- Iterator freePeoplesIterator = freePeoplesRuns.iterator();
- while (freePeoplesIterator.hasNext()) {
- JSONArray cards = freePeoplesIterator.next();
-
- List orderedCards = new ArrayList();
- Iterator cardIterator = cards.iterator();
- while (cardIterator.hasNext()) {
- orderedCards.add(cardIterator.next());
- }
- freePeoplesRunList.add(orderedCards);
- }
-
- final List> shadowRunList = new ArrayList>();
- Iterator shadowIterator = shadowRuns.iterator();
- while (shadowIterator.hasNext()) {
- JSONArray cards = shadowIterator.next();
-
- List orderedCards = new ArrayList();
- Iterator cardIterator = cards.iterator();
- while (cardIterator.hasNext()) {
- orderedCards.add(cardIterator.next());
- }
- shadowRunList.add(orderedCards);
- }
-
- return new CardCollectionProducer() {
- @Override
- public CardCollection getCardCollection(long seed) {
- Random rnd = new Random(seed);
- List freePeoplesRun = freePeoplesRunList.get(rnd.nextInt(freePeoplesRunList.size()));
- List shadowRun = shadowRunList.get(rnd.nextInt(shadowRunList.size()));
- int runLength = 0;
- if (freePeoplesRun.size() > 0 && shadowRun.size() > 0) {
- runLength = Math.min(runLengthInput, Math.min(freePeoplesRun.size(), shadowRun.size()));
- } else if (freePeoplesRun.size() > 0) {
- runLength = Math.min(runLengthInput, freePeoplesRun.size());
- } else {
- runLength = Math.min(runLengthInput, shadowRun.size());
- }
- String[] draftRun = new String[runLength];
- if (freePeoplesRun.size() > 0) {
- int runSeed = rnd.nextInt() % freePeoplesRun.size();
- if (runSeed + runLength > freePeoplesRun.size()) {
- int runFromStart = runSeed + runLength - freePeoplesRun.size();
- int runAtEnd = runLength - runFromStart;
- for (int i = 0; i < runAtEnd; i++) {
- draftRun[i] = freePeoplesRun.get(runSeed+i);
- }
- for (int i = 0; i < runFromStart; i++) {
- draftRun[runAtEnd + i] = freePeoplesRun.get(i);
- }
- } else {
- for (int i = 0; i < runLength; i++) {
- draftRun[i] = freePeoplesRun.get(runSeed+i);
- }
- }
- }
- if (shadowRun.size() > 0) {
- int runSeed = rnd.nextInt() % shadowRun.size();
- if (runSeed + runLength > shadowRun.size()) {
- int runFromStart = runSeed + runLength - shadowRun.size();
- int runAtEnd = runLength - runFromStart;
- for (int i = 0; i < runAtEnd; i++) {
- draftRun[i] = shadowRun.get(runSeed+i);
- }
- for (int i = 0; i < runFromStart; i++) {
- draftRun[runAtEnd + i] = shadowRun.get(i);
- }
- } else {
- for (int i = 0; i < runLength; i++) {
- draftRun[i] = shadowRun.get(runSeed+i);
- }
- }
- }
-
- final DefaultCardCollection draftCollection = new DefaultCardCollection();
- Iterator iterator = coreCards.iterator();
- while (iterator.hasNext()) {
- draftCollection.addItem(iterator.next(), 1);
- }
- for (int i = 0; i < draftRun.length; i++) {
- draftCollection.addItem(draftRun[i], 1);
- }
- return draftCollection;
- }
- };
- }
-}
\ No newline at end of file
diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/formats/LotroFormatLibrary.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/formats/LotroFormatLibrary.java
index c060c8dc6..0434e1b93 100644
--- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/formats/LotroFormatLibrary.java
+++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/formats/LotroFormatLibrary.java
@@ -46,8 +46,12 @@ public class LotroFormatLibrary {
Boolean winOnControlling5Sites = (Boolean) formatDef.get("winOnControlling5Sites");
if (winOnControlling5Sites == null)
winOnControlling5Sites = false;
+ Boolean limited = (Boolean) formatDef.get("limited");
+ if (limited == null)
+ limited = false;
- final DefaultLotroFormat format = new DefaultLotroFormat(adventure, library, name, surveyUrl, block, true, 60, 4, true,
+ int maximumSameName = limited ? 20 : 4;
+ final DefaultLotroFormat format = new DefaultLotroFormat(adventure, library, name, surveyUrl, block, true, 60, maximumSameName, true,
cancelRingBearerSkirmish, hasRuleOfFour, winAtEndOfRegroup, winOnControlling5Sites);
JSONArray sets = (JSONArray) formatDef.get("set");
diff --git a/gemp-lotr/gemp-lotr-server/src/main/resources/lotrFormats.json b/gemp-lotr/gemp-lotr-server/src/main/resources/lotrFormats.json
index 8e2884b99..a308046c3 100644
--- a/gemp-lotr/gemp-lotr-server/src/main/resources/lotrFormats.json
+++ b/gemp-lotr/gemp-lotr-server/src/main/resources/lotrFormats.json
@@ -245,6 +245,7 @@
"code":"limited_fotr",
"sites":"FELLOWSHIP",
"cancelRingBearerSkirmish":true,
+ "limited":true,
"set":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
"hall":false
},
@@ -253,6 +254,7 @@
"code":"limited_ttt",
"sites":"TWO_TOWERS",
"cancelRingBearerSkirmish":true,
+ "limited":true,
"set":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
"hall":false
},
@@ -261,6 +263,7 @@
"code":"limited_king",
"sites":"KING",
"cancelRingBearerSkirmish":true,
+ "limited":true,
"set":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
"hall":false
},
@@ -269,6 +272,7 @@
"code":"limited_shadows",
"sites":"SHADOWS",
"cancelRingBearerSkirmish":false,
+ "limited":true,
"set":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
"hall":false
},
@@ -345,6 +349,7 @@
"code":"limited_hobbit",
"sites":"HOBBIT",
"cancelRingBearerSkirmish":true,
+ "limited":true,
"set":[30, 31],
"hall":false
}