Cleaned up and the new quest section for readability and added an option to allow duplicate cards in a quest's starting pool

This commit is contained in:
Krazy
2015-05-02 00:39:34 +00:00
parent f766faa1b1
commit f0f741ace4
6 changed files with 227 additions and 247 deletions

View File

@@ -1,17 +1,5 @@
package forge.screens.home.quest; package forge.screens.home.quest;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.swing.SwingUtilities;
import forge.UiCommand; import forge.UiCommand;
import forge.deck.Deck; import forge.deck.Deck;
import forge.deck.DeckSection; import forge.deck.DeckSection;
@@ -20,18 +8,19 @@ import forge.gui.framework.ICDoc;
import forge.item.PaperCard; import forge.item.PaperCard;
import forge.model.FModel; import forge.model.FModel;
import forge.properties.ForgeConstants; import forge.properties.ForgeConstants;
import forge.quest.QuestController; import forge.quest.*;
import forge.quest.QuestMode;
import forge.quest.QuestUtil;
import forge.quest.QuestWorld;
import forge.quest.StartingPoolPreferences;
import forge.quest.StartingPoolType;
import forge.quest.data.GameFormatQuest; import forge.quest.data.GameFormatQuest;
import forge.quest.data.QuestData; import forge.quest.data.QuestData;
import forge.quest.data.QuestPreferences.QPref; import forge.quest.data.QuestPreferences.QPref;
import forge.quest.io.QuestDataIO; import forge.quest.io.QuestDataIO;
import forge.toolbox.FOptionPane; import forge.toolbox.FOptionPane;
import javax.swing.*;
import java.io.File;
import java.io.FilenameFilter;
import java.util.*;
import java.util.Map.Entry;
/** /**
* Controls the quest data submenu in the home UI. * Controls the quest data submenu in the home UI.
* *
@@ -80,27 +69,33 @@ public enum CSubmenuQuestData implements ICDoc {
unselectableSets.add("ARC"); unselectableSets.add("ARC");
unselectableSets.add("PC2"); unselectableSets.add("PC2");
view.getBtnCustomFormat().setCommand(new UiCommand() { @Override public void run() { view.getBtnCustomFormat().setCommand(new UiCommand() {
final DialogChooseSets dialog = new DialogChooseSets(customFormatCodes, unselectableSets, false); @Override
dialog.setOkCallback(new Runnable() { public void run() {
@Override final DialogChooseSets dialog = new DialogChooseSets(customFormatCodes, unselectableSets, false);
public void run() { dialog.setOkCallback(new Runnable() {
customFormatCodes.clear(); @Override
customFormatCodes.addAll(dialog.getSelectedSets()); public void run() {
} customFormatCodes.clear();
}); customFormatCodes.addAll(dialog.getSelectedSets());
} }); }
});
}
});
view.getBtnPrizeCustomFormat().setCommand(new UiCommand() { @Override public void run() { view.getBtnPrizeCustomFormat().setCommand(new UiCommand() {
final DialogChooseSets dialog = new DialogChooseSets(customPrizeFormatCodes, unselectableSets, false); @Override
dialog.setOkCallback(new Runnable() { public void run() {
@Override final DialogChooseSets dialog = new DialogChooseSets(customPrizeFormatCodes, unselectableSets, false);
public void run() { dialog.setOkCallback(new Runnable() {
customPrizeFormatCodes.clear(); @Override
customPrizeFormatCodes.addAll(dialog.getSelectedSets()); public void run() {
} customPrizeFormatCodes.clear();
}); customPrizeFormatCodes.addAll(dialog.getSelectedSets());
} }); }
});
}
});
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -152,7 +147,10 @@ public enum CSubmenuQuestData implements ICDoc {
view.getLstQuests().setEditCommand(cmdQuestUpdate); view.getLstQuests().setEditCommand(cmdQuestUpdate);
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override public void run() { view.getBtnEmbark().requestFocusInWindow(); } @Override
public void run() {
view.getBtnEmbark().requestFocusInWindow();
}
}); });
} }
@@ -253,7 +251,7 @@ public enum CSubmenuQuestData implements ICDoc {
// } else { // } else {
// fmtPrizes = worldFormat; // fmtPrizes = worldFormat;
// } // }
final StartingPoolPreferences userPrefs = new StartingPoolPreferences(view.randomizeColorDistribution(), view.getPreferredColor(), view.startWithCompleteSet()); final StartingPoolPreferences userPrefs = new StartingPoolPreferences(view.randomizeColorDistribution(), view.getPreferredColor(), view.startWithCompleteSet(), view.allowDuplicateCards());
String questName; String questName;
while (true) { while (true) {

View File

@@ -1,20 +1,5 @@
package forge.screens.home.quest; package forge.screens.home.quest;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.plaf.basic.BasicComboBoxRenderer;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.text.WordUtils;
import forge.card.MagicColor; import forge.card.MagicColor;
import forge.deck.Deck; import forge.deck.Deck;
import forge.deck.DeckGroup; import forge.deck.DeckGroup;
@@ -32,29 +17,32 @@ import forge.quest.StartingPoolType;
import forge.screens.home.EMenuGroup; import forge.screens.home.EMenuGroup;
import forge.screens.home.IVSubmenu; import forge.screens.home.IVSubmenu;
import forge.screens.home.VHomeUI; import forge.screens.home.VHomeUI;
import forge.toolbox.FCheckBox; import forge.toolbox.*;
import forge.toolbox.FComboBoxWrapper;
import forge.toolbox.FLabel;
import forge.toolbox.FRadioButton;
import forge.toolbox.FScrollPane;
import forge.toolbox.FSkin;
import forge.toolbox.JXButtonPanel;
import forge.util.storage.IStorage; import forge.util.storage.IStorage;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.text.WordUtils;
import javax.swing.*;
import javax.swing.plaf.basic.BasicComboBoxRenderer;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Map;
/** /**
* Assembles Swing components of quest data submenu singleton. * Assembles Swing components of quest data submenu singleton.
* *
* <br><br><i>(V at beginning of class name denotes a view class.)</i> * <br><br><i>(V at beginning of class name denotes a view class.)</i>
*/ */
@SuppressWarnings("FieldCanBeLocal")
public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> { public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
/** */
SINGLETON_INSTANCE; SINGLETON_INSTANCE;
// Fields used with interface IVDoc // Fields used with interface IVDoc
private DragCell parentCell; private DragCell parentCell;
private final DragTab tab = new DragTab("Quest Data"); private final DragTab tab = new DragTab("Quest Data");
/** */
private final FLabel lblTitle = new FLabel.Builder() private final FLabel lblTitle = new FLabel.Builder()
.text("Load Quest Data").fontAlign(SwingConstants.CENTER) .text("Load Quest Data").fontAlign(SwingConstants.CENTER)
.opaque(true).fontSize(16).build(); .opaque(true).fontSize(16).build();
@@ -70,50 +58,52 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
private final FScrollPane scrQuests = new FScrollPane(lstQuests, false); private final FScrollPane scrQuests = new FScrollPane(lstQuests, false);
private final JPanel pnlOptions = new JPanel(); private final JPanel pnlOptions = new JPanel();
/* Fist column */ /* First column */
private final FRadioButton radEasy = new FRadioButton("Easy"); private final FRadioButton radEasy = new FRadioButton("Easy");
private final FRadioButton radMedium = new FRadioButton("Medium"); private final FRadioButton radMedium = new FRadioButton("Medium");
private final FRadioButton radHard = new FRadioButton("Hard"); private final FRadioButton radHard = new FRadioButton("Hard");
private final FRadioButton radExpert = new FRadioButton("Expert"); private final FRadioButton radExpert = new FRadioButton("Expert");
private final FCheckBox boxFantasy = new FCheckBox("Fantasy Mode"); private final FCheckBox boxFantasy = new FCheckBox("Fantasy Mode");
private final FCheckBox boxCompleteSet = new FCheckBox("Start with all cards in selected sets");
private final FLabel lblStartingWorld = new FLabel.Builder().text("Starting world:").build(); private final FLabel lblStartingWorld = new FLabel.Builder().text("Starting world:").build();
private final FComboBoxWrapper<QuestWorld> cbxStartingWorld = new FComboBoxWrapper<QuestWorld>(); private final FComboBoxWrapper<QuestWorld> cbxStartingWorld = new FComboBoxWrapper<>();
private final FLabel lblPreferredColor = new FLabel.Builder().text("Starting pool colors:").build();
private final FComboBoxWrapper<String> cbxPreferredColor = new FComboBoxWrapper<String>();
private final String stringBalancedDistribution = new String("balanced distribution");
private final String stringRandomizedDistribution = new String("randomized distribution");
private final String stringBias = new String(" bias");
/* Second column */ /* Second column */
private final FLabel lblStartingPool = new FLabel.Builder().text("Starting pool:").build(); private final FLabel lblStartingPool = new FLabel.Builder().text("Starting pool:").build();
private final FComboBoxWrapper<StartingPoolType> cbxStartingPool = new FComboBoxWrapper<StartingPoolType>(); private final FComboBoxWrapper<StartingPoolType> cbxStartingPool = new FComboBoxWrapper<>();
private final FLabel lblUnrestricted = new FLabel.Builder().text("All cards will be available to play.").build(); private final FLabel lblUnrestricted = new FLabel.Builder().text("All cards will be available to play.").build();
private final FLabel lblPreconDeck = new FLabel.Builder().text("Starter/Event deck:").build(); private final FLabel lblPreconDeck = new FLabel.Builder().text("Starter/Event deck:").build();
private final FComboBoxWrapper<String> cbxPreconDeck = new FComboBoxWrapper<String>(); private final FComboBoxWrapper<String> cbxPreconDeck = new FComboBoxWrapper<>();
private final FLabel lblFormat = new FLabel.Builder().text("Sanctioned format:").build(); private final FLabel lblFormat = new FLabel.Builder().text("Sanctioned format:").build();
private final FComboBoxWrapper<GameFormat> cbxFormat = new FComboBoxWrapper<GameFormat>(); private final FComboBoxWrapper<GameFormat> cbxFormat = new FComboBoxWrapper<>();
private final FLabel lblCustomDeck = new FLabel.Builder().text("Custom deck:").build(); private final FLabel lblCustomDeck = new FLabel.Builder().text("Custom deck:").build();
private final FComboBoxWrapper<Deck> cbxCustomDeck = new FComboBoxWrapper<Deck>(); private final FComboBoxWrapper<Deck> cbxCustomDeck = new FComboBoxWrapper<>();
private final FLabel btnDefineCustomFormat = new FLabel.Builder().opaque(true).hoverable(true).text("Define custom format").build(); private final FLabel btnDefineCustomFormat = new FLabel.Builder().opaque(true).hoverable(true).text("Define custom format").build();
private final FCheckBox boxCompleteSet = new FCheckBox("Start with all cards in selected sets");
private final FCheckBox boxAllowDuplicates = new FCheckBox("Allow duplicate cards");
private final FLabel lblPreferredColor = new FLabel.Builder().text("Starting pool colors:").build();
private final FComboBoxWrapper<String> cbxPreferredColor = new FComboBoxWrapper<>();
private final String stringBalancedDistribution = "balanced distribution";
private final String stringRandomizedDistribution = "randomized distribution";
private final String stringBias = " bias";
private final FLabel btnPrizeDefineCustomFormat = new FLabel.Builder().opaque(true).hoverable(true).text("Define custom format").build(); private final FLabel btnPrizeDefineCustomFormat = new FLabel.Builder().opaque(true).hoverable(true).text("Define custom format").build();
private final FLabel lblPrizedCards = new FLabel.Builder().text("Prized cards:").build(); private final FLabel lblPrizedCards = new FLabel.Builder().text("Prized cards:").build();
private final FComboBoxWrapper<Object> cbxPrizedCards = new FComboBoxWrapper<Object>(); private final FComboBoxWrapper<Object> cbxPrizedCards = new FComboBoxWrapper<>();
private final FLabel lblPrizeFormat = new FLabel.Builder().text("Sanctioned format:").build(); private final FLabel lblPrizeFormat = new FLabel.Builder().text("Sanctioned format:").build();
private final FComboBoxWrapper<GameFormat> cbxPrizeFormat = new FComboBoxWrapper<GameFormat>(); private final FComboBoxWrapper<GameFormat> cbxPrizeFormat = new FComboBoxWrapper<>();
private final FLabel lblPrizeUnrestricted = new FLabel.Builder().text("All cards will be available to win.").build(); private final FLabel lblPrizeUnrestricted = new FLabel.Builder().text("All cards will be available to win.").build();
private final FLabel lblPrizeSameAsStarting = new FLabel.Builder().text("Only sets found in starting pool will be available.").build(); private final FLabel lblPrizeSameAsStarting = new FLabel.Builder().text("Only sets in starting pool will be available.").build();
private final FCheckBox cboAllowUnlocks = new FCheckBox("Allow unlock of additional editions"); private final FCheckBox cboAllowUnlocks = new FCheckBox("Allow unlock of additional editions");
@@ -145,15 +135,15 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
cbxCustomDeck.removeAllItems(); cbxCustomDeck.removeAllItems();
final CardCollections decks = FModel.getDecks(); final CardCollections decks = FModel.getDecks();
switch (newVal) { switch (newVal) {
case SealedDeck: case SealedDeck:
for (final DeckGroup d : decks.getSealed()) { cbxCustomDeck.addItem(d.getHumanDeck()); } for (final DeckGroup d : decks.getSealed()) { cbxCustomDeck.addItem(d.getHumanDeck()); }
break; break;
case DraftDeck: case DraftDeck:
for (final DeckGroup d : decks.getDraft()) { cbxCustomDeck.addItem(d.getHumanDeck()); } for (final DeckGroup d : decks.getDraft()) { cbxCustomDeck.addItem(d.getHumanDeck()); }
break; break;
case Cube: case Cube:
for (final Deck d : decks.getCubes()) { cbxCustomDeck.addItem(d); } for (final Deck d : decks.getCubes()) { cbxCustomDeck.addItem(d); }
break; break;
} }
} }
} }
@@ -202,12 +192,13 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
* Constructor. * Constructor.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private VSubmenuQuestData() { VSubmenuQuestData() {
lblTitle.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2)); lblTitle.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
lblTitleNew.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2)); lblTitleNew.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
final JXButtonPanel difficultyPanel = new JXButtonPanel(); final JXButtonPanel difficultyPanel = new JXButtonPanel();
final String difficulty_constraints = "h 27px!, gapbottom 5"; final String difficulty_constraints = "h 25px!, gapbottom 5";
difficultyPanel.add(radEasy, difficulty_constraints); difficultyPanel.add(radEasy, difficulty_constraints);
difficultyPanel.add(radMedium, difficulty_constraints); difficultyPanel.add(radMedium, difficulty_constraints);
difficultyPanel.add(radHard, difficulty_constraints); difficultyPanel.add(radHard, difficulty_constraints);
@@ -215,6 +206,7 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
radEasy.setSelected(true); radEasy.setSelected(true);
boxCompleteSet.setToolTipText("You will start the quest with 4 of each card in the sets you have selected."); boxCompleteSet.setToolTipText("You will start the quest with 4 of each card in the sets you have selected.");
boxAllowDuplicates.setToolTipText("When your starting pool is generated duplicates of cards may be included.");
cbxStartingPool.addItem(StartingPoolType.Complete); cbxStartingPool.addItem(StartingPoolType.Complete);
cbxStartingPool.addItem(StartingPoolType.Rotating); cbxStartingPool.addItem(StartingPoolType.Rotating);
@@ -261,7 +253,7 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
cboAllowUnlocks.setSelected(true); cboAllowUnlocks.setSelected(true);
final Map<String, String> preconDescriptions = new HashMap<String, String>(); final Map<String, String> preconDescriptions = new HashMap<>();
final IStorage<PreconDeck> preconDecks = QuestController.getPrecons(); final IStorage<PreconDeck> preconDecks = QuestController.getPrecons();
for (final PreconDeck preconDeck : preconDecks) { for (final PreconDeck preconDeck : preconDecks) {
@@ -297,6 +289,7 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
boxFantasy.setSelected(true); boxFantasy.setSelected(true);
boxFantasy.setEnabled(true); boxFantasy.setEnabled(true);
boxCompleteSet.setEnabled(true); boxCompleteSet.setEnabled(true);
boxAllowDuplicates.setEnabled(true);
cbxPreferredColor.setEnabled(true); cbxPreferredColor.setEnabled(true);
@@ -305,60 +298,59 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
final JPanel pnlDifficultyMode = new JPanel(new MigLayout("insets 0, gap 1%, flowy")); final JPanel pnlDifficultyMode = new JPanel(new MigLayout("insets 0, gap 1%, flowy"));
pnlDifficultyMode.add(difficultyPanel, "gapright 4%"); pnlDifficultyMode.add(difficultyPanel, "gapright 4%");
pnlDifficultyMode.add(boxFantasy, difficulty_constraints + ", gapright 4%"); pnlDifficultyMode.add(boxFantasy, "h 27px!, gapbottom 15, gapright 4%");
pnlDifficultyMode.add(lblStartingWorld, "h 27px!, hidemode 3");
cbxStartingWorld.addTo(pnlDifficultyMode, "h 27px!, w 40%, pushx, hidemode 3");
pnlDifficultyMode.setOpaque(false); pnlDifficultyMode.setOpaque(false);
pnlOptions.add(pnlDifficultyMode, "w 40%"); pnlOptions.add(pnlDifficultyMode, "w 40%");
final JPanel pnlRestrictions = new JPanel(); final JPanel pnlRestrictions = new JPanel();
final String constraints = "h 27px!, "; final String constraints = "h 25px!, ";
final String lblWidth = "w 40%, ";
final String hidemode = "hidemode 3, "; final String hidemode = "hidemode 3, ";
final String lblWidthStart = lblWidth + hidemode; final String cboWidth = "w 240px!, pushx, ";
final String cboWidth = "pushx, ";
final String cboWidthStart = cboWidth + hidemode; final String cboWidthStart = cboWidth + hidemode;
final String btnStartingCustomFormatWidth = "w " + (4 + cbxStartingPool.getAutoSizeWidth()) + "px!, ";
pnlRestrictions.setLayout(new MigLayout("insets 0, gap 0, wrap 2", "[120, al right][240, fill]", "[|]12[|]6[]")); pnlRestrictions.setLayout(new MigLayout("insets 0, gap 10", "[right][left]"));
pnlRestrictions.add(lblStartingPool, constraints + lblWidthStart); pnlRestrictions.add(lblStartingPool, "h 15px!, cell 0 0");
cbxStartingPool.addTo(pnlRestrictions, constraints + cboWidthStart); cbxStartingPool.addTo(pnlRestrictions, constraints + cboWidthStart + " cell 1 0");
/* out of these 3 groups only one will be visible */ /* --vvv-- out of these 3 groups only one will be visible --vvv-- */
pnlRestrictions.add(lblUnrestricted, constraints + hidemode + "spanx 2"); pnlRestrictions.add(lblUnrestricted, constraints + hidemode + " cell 1 1, ");
pnlRestrictions.add(lblPreconDeck, constraints + lblWidthStart); pnlRestrictions.add(lblPreconDeck, constraints + hidemode + " cell 0 1");
cbxPreconDeck.addTo(pnlRestrictions, constraints + cboWidthStart); cbxPreconDeck.addTo(pnlRestrictions, constraints + cboWidthStart + " cell 1 1");
pnlRestrictions.add(lblCustomDeck, constraints + lblWidthStart); pnlRestrictions.add(lblCustomDeck, constraints + hidemode + " cell 0 1");
cbxCustomDeck.addTo(pnlRestrictions, constraints + cboWidthStart); // , skip 1 cbxCustomDeck.addTo(pnlRestrictions, constraints + cboWidthStart + " cell 1 1");
/* --^^^-- out of these 3 groups only one will be visible --^^^-- */
pnlRestrictions.add(lblFormat, constraints + lblWidthStart); pnlRestrictions.add(lblFormat, constraints + hidemode + " cell 0 1");
cbxFormat.addTo(pnlRestrictions, constraints + cboWidthStart); // , skip 1 cbxFormat.addTo(pnlRestrictions, constraints + cboWidthStart + " cell 1 1");
pnlRestrictions.add(btnDefineCustomFormat, constraints + hidemode + "spanx 2, w 240px"); pnlRestrictions.add(btnDefineCustomFormat, btnStartingCustomFormatWidth + constraints + hidemode + " cell 1 1");
pnlRestrictions.add(boxAllowDuplicates, "h 15px!, cell 1 2");
pnlRestrictions.add(boxCompleteSet, "h 15px!, cell 1 3");
pnlRestrictions.add(lblPreferredColor, constraints + hidemode + "cell 0 4");
cbxPreferredColor.addTo(pnlRestrictions, constraints + cboWidthStart + "cell 1 4");
// Prized cards options // Prized cards options
pnlRestrictions.add(lblPrizedCards, constraints + lblWidth); pnlRestrictions.add(lblPrizedCards, constraints + " cell 0 5");
cbxPrizedCards.addTo(pnlRestrictions, constraints + cboWidth); cbxPrizedCards.addTo(pnlRestrictions, constraints + cboWidth + " cell 1 5");
pnlRestrictions.add(lblPrizeFormat, constraints + lblWidthStart); pnlRestrictions.add(lblPrizeFormat, constraints + hidemode + "cell 0 6");
cbxPrizeFormat.addTo(pnlRestrictions, constraints + cboWidthStart); // , skip 1 cbxPrizeFormat.addTo(pnlRestrictions, constraints + cboWidthStart + "cell 1 6"); // , skip 1
pnlRestrictions.add(btnPrizeDefineCustomFormat, constraints + hidemode + "spanx 2, w 240px"); pnlRestrictions.add(btnPrizeDefineCustomFormat, constraints + hidemode + "cell 1 6");
pnlRestrictions.add(lblPrizeSameAsStarting, constraints + hidemode + "spanx 2"); pnlRestrictions.add(lblPrizeSameAsStarting, constraints + hidemode + "cell 1 6");
pnlRestrictions.add(lblPrizeUnrestricted, constraints + hidemode + "spanx 2"); pnlRestrictions.add(lblPrizeUnrestricted, constraints + hidemode + "cell 1 6");
pnlRestrictions.add(cboAllowUnlocks, constraints + "spanx 2, ax right"); pnlRestrictions.add(cboAllowUnlocks, constraints + "cell 1 7");
pnlRestrictions.add(boxCompleteSet, constraints + "spanx 2, ax right");
pnlRestrictions.add(lblPreferredColor, constraints + lblWidthStart);
cbxPreferredColor.addTo(pnlRestrictions, constraints + cboWidthStart + ", wrap");
pnlRestrictions.add(lblStartingWorld, constraints + lblWidthStart);
cbxStartingWorld.addTo(pnlRestrictions, constraints + cboWidthStart);
// cboAllowUnlocks.setOpaque(false);
pnlRestrictions.setOpaque(false); pnlRestrictions.setOpaque(false);
pnlOptions.add(pnlRestrictions, "pushx, ay top"); pnlOptions.add(pnlRestrictions, "pushx, ay top");
@@ -477,12 +469,12 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
} }
public String getSelectedPrecon() { public String getSelectedPrecon() {
return cbxPreconDeck.getSelectedItem().toString(); return cbxPreconDeck.getSelectedItem();
} }
public Deck getSelectedDeck() { public Deck getSelectedDeck() {
final Object sel = cbxCustomDeck.getSelectedItem(); final Object sel = cbxCustomDeck.getSelectedItem();
return sel instanceof Deck ? (Deck) sel : null; return sel != null ? (Deck) sel : null;
} }
public boolean isUnlockSetsAllowed() { public boolean isUnlockSetsAllowed() {
@@ -510,6 +502,10 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
return boxCompleteSet.isSelected(); return boxCompleteSet.isSelected();
} }
public boolean allowDuplicateCards() {
return boxAllowDuplicates.isSelected();
}
public boolean randomizeColorDistribution() { public boolean randomizeColorDistribution() {
return stringRandomizedDistribution.equals(cbxPreferredColor.getSelectedItem()); return stringRandomizedDistribution.equals(cbxPreferredColor.getSelectedItem());
} }

