mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +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,46 +401,68 @@ public class BoosterGenerator {
|
|||||||
System.out.println(numCards + " of type " + slotType);
|
System.out.println(numCards + " of type " + slotType);
|
||||||
|
|
||||||
// For cards that end in '+', attempt to convert this card to foil.
|
// For cards that end in '+', attempt to convert this card to foil.
|
||||||
boolean convertCardFoil = slotType.endsWith("+");
|
boolean convertAllToFoil = slotType.endsWith("+");
|
||||||
if (convertCardFoil) {
|
if (convertAllToFoil) {
|
||||||
slotType = slotType.substring(0, slotType.length() - 1);
|
slotType = slotType.substring(0, slotType.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unpack Base
|
|
||||||
BoosterSlot boosterSlot = boosterSlots.get(slotType);
|
BoosterSlot boosterSlot = boosterSlots.get(slotType);
|
||||||
String determineSheet = boosterSlot.replaceSlot();
|
Map<String, Integer> slotReplacementCount = bulkSlotReplacement(boosterSlot, numCards);
|
||||||
|
|
||||||
if (determineSheet.endsWith("+")) {
|
List<PaperCard> paperCards = Lists.newArrayList();
|
||||||
determineSheet = determineSheet.substring(0, determineSheet.length() - 1);
|
for(Map.Entry<String, Integer> entry : slotReplacementCount.entrySet()) {
|
||||||
convertCardFoil = true;
|
String determineSheet = entry.getKey();
|
||||||
}
|
int numCardsToGenerate = entry.getValue();
|
||||||
|
|
||||||
String setCode = template.getEdition();
|
if (determineSheet == null || determineSheet.isEmpty() || numCardsToGenerate == 0) {
|
||||||
|
continue;
|
||||||
// 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
|
|
||||||
ps = getPrintSheet(determineSheet + " " + setCode);
|
|
||||||
} catch(Exception e) {
|
|
||||||
ps = getPrintSheet(determineSheet);
|
|
||||||
}
|
|
||||||
if (convertCardFoil) {
|
|
||||||
paperCards = Lists.newArrayList();
|
|
||||||
for(PaperCard pc : ps.random(numCards, true)) {
|
|
||||||
paperCards.add(pc.getFoiled());
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
paperCards = ps.random(numCards, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
result.addAll(paperCards);
|
// 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);
|
||||||
|
convertThisToFoil = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String setCode = template.getEdition();
|
||||||
|
PrintSheet ps;
|
||||||
|
try {
|
||||||
|
// Apply the edition to the sheet name by default. We'll try again if thats not a real sheet
|
||||||
|
ps = getPrintSheet(determineSheet + " " + setCode);
|
||||||
|
} catch (Exception e) {
|
||||||
|
ps = getPrintSheet(determineSheet);
|
||||||
|
}
|
||||||
|
if (convertAllToFoil || convertThisToFoil) {
|
||||||
|
for (PaperCard pc : ps.random(numCardsToGenerate, true)) {
|
||||||
|
paperCards.add(pc.getFoiled());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
paperCards.addAll(ps.random(numCardsToGenerate, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
result.addAll(paperCards);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
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) {
|
private static void ensureGuaranteedCardInBooster(List<PaperCard> result, SealedTemplate template, String boosterMustContain) {
|
||||||
// First, see if there's already a card of the given type
|
// First, see if there's already a card of the given type
|
||||||
String[] types = TextUtil.split(boosterMustContain, ' ');
|
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=.0000625F :name("Cid, Timeless Artificer"):!fromSheet("FIN alternate art")
|
||||||
Replace=.0009375F :name("Cid, Timeless Artificer"):fromSheet("FIN alternate art")
|
Replace=.0009375F :name("Cid, Timeless Artificer"):fromSheet("FIN alternate art")
|
||||||
|
|
||||||
|
|
||||||
[AnyLand]
|
[AnyLand]
|
||||||
Base=fromSheet("FIN dual lands")
|
Base=fromSheet("FIN dual lands")
|
||||||
Replace=.22F :fromSheet("FIN dual lands")+
|
Replace=.22F :fromSheet("FIN dual lands")+
|
||||||
|
|||||||
Reference in New Issue
Block a user