mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Fix for Random booster draft iterates endless while booster generation (#1136)
This commit is contained in:
parent
b029de3ec9
commit
84d2353819
3 changed files with 8 additions and 14 deletions
|
@ -84,7 +84,8 @@ public class DragonsMaze extends ExpansionSet {
|
|||
savedCardsInfos = CardRepository.instance.findCards(criteria);
|
||||
savedCards.put(rarity, savedCardsInfos);
|
||||
}
|
||||
return savedCardsInfos;
|
||||
// Return a copy of the saved cards information, as not to modify the original.
|
||||
return new ArrayList<>(savedCardsInfos);
|
||||
} else {
|
||||
return super.getCardsByRarity(rarity);
|
||||
}
|
||||
|
|
|
@ -81,9 +81,8 @@ public class FateReforged extends ExpansionSet {
|
|||
savedCardsInfos = CardRepository.instance.findCards(criteria);
|
||||
savedCards.put(rarity, savedCardsInfos);
|
||||
}
|
||||
List<CardInfo> cards = new ArrayList<>();
|
||||
cards.addAll(savedCardsInfos);
|
||||
return cards;
|
||||
// Return a copy of the saved cards information, as not to modify the original.
|
||||
return new ArrayList<>(savedCardsInfos);
|
||||
} else {
|
||||
return super.getCardsByRarity(rarity);
|
||||
}
|
||||
|
|
|
@ -117,16 +117,11 @@ public abstract class ExpansionSet implements Serializable {
|
|||
// if the packs are too big, it removes the first cards.
|
||||
// since it adds lands then commons before uncommons
|
||||
// and rares this should be the least disruptive.
|
||||
|
||||
List<Card> theBooster = this.createBooster();
|
||||
List<CardInfo> commons = getCardsByRarity(Rarity.COMMON);
|
||||
int iterations = 0;
|
||||
while (15 > theBooster.size() && !commons.isEmpty()) {
|
||||
|
||||
while (15 > theBooster.size()) {
|
||||
addToBooster(theBooster, commons);
|
||||
iterations++;
|
||||
if (iterations > 14) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (theBooster.size() > 15) {
|
||||
|
@ -301,9 +296,8 @@ public abstract class ExpansionSet implements Serializable {
|
|||
savedCardsInfos = CardRepository.instance.findCards(criteria);
|
||||
savedCards.put(rarity, savedCardsInfos);
|
||||
}
|
||||
List<CardInfo> cards = new ArrayList<>();
|
||||
cards.addAll(savedCardsInfos);
|
||||
return cards;
|
||||
// Return a copy of the saved cards information, as not to modify the original.
|
||||
return new ArrayList<>(savedCardsInfos);
|
||||
}
|
||||
|
||||
public List<CardInfo> getSpecialCommon() {
|
||||
|
|
Loading…
Reference in a new issue