mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Merge branch 'update-shop-singles-generation' into 'master'
Generate singles in the spell shop by using the pool list instead of boosters See merge request core-developers/forge!3966
This commit is contained in:
@@ -102,6 +102,9 @@ public final class QuestUtilCards {
|
|||||||
if (usedFormat.isSetLegal("CSP")) {
|
if (usedFormat.isSetLegal("CSP")) {
|
||||||
snowLandCodes.add("CSP");
|
snowLandCodes.add("CSP");
|
||||||
}
|
}
|
||||||
|
if (usedFormat.isSetLegal("KHM")) {
|
||||||
|
snowLandCodes.add("KHM");
|
||||||
|
}
|
||||||
|
|
||||||
if (usedFormat.isSetLegal("OGW")) {
|
if (usedFormat.isSetLegal("OGW")) {
|
||||||
wastesCodes.add("OGW");
|
wastesCodes.add("OGW");
|
||||||
@@ -113,6 +116,7 @@ public final class QuestUtilCards {
|
|||||||
}
|
}
|
||||||
snowLandCodes.add("ICE");
|
snowLandCodes.add("ICE");
|
||||||
snowLandCodes.add("CSP");
|
snowLandCodes.add("CSP");
|
||||||
|
snowLandCodes.add("KHM");
|
||||||
wastesCodes.add("OGW");
|
wastesCodes.add("OGW");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,41 +567,19 @@ public final class QuestUtilCards {
|
|||||||
* @param quantity the count
|
* @param quantity the count
|
||||||
*/
|
*/
|
||||||
private void generateSinglesInShop(final int quantity) {
|
private void generateSinglesInShop(final int quantity) {
|
||||||
|
// This is the spot we need to change
|
||||||
if (questController.getFormat() == null) {
|
|
||||||
SealedProduct.Template boosterTemplate = getShopBoosterTemplate();
|
SealedProduct.Template boosterTemplate = getShopBoosterTemplate();
|
||||||
|
if (questController.getFormat() == null) {
|
||||||
for (int i = 0; i < quantity; i++) {
|
for (int i = 0; i < quantity; i++) {
|
||||||
questAssets.getShopList().addAllOfTypeFlat(new UnOpenedProduct(boosterTemplate).get());
|
questAssets.getShopList().addAllOfTypeFlat(new UnOpenedProduct(boosterTemplate).get());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
int commons = questPreferences.getPrefInt(QPref.SHOP_SINGLES_COMMON) * quantity;
|
|
||||||
int uncommons = questPreferences.getPrefInt(QPref.SHOP_SINGLES_UNCOMMON) * quantity;
|
|
||||||
int rareOrMythics = questPreferences.getPrefInt(QPref.SHOP_SINGLES_RARE) * quantity;
|
|
||||||
|
|
||||||
int attempts = commons + uncommons + rareOrMythics + 50;
|
|
||||||
|
|
||||||
List<PaperCard> toAdd = new ArrayList<>();
|
|
||||||
|
|
||||||
do {
|
|
||||||
|
|
||||||
List<PaperCard> cards = ((BoosterPack) BoosterUtils.generateRandomBoosterPacks(1, questController).get(0)).getCards();
|
|
||||||
|
|
||||||
if (commons > 0) {
|
|
||||||
commons = getRandomCardFromBooster(cards, COMMON_PREDICATE, toAdd, commons);
|
|
||||||
} else if (uncommons > 0) {
|
|
||||||
uncommons = getRandomCardFromBooster(cards, UNCOMMON_PREDICATE, toAdd, uncommons);
|
|
||||||
} else if (rareOrMythics > 0) {
|
|
||||||
rareOrMythics = getRandomCardFromBooster(cards, RARE_PREDICATE, toAdd, rareOrMythics);
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
for (int i = 0; i < quantity; i++) {
|
||||||
|
// Unopened product based on format of the cards?
|
||||||
|
questAssets.getShopList().addAllOfTypeFlat(new UnOpenedProduct(boosterTemplate, questController.getFormat().getFilterPrinted()).get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (commons + uncommons + rareOrMythics > 0 && attempts-- > 0);
|
|
||||||
|
|
||||||
questAssets.getShopList().addAllOfTypeFlat(toAdd);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getRandomCardFromBooster(final List<PaperCard> cards, final Predicate<PaperCard> predicate, final List<PaperCard> toAddTo, final int amount) {
|
private static int getRandomCardFromBooster(final List<PaperCard> cards, final Predicate<PaperCard> predicate, final List<PaperCard> toAddTo, final int amount) {
|
||||||
|
|||||||
Reference in New Issue
Block a user