mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 02:08:00 +00:00
Fixed deck generation performance issue
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user