Fixed deck generation performance issue

This commit is contained in:
austinio7116
2018-04-20 18:23:59 +01:00
committed by maustin
parent 7df721a863
commit 51bf8a5286

View File

@@ -529,9 +529,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
if (secondKeyCard != null) { if (secondKeyCard != null) {
possibleList.removeAll(StaticData.instance().getCommonCards().getAllCards(secondKeyCard.getName())); possibleList.removeAll(StaticData.instance().getCommonCards().getAllCards(secondKeyCard.getName()));
} }
List<PaperCard> randomPool = CardRanker.rankCardsInDeck(possibleList).subList(0,new Float(possibleList.size()*0.25).intValue()); Iterator<PaperCard> iRandomPool=possibleList.iterator();
Collections.shuffle(randomPool, MyRandom.getRandom());
Iterator<PaperCard> iRandomPool=randomPool.iterator();
while (deckList.size() < targetSize) { while (deckList.size() < targetSize) {
if (logToConsole) { if (logToConsole) {
System.out.println("WARNING: Fixing deck size, currently " + deckList.size() + " cards."); System.out.println("WARNING: Fixing deck size, currently " + deckList.size() + " cards.");
@@ -766,11 +764,8 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
if (secondKeyCard != null) { if (secondKeyCard != null) {
possibleList.removeAll(StaticData.instance().getCommonCards().getAllCards(secondKeyCard.getName())); possibleList.removeAll(StaticData.instance().getCommonCards().getAllCards(secondKeyCard.getName()));
} }
//reduce pool to more powerful cards to use as filler Collections.shuffle(possibleList);
int poolSize = new Float(possibleList.size()*0.25).intValue(); Iterator<PaperCard> iRandomPool=possibleList.iterator();
List<PaperCard> randomPool = CardRanker.rankCardsInDeck(possibleList).subList(0,poolSize);
Collections.shuffle(randomPool);
Iterator<PaperCard> iRandomPool=randomPool.iterator();
for(int i=0;i<num;++i){ for(int i=0;i<num;++i){
PaperCard randomCard=iRandomPool.next(); PaperCard randomCard=iRandomPool.next();
deckList.add(randomCard); deckList.add(randomCard);