mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
Player can choose which booster to receive in the course of quest: containing only T2 cards, Extanded or Legacy (the way it was before)
This commit is contained in:
@@ -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,24 +332,19 @@ 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<Card> getSets(Generator<Card> inputGenerator,
|
||||
final ArrayList<String> sets)
|
||||
public static Generator<Card> getSets(Generator<Card> inputGenerator, final List<String> sets)
|
||||
{
|
||||
UtilFunctions.checkNotNull("inputGenerator", inputGenerator);
|
||||
UtilFunctions.checkNotNull("sets", sets);
|
||||
|
||||
|
||||
Lambda1<Boolean, Card> predicate = new Lambda1<Boolean, Card>() {
|
||||
public Boolean apply(Card c) {
|
||||
if (c == null) {
|
||||
@@ -367,7 +362,6 @@ public class CardFilter {
|
||||
};
|
||||
|
||||
return GeneratorFunctions.filterGenerator(predicate, inputGenerator);
|
||||
|
||||
}//getSets(Generator,ArrayList)
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>Gui_WinLose class.</p>
|
||||
@@ -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: <b>%d credits</b>.<br>", reward));
|
||||
}
|
||||
@@ -374,10 +376,22 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
||||
quitButton_actionPerformed(null);
|
||||
}
|
||||
|
||||
protected void giveQuestRewards(final boolean wonMatch) {
|
||||
// Award a random booster, as frequent as set in difficulty setup
|
||||
if (model.quest.shouldAddCards(wonMatch)) {
|
||||
ArrayList<String> cardsWon = model.quest.addCards();
|
||||
protected void giveBooster()
|
||||
{
|
||||
String[] boosterTypes = {"Legacy", "Extended", "T2"};
|
||||
String boosterType = GuiUtils.getChoice("Choose prize booster type", boosterTypes);
|
||||
List<String> setsToGive = null;
|
||||
if (boosterTypes[2].equals( boosterType )) { // T2
|
||||
setsToGive = new ArrayList<String>();
|
||||
setsToGive.addAll( Arrays.asList(new String[]{"M12","NPH","MBS","M11","ROE","WWK","ZEN"}) );
|
||||
}
|
||||
if (boosterTypes[1].equals( boosterType )) { // Ext
|
||||
setsToGive = new ArrayList<String>();
|
||||
setsToGive.addAll( Arrays.asList(new String[]{"M12","NPH","MBS","M11","ROE","WWK","ZEN","M10","ARB","CFX","ALA","MOR","SHM","EVE","LRW"}) );
|
||||
}
|
||||
|
||||
ArrayList<String> 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");
|
||||
@@ -387,9 +401,16 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
||||
|
||||
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)) {
|
||||
giveBooster();
|
||||
}
|
||||
|
||||
// Award credits
|
||||
if (wonMatch) {
|
||||
long creds = model.quest.getCreditsToAdd(model.match);
|
||||
|
||||
@@ -374,8 +374,11 @@ public class QuestData {
|
||||
/**
|
||||
* <p>addCards.</p>
|
||||
*/
|
||||
public ArrayList<String> addCards() {
|
||||
public ArrayList<String> addCards( List<String> setsFilter ) {
|
||||
Generator<Card> 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++) {
|
||||
|
||||
Reference in New Issue
Block a user