From fd2b7639c38780091edfb2e27dd10132f33c16c4 Mon Sep 17 00:00:00 2001 From: Krazy Date: Sat, 6 Jun 2015 15:58:17 +0000 Subject: [PATCH] Prevented crash when opening the card shop for quests with no boosters in its unlocked sets. --- .../src/main/java/forge/quest/QuestUtilCards.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/forge-gui/src/main/java/forge/quest/QuestUtilCards.java b/forge-gui/src/main/java/forge/quest/QuestUtilCards.java index a757ed5630d..a207f4bb453 100644 --- a/forge-gui/src/main/java/forge/quest/QuestUtilCards.java +++ b/forge-gui/src/main/java/forge/quest/QuestUtilCards.java @@ -79,10 +79,10 @@ public final class QuestUtilCards { */ public static ItemPool generateBasicLands(final int nBasic, final int nSnow, final GameFormatQuest usedFormat) { final ICardDatabase db = FModel.getMagicDb().getCommonCards(); - final ItemPool pool = new ItemPool(PaperCard.class); + final ItemPool pool = new ItemPool<>(PaperCard.class); - List landCodes = new ArrayList(); - List snowLandCodes = new ArrayList(); + List landCodes = new ArrayList<>(); + List snowLandCodes = new ArrayList<>(); if (usedFormat != null) { List availableEditions = usedFormat.getAllowedSetCodes(); @@ -391,7 +391,7 @@ public final class QuestUtilCards { /** * Lose card. - * @param cards + * @param cards The cards to lose */ public void loseCards(final List cards) { for(PaperCard pc: cards) @@ -533,6 +533,9 @@ public final class QuestUtilCards { filter = Predicates.and(CardEdition.Predicates.CAN_MAKE_BOOSTER, isLegalInQuestFormat(qc.getFormat())); } Iterable rightEditions = Iterables.filter(FModel.getMagicDb().getEditions(), filter); + if (!rightEditions.iterator().hasNext()) { + continue; + } this.qa.getShopList().add(BoosterPack.FN_FROM_SET.apply(Aggregates.random(rightEditions))); } } @@ -610,7 +613,7 @@ public final class QuestUtilCards { * the count */ private void generatePreconsInShop(final int count) { - final List meetRequirements = new ArrayList(); + final List meetRequirements = new ArrayList<>(); for (final PreconDeck deck : QuestController.getPrecons()) { if (QuestController.getPreconDeals(deck).meetsRequiremnts(this.qc.getAchievements()) && (null == qc.getFormat() || qc.getFormat().isSetLegal(deck.getEdition()))) {