diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/draft2/SoloDraftDefinitions.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/draft2/SoloDraftDefinitions.java index 35250dfd9..21160d3f5 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/draft2/SoloDraftDefinitions.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/draft2/SoloDraftDefinitions.java @@ -7,6 +7,7 @@ import com.gempukku.lotro.draft2.builder.DraftChoiceBuilder; import com.gempukku.lotro.draft2.builder.StartingPoolBuilder; import com.gempukku.lotro.game.LotroCardBlueprintLibrary; import com.gempukku.lotro.game.formats.LotroFormatLibrary; +import org.apache.log4j.Logger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -17,6 +18,7 @@ import java.io.InputStreamReader; import java.util.*; public class SoloDraftDefinitions { + private static Logger _logger = Logger.getLogger(SoloDraftDefinitions.class); private Map draftTypes = new HashMap(); private StartingPoolBuilder startingPoolBuilder = new StartingPoolBuilder(); private DraftChoiceBuilder draftChoiceBuilder; @@ -66,6 +68,7 @@ public class SoloDraftDefinitions { draftChoiceDefinitions.add(draftChoiceDefinition); } + _logger.debug("Loaded draft definition: "+file); return new DefaultSoloDraft(format, cardCollectionProducer, draftChoiceDefinitions); } catch (ParseException exp) { throw new RuntimeException("Problem loading solo draft " + file, exp); 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 af0691e94..4b9b453ea 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,7 +2,7 @@ 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 com.google.common.collect.Iterables; import org.json.simple.JSONArray; import org.json.simple.JSONObject; @@ -54,8 +54,8 @@ public class StartingPoolBuilder { @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())); + 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(); @@ -72,28 +72,20 @@ public class StartingPoolBuilder { int freePeopleStart = rnd.nextInt(freePeopleLength); int shadowStart = rnd.nextInt(shadowLength); - Iterator freePeopleIterator = getCyclingIterator(freePeoplesRun, freePeopleStart, runLength); - Iterator shadowIterator = getCyclingIterator(shadowRun, shadowStart, runLength); + Iterable freePeopleIterator = getCyclingIterable(freePeoplesRun, freePeopleStart, runLength); + Iterable shadowIterator = getCyclingIterable(shadowRun, shadowStart, runLength); - final DefaultCardCollection draftCollection = new DefaultCardCollection(); + final DefaultCardCollection startingCollection = 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; + for (String card : Iterables.concat((List) coreCards, freePeopleIterator, shadowIterator)) + startingCollection.addItem(card, 1); + + return startingCollection; } }; } - private static Iterator getCyclingIterator(List list, int start, int length) { - Iterator cycleListIterator = Iterators.cycle(list); - Iterators.skip(cycleListIterator, start); - return Iterators.limit(cycleListIterator, length); + private static Iterable getCyclingIterable(List list, int start, int length) { + return Iterables.limit(Iterables.skip(Iterables.cycle(list), start), length); } } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SoloDraftLeagueData.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SoloDraftLeagueData.java index b2ba85434..447e88d0c 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SoloDraftLeagueData.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/SoloDraftLeagueData.java @@ -106,14 +106,14 @@ public class SoloDraftLeagueData implements LeagueData { if (status == 1) { if (currentTime > DateUtils.offsetDate(_serie.getEnd(), 1)) { -// for (PlayerStanding leagueStanding : leagueStandings) { -// CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesTotal, _collectionType); -// if (leaguePrize != null) -// collectionsManager.addItemsToPlayerCollection(true, "End of league prizes", leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll().values()); -// final CardCollection leagueTrophies = _leaguePrizes.getTrophiesForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesTotal, _collectionType); -// if (leagueTrophies != null) -// collectionsManager.addItemsToPlayerCollection(true, "End of league trophies", leagueStanding.getPlayerName(), CollectionType.TROPHY, leagueTrophies.getAll().values()); -// } + for (PlayerStanding leagueStanding : leagueStandings) { + CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesTotal, _collectionType); + if (leaguePrize != null) + collectionsManager.addItemsToPlayerCollection(true, "End of league prizes", leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll().values()); + final CardCollection leagueTrophies = _leaguePrizes.getTrophiesForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesTotal, _collectionType); + if (leagueTrophies != null) + collectionsManager.addItemsToPlayerCollection(true, "End of league trophies", leagueStanding.getPlayerName(), CollectionType.TROPHY, leagueTrophies.getAll().values()); + } status++; } }