diff --git a/src/main/java/forge/CardFilter.java b/src/main/java/forge/CardFilter.java index 711066f5f1c..20f95a99c1b 100644 --- a/src/main/java/forge/CardFilter.java +++ b/src/main/java/forge/CardFilter.java @@ -1,6 +1,6 @@ package forge; -import java.util.ArrayList; +import java.util.List; import net.slightlymagic.braids.util.UtilFunctions; import net.slightlymagic.braids.util.generator.GeneratorFunctions; @@ -332,42 +332,36 @@ public class CardFilter { }//getColor() /** - * Filter a Generator of cards so that it contains only the ones that - * exist in certain sets. + * Filter a Generator of cards so that it contains only the ones that exist in certain sets. * - * @param inputGenerator a sequence Generator of Card instances; must - * not be null. + * @param inputGenerator a sequence Generator of Card instances; must not be null. * - * @param sets an ArrayList of Strings identifying the valid sets; - * must not be null. + * @param sets an ArrayList of Strings identifying the valid sets; must not be null. * * @return a {@link forge.CardList} object. */ - public static Generator getSets(Generator inputGenerator, - final ArrayList sets) + public static Generator getSets(Generator inputGenerator, final List sets) { UtilFunctions.checkNotNull("inputGenerator", inputGenerator); UtilFunctions.checkNotNull("sets", sets); - - - Lambda1 predicate = new Lambda1() { + + Lambda1 predicate = new Lambda1() { public Boolean apply(Card c) { if (c == null) { return false; } - + for (SetInfo set : c.getSets()) { if (set != null && sets.contains(set.toString())) { return true; } } - + return false; } }; - + return GeneratorFunctions.filterGenerator(predicate, inputGenerator); - }//getSets(Generator,ArrayList) diff --git a/src/main/java/forge/Gui_WinLose.java b/src/main/java/forge/Gui_WinLose.java index b746c094593..74c5bf41f01 100644 --- a/src/main/java/forge/Gui_WinLose.java +++ b/src/main/java/forge/Gui_WinLose.java @@ -6,6 +6,7 @@ import forge.game.GameLossReason; import forge.game.GamePlayerRating; import forge.game.GameSummary; import forge.game.PlayerIndex; +import forge.gui.GuiUtils; import forge.properties.ForgeProps; import forge.properties.NewConstants; import forge.properties.NewConstants.LANG.Gui_WinLose.WINLOSE_TEXT; @@ -32,6 +33,8 @@ import java.awt.event.ActionEvent; import java.awt.event.WindowEvent; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; /** *

Gui_WinLose class.

@@ -188,7 +191,7 @@ public class Gui_WinLose extends JFrame implements NewConstants { if ( model.qa != null ) computerLife = model.qa.getComputerLife(); - AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0], humanList, computerList, humanLife, computerLife, model.qa ); + AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0], humanList, computerList, humanLife, computerLife, model.qa); } else { AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0]); } @@ -234,10 +237,10 @@ public class Gui_WinLose extends JFrame implements NewConstants { int rewardAltWinCondition = q.getCreditsRewardForAltWin(whyAiLost); if (rewardAltWinCondition > 0) { String winConditionName = "Unknown (bug)"; - if ( game.getWinCondition() == GameEndReason.WinsGameSpellEffect ) { + if (game.getWinCondition() == GameEndReason.WinsGameSpellEffect) { winConditionName = game.getWinSpellEffect(); } else { - switch( whyAiLost ) { + switch(whyAiLost) { case Poisoned: winConditionName = "Poison"; break; case Milled: winConditionName = "Milled"; break; default: break; @@ -265,8 +268,7 @@ public class Gui_WinLose extends JFrame implements NewConstants { } int cntCardsHumanStartedWith = humanRating.getOpeningHandSize(); - if ( 0 == cntCardsHumanStartedWith ) - { + if (0 == cntCardsHumanStartedWith) { int reward = QuestPreferences.getMatchMullToZero(); sb.append(String.format("Mulliganed to zero and still won! Bonus: %d credits.
", reward)); } @@ -374,20 +376,39 @@ public class Gui_WinLose extends JFrame implements NewConstants { quitButton_actionPerformed(null); } + protected void giveBooster() + { + String[] boosterTypes = {"Legacy", "Extended", "T2"}; + String boosterType = GuiUtils.getChoice("Choose prize booster type", boosterTypes); + List setsToGive = null; + if (boosterTypes[2].equals( boosterType )) { // T2 + setsToGive = new ArrayList(); + setsToGive.addAll( Arrays.asList(new String[]{"M12","NPH","MBS","M11","ROE","WWK","ZEN"}) ); + } + if (boosterTypes[1].equals( boosterType )) { // Ext + setsToGive = new ArrayList(); + setsToGive.addAll( Arrays.asList(new String[]{"M12","NPH","MBS","M11","ROE","WWK","ZEN","M10","ARB","CFX","ALA","MOR","SHM","EVE","LRW"}) ); + } + + ArrayList cardsWon = model.quest.addCards(setsToGive); + // TODO: Make a better presentation of cards - with pictures at least + + StringBuilder sb = new StringBuilder(); + sb.append("You have won the following new cards:\n"); + for (String cardName : cardsWon) { + sb.append(cardName + "\n"); + } + + String fileName = "BookIcon.png"; + ImageIcon icon = getIcon(fileName); + + JOptionPane.showMessageDialog(null, sb.toString(), "", JOptionPane.INFORMATION_MESSAGE, icon); + } + protected void giveQuestRewards(final boolean wonMatch) { // Award a random booster, as frequent as set in difficulty setup if (model.quest.shouldAddCards(wonMatch)) { - ArrayList cardsWon = model.quest.addCards(); - - StringBuilder sb = new StringBuilder(); - sb.append("You have won the following new cards:\n"); - for (String cardName : cardsWon) { - sb.append(cardName + "\n"); - } - - String fileName = "BookIcon.png"; - ImageIcon icon = getIcon(fileName); - JOptionPane.showMessageDialog(null, sb.toString(), "", JOptionPane.INFORMATION_MESSAGE, icon); + giveBooster(); } // Award credits diff --git a/src/main/java/forge/quest/data/QuestData.java b/src/main/java/forge/quest/data/QuestData.java index 51f1b50a4c9..d3a7825d3ea 100644 --- a/src/main/java/forge/quest/data/QuestData.java +++ b/src/main/java/forge/quest/data/QuestData.java @@ -374,8 +374,11 @@ public class QuestData { /** *

addCards.

*/ - public ArrayList addCards() { + public ArrayList addCards( List setsFilter ) { Generator cards = YieldUtils.toGenerator(AllZone.getCardFactory()); + if ( setsFilter != null ) + cards = CardFilter.getSets(cards, setsFilter); + int nCommon = QuestPreferences.getNumCommon(); int nUncommon = QuestPreferences.getNumUncommon(); int nRare = QuestPreferences.getNumRare(); @@ -852,7 +855,7 @@ public class QuestData { public static void main(String[] args) { QuestData q = new QuestData(); for (int i = 0; i < 20; i++) { - q.addCards(); + q.addCards( null ); } for (int i = 0; i < 10; i++) {