View File

@@ -1,17 +1,6 @@
package forge.screens.quest; package forge.screens.quest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import org.apache.commons.lang3.text.WordUtils;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.FThreads; import forge.FThreads;
import forge.assets.FSkinFont; import forge.assets.FSkinFont;
import forge.assets.FSkinImage; import forge.assets.FSkinImage;
@@ -25,38 +14,31 @@ import forge.item.PreconDeck;
import forge.model.CardCollections; import forge.model.CardCollections;
import forge.model.FModel; import forge.model.FModel;
import forge.properties.ForgeConstants; import forge.properties.ForgeConstants;
import forge.quest.QuestController; import forge.quest.*;
import forge.quest.QuestMode;
import forge.quest.QuestUtil;
import forge.quest.QuestWorld;
import forge.quest.StartingPoolPreferences;
import forge.quest.StartingPoolType;
import forge.quest.data.GameFormatQuest; import forge.quest.data.GameFormatQuest;
import forge.quest.data.QuestPreferences.QPref; import forge.quest.data.QuestPreferences.QPref;
import forge.screens.FScreen; import forge.screens.FScreen;
import forge.screens.LoadingOverlay; import forge.screens.LoadingOverlay;
import forge.screens.home.NewGameMenu; import forge.screens.home.NewGameMenu;
import forge.screens.quest.QuestMenu.LaunchReason; import forge.screens.quest.QuestMenu.LaunchReason;
import forge.toolbox.FCheckBox; import forge.toolbox.*;
import forge.toolbox.FComboBox;
import forge.toolbox.FDisplayObject;
import forge.toolbox.FEvent;
import forge.toolbox.FEvent.FEventHandler; import forge.toolbox.FEvent.FEventHandler;
import forge.toolbox.FLabel;
import forge.toolbox.FOptionPane;
import forge.toolbox.FScrollPane;
import forge.util.FileUtil; import forge.util.FileUtil;
import forge.util.ThreadUtil; import forge.util.ThreadUtil;
import forge.util.Utils; import forge.util.Utils;
import forge.util.gui.SOptionPane; import forge.util.gui.SOptionPane;
import forge.util.storage.IStorage; import forge.util.storage.IStorage;
import org.apache.commons.lang3.text.WordUtils;
import java.util.*;
import java.util.Map.Entry;
public class NewQuestScreen extends FScreen { public class NewQuestScreen extends FScreen {
private static final float EMBARK_BTN_HEIGHT = 2 * Utils.AVG_FINGER_HEIGHT; private static final float EMBARK_BTN_HEIGHT = 2 * Utils.AVG_FINGER_HEIGHT;
private static final float PADDING = FOptionPane.PADDING; private static final float PADDING = FOptionPane.PADDING;
private final List<String> customFormatCodes = new ArrayList<String>(); private final List<String> customFormatCodes = new ArrayList<>();
private final List<String> customPrizeFormatCodes = new ArrayList<String>(); private final List<String> customPrizeFormatCodes = new ArrayList<>();
private final FScrollPane scroller = add(new FScrollPane() { private final FScrollPane scroller = add(new FScrollPane() {
@Override @Override
@@ -99,14 +81,14 @@ public class NewQuestScreen extends FScreen {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final FLabel lblDifficulty = scroller.add(new FLabel.Builder().text("Difficulty:").build()); private final FLabel lblDifficulty = scroller.add(new FLabel.Builder().text("Difficulty:").build());
private final FComboBox<String> cbxDifficulty = scroller.add(new FComboBox<String>(new String[]{ "Easy", "Medium", "Hard", "Expert" })); private final FComboBox<String> cbxDifficulty = scroller.add(new FComboBox<>(new String[]{ "Easy", "Medium", "Hard", "Expert" }));
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final FLabel lblPreferredColor = scroller.add(new FLabel.Builder().text("Starting pool colors:").build()); private final FLabel lblPreferredColor = scroller.add(new FLabel.Builder().text("Starting pool colors:").build());
private final FComboBox<String> cbxPreferredColor = scroller.add(new FComboBox<String>()); private final FComboBox<String> cbxPreferredColor = scroller.add(new FComboBox<String>());
private final String stringBalancedDistribution = new String("balanced distribution"); private final String stringBalancedDistribution = "balanced distribution";
private final String stringRandomizedDistribution = new String("randomized distribution"); private final String stringRandomizedDistribution = "randomized distribution";
private final String stringBias = new String(" bias"); private final String stringBias = " bias";
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final FLabel lblStartingPool = scroller.add(new FLabel.Builder().text("Starting pool:").build()); private final FLabel lblStartingPool = scroller.add(new FLabel.Builder().text("Starting pool:").build());
@@ -127,7 +109,7 @@ public class NewQuestScreen extends FScreen {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final FLabel lblPrizedCards = scroller.add(new FLabel.Builder().text("Prized cards:").build()); private final FLabel lblPrizedCards = scroller.add(new FLabel.Builder().text("Prized cards:").build());
private final FComboBox<Object> cbxPrizedCards = scroller.add(new FComboBox<Object>()); private final FComboBox<Object> cbxPrizedCards = scroller.add(new FComboBox<>());
private final FLabel lblPrizeFormat = scroller.add(new FLabel.Builder().text("Sanctioned format:").build()); private final FLabel lblPrizeFormat = scroller.add(new FLabel.Builder().text("Sanctioned format:").build());
private final FComboBox<GameFormat> cbxPrizeFormat = scroller.add(new FComboBox<GameFormat>()); private final FComboBox<GameFormat> cbxPrizeFormat = scroller.add(new FComboBox<GameFormat>());
@@ -138,6 +120,7 @@ public class NewQuestScreen extends FScreen {
private final FCheckBox cbAllowUnlocks = scroller.add(new FCheckBox("Allow unlock of additional editions")); private final FCheckBox cbAllowUnlocks = scroller.add(new FCheckBox("Allow unlock of additional editions"));
private final FCheckBox cbCompleteSet = scroller.add(new FCheckBox("Start with all cards in selected sets")); private final FCheckBox cbCompleteSet = scroller.add(new FCheckBox("Start with all cards in selected sets"));
private final FCheckBox cbDuplicateCards = scroller.add(new FCheckBox("Allow duplicates in starting pool"));
private final FCheckBox cbFantasy = scroller.add(new FCheckBox("Fantasy Mode")); private final FCheckBox cbFantasy = scroller.add(new FCheckBox("Fantasy Mode"));
private final FLabel btnEmbark = add(new FLabel.ButtonBuilder() private final FLabel btnEmbark = add(new FLabel.ButtonBuilder()
@@ -218,7 +201,7 @@ public class NewQuestScreen extends FScreen {
cbAllowUnlocks.setSelected(true); cbAllowUnlocks.setSelected(true);
final Map<String, String> preconDescriptions = new HashMap<String, String>(); final Map<String, String> preconDescriptions = new HashMap<>();
IStorage<PreconDeck> preconDecks = QuestController.getPrecons(); IStorage<PreconDeck> preconDecks = QuestController.getPrecons();
for (PreconDeck preconDeck : preconDecks) { for (PreconDeck preconDeck : preconDecks) {
@@ -237,7 +220,7 @@ public class NewQuestScreen extends FScreen {
btnPrizeDefineCustomFormat.setEnabled(false); btnPrizeDefineCustomFormat.setEnabled(false);
// disable the very powerful sets -- they can be unlocked later for a high price // disable the very powerful sets -- they can be unlocked later for a high price
final List<String> unselectableSets = new ArrayList<String>(); final List<String> unselectableSets = new ArrayList<>();
unselectableSets.add("LEA"); unselectableSets.add("LEA");
unselectableSets.add("LEB"); unselectableSets.add("LEB");
unselectableSets.add("MBP"); unselectableSets.add("MBP");
@@ -359,12 +342,12 @@ public class NewQuestScreen extends FScreen {
} }
public String getSelectedPrecon() { public String getSelectedPrecon() {
return cbxPreconDeck.getSelectedItem().toString(); return cbxPreconDeck.getSelectedItem();
} }
public Deck getSelectedDeck() { public Deck getSelectedDeck() {
Object sel = cbxCustomDeck.getSelectedItem(); Object sel = cbxCustomDeck.getSelectedItem();
return sel instanceof Deck ? (Deck) sel : null; return sel != null ? (Deck) sel : null;
} }
public boolean isUnlockSetsAllowed() { public boolean isUnlockSetsAllowed() {
@@ -375,8 +358,12 @@ public class NewQuestScreen extends FScreen {
return cbCompleteSet.isSelected(); return cbCompleteSet.isSelected();
} }
public boolean allowDuplicateCards() {
return cbDuplicateCards.isSelected();
}
public StartingPoolType getStartingPoolType() { public StartingPoolType getStartingPoolType() {
return (StartingPoolType) cbxStartingPool.getSelectedItem(); return cbxStartingPool.getSelectedItem();
} }
public StartingPoolType getPrizedPoolType() { public StartingPoolType getPrizedPoolType() {
@@ -405,11 +392,11 @@ public class NewQuestScreen extends FScreen {
} }
public GameFormat getRotatingFormat() { public GameFormat getRotatingFormat() {
return (GameFormat) cbxFormat.getSelectedItem(); return cbxFormat.getSelectedItem();
} }
public GameFormat getPrizedRotatingFormat() { public GameFormat getPrizedRotatingFormat() {
return (GameFormat) cbxPrizeFormat.getSelectedItem(); return cbxPrizeFormat.getSelectedItem();
} }
@Override @Override
@@ -468,7 +455,7 @@ public class NewQuestScreen extends FScreen {
fmtStartPool = worldFormat; fmtStartPool = worldFormat;
} }
GameFormat fmtPrizes = null; GameFormat fmtPrizes;
// The starting QuestWorld format should NOT affect what you get if you travel to a world that doesn't have one... // The starting QuestWorld format should NOT affect what you get if you travel to a world that doesn't have one...
// if (worldFormat == null) { // if (worldFormat == null) {
@@ -476,7 +463,7 @@ public class NewQuestScreen extends FScreen {
if (null == prizedPoolType) { if (null == prizedPoolType) {
fmtPrizes = fmtStartPool; fmtPrizes = fmtStartPool;
if (null == fmtPrizes && dckStartPool != null) { // build it form deck if (null == fmtPrizes && dckStartPool != null) { // build it form deck
Set<String> sets = new HashSet<String>(); Set<String> sets = new HashSet<>();
for (Entry<PaperCard, Integer> c : dckStartPool.getMain()) { for (Entry<PaperCard, Integer> c : dckStartPool.getMain()) {
sets.add(c.getKey().getEdition()); sets.add(c.getKey().getEdition());
} }
@@ -500,7 +487,7 @@ public class NewQuestScreen extends FScreen {
return; return;
} }
} }
fmtPrizes = customPrizeFormatCodes.isEmpty() ? null : new GameFormat("Custom Prizes", customPrizeFormatCodes, null); // chosen sets and no banend cards fmtPrizes = customPrizeFormatCodes.isEmpty() ? null : new GameFormat("Custom Prizes", customPrizeFormatCodes, null); // chosen sets and no banned cards
break; break;
case Rotating: case Rotating:
fmtPrizes = getPrizedRotatingFormat(); fmtPrizes = getPrizedRotatingFormat();
@@ -539,7 +526,7 @@ public class NewQuestScreen extends FScreen {
@Override @Override
public void run() { public void run() {
final QuestMode mode = isFantasy() ? QuestMode.Fantasy : QuestMode.Classic; final QuestMode mode = isFantasy() ? QuestMode.Fantasy : QuestMode.Classic;
final StartingPoolPreferences userPrefs = new StartingPoolPreferences(randomizeColorDistribution(), getPreferredColor(), startWithCompleteSet()); final StartingPoolPreferences userPrefs = new StartingPoolPreferences(randomizeColorDistribution(), getPreferredColor(), startWithCompleteSet(), allowDuplicateCards());
QuestController qc = FModel.getQuest(); QuestController qc = FModel.getQuest();
qc.newGame(questName, getSelectedDifficulty(), mode, fmtPrizes, isUnlockSetsAllowed(), dckStartPool, fmtStartPool, getStartingWorldName(), userPrefs); qc.newGame(questName, getSelectedDifficulty(), mode, fmtPrizes, isUnlockSetsAllowed(), dckStartPool, fmtStartPool, getStartingWorldName(), userPrefs);
qc.save(); qc.save();

View File

@@ -39,10 +39,9 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
// The BoosterPack generates cards for the Card Pool in Quest Mode
/** /**
* <p> * <p>
* QuestBoosterPack class. * QuestBoosterPack class. Generates cards for the Card Pool in Quest Mode
* </p> * </p>
* *
* @author Forge * @author Forge
@@ -68,13 +67,13 @@ public final class BoosterUtils {
public static List<PaperCard> getQuestStarterDeck(final Predicate<PaperCard> filter, final int numCommon, public static List<PaperCard> getQuestStarterDeck(final Predicate<PaperCard> filter, final int numCommon,
final int numUncommon, final int numRare, final StartingPoolPreferences userPrefs) { final int numUncommon, final int numRare, final StartingPoolPreferences userPrefs) {
final ArrayList<PaperCard> cards = new ArrayList<PaperCard>(); final ArrayList<PaperCard> cards = new ArrayList<>();
// Each color should have around the same amount of monocolored cards // Each color should have around the same amount of monocolored cards
// There should be 3 Colorless cards for every 4 cards in a single color // There should be 3 Colorless cards for every 4 cards in a single color
// There should be 1 Multicolor card for every 4 cards in a single color // There should be 1 Multicolor card for every 4 cards in a single color
final List<Predicate<CardRules>> colorFilters = new ArrayList<Predicate<CardRules>>(); final List<Predicate<CardRules>> colorFilters = new ArrayList<>();
final boolean preferred = (userPrefs != null && userPrefs.getPreferredColor() != MagicColor.ALL_COLORS); final boolean preferred = (userPrefs != null && userPrefs.getPreferredColor() != MagicColor.ALL_COLORS);
final boolean randomized = userPrefs != null && userPrefs.useRandomPool(); final boolean randomized = userPrefs != null && userPrefs.useRandomPool();
final int colorBias = (preferred && !randomized) ? FModel.getQuestPreferences().getPrefInt(QPref.STARTING_POOL_COLOR_BIAS) : 0; final int colorBias = (preferred && !randomized) ? FModel.getQuestPreferences().getPrefInt(QPref.STARTING_POOL_COLOR_BIAS) : 0;
@@ -108,23 +107,24 @@ public final class BoosterUtils {
// This will save CPU time when sets are limited // This will save CPU time when sets are limited
final List<PaperCard> cardpool = Lists.newArrayList(Iterables.filter(FModel.getMagicDb().getCommonCards().getAllCards(), filter)); final List<PaperCard> cardpool = Lists.newArrayList(Iterables.filter(FModel.getMagicDb().getCommonCards().getAllCards(), filter));
if (userPrefs.grantCompleteSet()) { assert userPrefs != null;
for (PaperCard card : cardpool) { if (userPrefs.grantCompleteSet()) {
cards.add(card); for (PaperCard card : cardpool) {
cards.add(card); cards.add(card);
cards.add(card); cards.add(card);
cards.add(card); cards.add(card);
} cards.add(card);
return cards; }
} return cards;
}
final Predicate<PaperCard> pCommon = IPaperCard.Predicates.Presets.IS_COMMON; final Predicate<PaperCard> pCommon = IPaperCard.Predicates.Presets.IS_COMMON;
cards.addAll(BoosterUtils.generateDefinetlyColouredCards(cardpool, pCommon, biasAdjustedCommons, colorFilters)); cards.addAll(BoosterUtils.generateCards(cardpool, pCommon, biasAdjustedCommons, colorFilters, userPrefs.allowDuplicates()));
final Predicate<PaperCard> pUncommon = IPaperCard.Predicates.Presets.IS_UNCOMMON; final Predicate<PaperCard> pUncommon = IPaperCard.Predicates.Presets.IS_UNCOMMON;
cards.addAll(BoosterUtils.generateDefinetlyColouredCards(cardpool, pUncommon, biasAdjustedUncommons, colorFilters)); cards.addAll(BoosterUtils.generateCards(cardpool, pUncommon, biasAdjustedUncommons, colorFilters, userPrefs.allowDuplicates()));
int nRares = biasAdjustedRares, nMythics = 0; int nRares = biasAdjustedRares, nMythics = 0;
final Predicate<PaperCard> filterMythics = IPaperCard.Predicates.Presets.IS_MYTHIC_RARE; final Predicate<PaperCard> filterMythics = IPaperCard.Predicates.Presets.IS_MYTHIC_RARE;
final boolean haveMythics = Iterables.any(cardpool, filterMythics); final boolean haveMythics = Iterables.any(cardpool, filterMythics);
for (int iSlot = 0; haveMythics && (iSlot < numRare); iSlot++) { for (int iSlot = 0; haveMythics && (iSlot < numRare); iSlot++) {
@@ -136,9 +136,9 @@ public final class BoosterUtils {
} }
final Predicate<PaperCard> pRare = IPaperCard.Predicates.Presets.IS_RARE; final Predicate<PaperCard> pRare = IPaperCard.Predicates.Presets.IS_RARE;
cards.addAll(BoosterUtils.generateDefinetlyColouredCards(cardpool, pRare, nRares, colorFilters)); cards.addAll(BoosterUtils.generateCards(cardpool, pRare, nRares, colorFilters, false));
if (nMythics > 0) { if (nMythics > 0) {
cards.addAll(BoosterUtils.generateDefinetlyColouredCards(cardpool, filterMythics, nMythics, colorFilters)); cards.addAll(BoosterUtils.generateCards(cardpool, filterMythics, nMythics, colorFilters, userPrefs.allowDuplicates()));
} }
return cards; return cards;
} }
@@ -154,12 +154,16 @@ public final class BoosterUtils {
* an int * an int
* @param allowedColors * @param allowedColors
* a List<Predicate<CardRules>> * a List<Predicate<CardRules>>
* @param allowDuplicates
* If true, multiple copies of the same card will be allowed to be generated.
* @return a list of card names * @return a list of card names
*/ */
private static ArrayList<PaperCard> generateDefinetlyColouredCards(final Iterable<PaperCard> source, private static ArrayList<PaperCard> generateCards(
final Predicate<PaperCard> filter, final int cntNeeded, final List<Predicate<CardRules>> allowedColors) { final Iterable<PaperCard> source, final Predicate<PaperCard> filter, final int cntNeeded,
final List<Predicate<CardRules>> allowedColors, final boolean allowDuplicates) {
// If color is null, use colorOrder progression to grab cards // If color is null, use colorOrder progression to grab cards
final ArrayList<PaperCard> result = new ArrayList<PaperCard>(); final ArrayList<PaperCard> result = new ArrayList<>();
final int size = allowedColors == null ? 0 : allowedColors.size(); final int size = allowedColors == null ? 0 : allowedColors.size();
if (allowedColors != null) { if (allowedColors != null) {
@@ -169,8 +173,7 @@ public final class BoosterUtils {
int cntMade = 0, iAttempt = 0; int cntMade = 0, iAttempt = 0;
// This will prevent endless loop @ wh // This will prevent endless loop @ wh
int allowedMisses = (2 + size + 2) * cntNeeded; // lol, 2+2 is not magic int allowedMisses = (size + 4) * cntNeeded; // lol, 2+2 is not magic constant!
// constant!
while ((cntMade < cntNeeded) && (allowedMisses > 0)) { while ((cntMade < cntNeeded) && (allowedMisses > 0)) {
PaperCard card = null; PaperCard card = null;
@@ -188,7 +191,7 @@ public final class BoosterUtils {
card = Aggregates.random(Iterables.filter(source, filter)); card = Aggregates.random(Iterables.filter(source, filter));
} }
if ((card != null) && !result.contains(card)) { if ((card != null) && (allowDuplicates || !result.contains(card))) {
result.add(card); result.add(card);
cntMade++; cntMade++;
} else { } else {
@@ -240,18 +243,19 @@ public final class BoosterUtils {
private static List<InventoryItem> parseReward(final String s) { private static List<InventoryItem> parseReward(final String s) {
String[] temp = s.split(" "); String[] temp = s.split(" ");
List<InventoryItem> rewards = new ArrayList<InventoryItem>(); List<InventoryItem> rewards = new ArrayList<>();
// last word starts with 'rare' ignore case // last word starts with 'rare' ignore case
if (temp.length > 1 && temp[temp.length - 1].regionMatches(true, 0, "rare", 0, 4)) { if (temp.length > 1 && temp[temp.length - 1].regionMatches(true, 0, "rare", 0, 4)) {
// Type 1: 'n [color] rares' // Type 1: 'n [color] rares'
final int qty = Integer.parseInt(temp[0]); final int qty = Integer.parseInt(temp[0]);
List<Predicate<PaperCard>> preds = new ArrayList<Predicate<PaperCard>>(); List<Predicate<PaperCard>> preds = new ArrayList<>();
preds.add(IPaperCard.Predicates.Presets.IS_RARE_OR_MYTHIC); // Determine rarity preds.add(IPaperCard.Predicates.Presets.IS_RARE_OR_MYTHIC); // Determine rarity
if (temp.length > 2) { if (temp.length > 2) {
Predicate<CardRules> cr = parseRulesLimitation(temp[1]); Predicate<CardRules> cr = parseRulesLimitation(temp[1]);
//noinspection RedundantCast
if (Predicates.alwaysTrue() != (Object) cr) { // guava has a single instance for always-const predicates if (Predicates.alwaysTrue() != (Object) cr) { // guava has a single instance for always-const predicates
preds.add(Predicates.compose(cr, PaperCard.FN_GET_RULES)); preds.add(Predicates.compose(cr, PaperCard.FN_GET_RULES));
} }
@@ -307,7 +311,7 @@ public final class BoosterUtils {
} }
final String[] items = s.split(";"); final String[] items = s.split(";");
final List<InventoryItem> rewards = new ArrayList<InventoryItem>(); final List<InventoryItem> rewards = new ArrayList<>();
for (final String item : items) { for (final String item : items) {

View File

@@ -1,29 +1,11 @@
package forge.quest; package forge.quest;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.base.Function; import com.google.common.base.Function;
import forge.GuiBase; import forge.GuiBase;
import forge.deck.CardPool; import forge.deck.CardPool;
import forge.deck.Deck; import forge.deck.Deck;
import forge.deck.DeckSection; import forge.deck.DeckSection;
import forge.item.BoosterBox; import forge.item.*;
import forge.item.BoosterPack;
import forge.item.BoxedProduct;
import forge.item.FatPack;
import forge.item.IPaperCard;
import forge.item.InventoryItem;
import forge.item.PaperCard;
import forge.item.PreconDeck;
import forge.item.SealedProduct;
import forge.item.TournamentPack;
import forge.itemmanager.IItemManager; import forge.itemmanager.IItemManager;
import forge.itemmanager.SItemManagerUtil; import forge.itemmanager.SItemManagerUtil;
import forge.model.FModel; import forge.model.FModel;
@@ -31,6 +13,13 @@ import forge.properties.ForgePreferences.FPref;
import forge.quest.io.ReadPriceList; import forge.quest.io.ReadPriceList;
import forge.util.ItemPool; import forge.util.ItemPool;
import forge.util.gui.SOptionPane; import forge.util.gui.SOptionPane;
import org.apache.commons.lang3.tuple.Pair;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class QuestSpellShop { public class QuestSpellShop {
private static Map<String, Integer> mapPrices; private static Map<String, Integer> mapPrices;

View File

@@ -28,20 +28,22 @@ public final class StartingPoolPreferences {
private final boolean randomPool; private final boolean randomPool;
private final byte preferredColor; private final byte preferredColor;
private final boolean completeSet; private final boolean completeSet;
private final boolean allowDuplicates;
/** /**
* The constructor. * Creates a new StartingPoolPreferences instance.
* @param random * @param random If true, a completely random pool will be generated without filter restrictions. This does not
* true = use completely random pool without filter restrictions * bypass rarity restrictions.
* (Note that this does NOT bypass card rarity restrictions!) * @param preference Preferred color or colorless. All colors == no preference. See {@link forge.card.MagicColor}.
* @param preference * @param completeSet If true, four of each card in the starting pool will be generated.
* preferred color/COLORLESS (ALL_COLORS = no preference) * @param allowDuplicates If true, multiples of each card will be allowed to be generated.
*/ */
public StartingPoolPreferences(final boolean random, final byte preference, final boolean completeSet) { public StartingPoolPreferences(final boolean random, final byte preference, final boolean completeSet, final boolean allowDuplicates) {
randomPool = random; randomPool = random;
preferredColor = preference; preferredColor = preference;
this.completeSet = completeSet; this.completeSet = completeSet;
this.allowDuplicates = allowDuplicates;
} }
/** /**
@@ -61,8 +63,12 @@ public final class StartingPoolPreferences {
return preferredColor; return preferredColor;
} }
public boolean grantCompleteSet() { public boolean grantCompleteSet() {
return completeSet; return completeSet;
} }
public boolean allowDuplicates() {
return allowDuplicates;
}
} }