mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Replace each card in a slot individually instead of replacing the whole slot at once. (Fixes higher rates of replacements) (#7854)
This commit is contained in:
@@ -401,24 +401,31 @@ public class BoosterGenerator {
|
||||
System.out.println(numCards + " of type " + slotType);
|
||||
|
||||
// For cards that end in '+', attempt to convert this card to foil.
|
||||
boolean convertCardFoil = slotType.endsWith("+");
|
||||
if (convertCardFoil) {
|
||||
boolean convertAllToFoil = slotType.endsWith("+");
|
||||
if (convertAllToFoil) {
|
||||
slotType = slotType.substring(0, slotType.length() - 1);
|
||||
}
|
||||
|
||||
// Unpack Base
|
||||
BoosterSlot boosterSlot = boosterSlots.get(slotType);
|
||||
String determineSheet = boosterSlot.replaceSlot();
|
||||
Map<String, Integer> slotReplacementCount = bulkSlotReplacement(boosterSlot, numCards);
|
||||
|
||||
List<PaperCard> paperCards = Lists.newArrayList();
|
||||
for(Map.Entry<String, Integer> entry : slotReplacementCount.entrySet()) {
|
||||
String determineSheet = entry.getKey();
|
||||
int numCardsToGenerate = entry.getValue();
|
||||
|
||||
if (determineSheet == null || determineSheet.isEmpty() || numCardsToGenerate == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the sheet ends with a '+', convert all cards in replacement section to foil
|
||||
boolean convertThisToFoil = false;
|
||||
if (determineSheet.endsWith("+")) {
|
||||
determineSheet = determineSheet.substring(0, determineSheet.length() - 1);
|
||||
convertCardFoil = true;
|
||||
convertThisToFoil = true;
|
||||
}
|
||||
|
||||
String setCode = template.getEdition();
|
||||
|
||||
// Ok, so we have a sheet now. Most should be standard sheets, but some named edition sheets
|
||||
List<PaperCard> paperCards;
|
||||
PrintSheet ps;
|
||||
try {
|
||||
// Apply the edition to the sheet name by default. We'll try again if thats not a real sheet
|
||||
@@ -426,21 +433,36 @@ public class BoosterGenerator {
|
||||
} catch (Exception e) {
|
||||
ps = getPrintSheet(determineSheet);
|
||||
}
|
||||
if (convertCardFoil) {
|
||||
paperCards = Lists.newArrayList();
|
||||
for(PaperCard pc : ps.random(numCards, true)) {
|
||||
if (convertAllToFoil || convertThisToFoil) {
|
||||
for (PaperCard pc : ps.random(numCardsToGenerate, true)) {
|
||||
paperCards.add(pc.getFoiled());
|
||||
}
|
||||
} else {
|
||||
paperCards = ps.random(numCards, true);
|
||||
paperCards.addAll(ps.random(numCardsToGenerate, true));
|
||||
}
|
||||
|
||||
result.addAll(paperCards);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Map<String, Integer> bulkSlotReplacement(BoosterSlot boosterSlot, int numCards) {
|
||||
Map<String, Integer> slotReplacementCount = new HashMap<>();
|
||||
|
||||
for(int i = 0; i < numCards; i++) {
|
||||
String determineSheet = boosterSlot.replaceSlot();
|
||||
if (slotReplacementCount.containsKey(determineSheet)) {
|
||||
slotReplacementCount.put(determineSheet, slotReplacementCount.get(determineSheet) + 1);
|
||||
} else {
|
||||
slotReplacementCount.put(determineSheet, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return slotReplacementCount;
|
||||
}
|
||||
|
||||
private static void ensureGuaranteedCardInBooster(List<PaperCard> result, SealedTemplate template, String boosterMustContain) {
|
||||
// First, see if there's already a card of the given type
|
||||
String[] types = TextUtil.split(boosterMustContain, ' ');
|
||||
|
||||
@@ -59,7 +59,6 @@ Replace=.0007F Mythic:fromSheet("FIN alternate art")
|
||||
Replace=.0000625F :name("Cid, Timeless Artificer"):!fromSheet("FIN alternate art")
|
||||
Replace=.0009375F :name("Cid, Timeless Artificer"):fromSheet("FIN alternate art")
|
||||
|
||||
|
||||
[AnyLand]
|
||||
Base=fromSheet("FIN dual lands")
|
||||
Replace=.22F :fromSheet("FIN dual lands")+
|
||||
|
||||
Reference in New Issue
Block a user