- Do not add guaranteed legendary cards to Dominaria boosters from the ones that are reserved for Planeswalker decks.

This commit is contained in:
Agetian
2018-04-23 22:27:21 +03:00
parent 75d6ea6537
commit 2b34c68057

View File

@@ -329,13 +329,13 @@ public class BoosterGenerator {
// Guaranteed cards, e.g. Dominaria guaranteed legendary creatures // Guaranteed cards, e.g. Dominaria guaranteed legendary creatures
String boosterMustContain = edition.getBoosterMustContain(); String boosterMustContain = edition.getBoosterMustContain();
if (!boosterMustContain.isEmpty()) { if (!boosterMustContain.isEmpty()) {
ensureGuaranteedCardInBooster(result, edition, boosterMustContain); ensureGuaranteedCardInBooster(result, template, boosterMustContain);
} }
return result; return result;
} }
private static void ensureGuaranteedCardInBooster(List<PaperCard> result, CardEdition edition, String boosterMustContain) { private static void ensureGuaranteedCardInBooster(List<PaperCard> result, SealedProduct.Template 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, ' ');
boolean alreadyHaveCard = false; boolean alreadyHaveCard = false;
@@ -356,8 +356,16 @@ public class BoosterGenerator {
if (!alreadyHaveCard) { if (!alreadyHaveCard) {
// Create a list of all cards that match the criteria // Create a list of all cards that match the criteria
List<PaperCard> possibleCards = Lists.newArrayList(); List<PaperCard> possibleCards = Lists.newArrayList();
for (CardEdition.CardInSet card : edition.getCards()) { for (Pair<String, Integer> slot : template.getSlots()) {
PaperCard pc = StaticData.instance().getCommonCards().getCard(card.name, edition.getCode()); String slotType = slot.getLeft();
String setCode = template.getEdition();
String sheetKey = StaticData.instance().getEditions().contains(setCode) ? slotType.trim() + " " + setCode
: slotType.trim();
PrintSheet ps = getPrintSheet(sheetKey);
List<PaperCard> cardsInSlot = Lists.newArrayList(ps.toFlatList());
for (PaperCard pc : cardsInSlot) {
boolean cardHasAllTypes = true; boolean cardHasAllTypes = true;
for (String type : types) { for (String type : types) {
if (!pc.getRules().getType().hasStringType(type)) { if (!pc.getRules().getType().hasStringType(type)) {
@@ -365,10 +373,11 @@ public class BoosterGenerator {
break; break;
} }
} }
if (cardHasAllTypes) { if (cardHasAllTypes && !possibleCards.contains(pc)) {
possibleCards.add(pc); possibleCards.add(pc);
} }
} }
}
if (!possibleCards.isEmpty()) { if (!possibleCards.isEmpty()) {
PaperCard toAdd = Aggregates.random(possibleCards); PaperCard toAdd = Aggregates.random(possibleCards);