Updated selected sets for "Standard" and "Selected". Added blocks to selectable Formats. Made all formats selectable in card selector, mage book and automated deck generation.

This commit is contained in:
LevelX2 2012-10-14 10:08:16 +02:00
parent 6619c21d6b
commit cf88bb5ac3
5 changed files with 380 additions and 88 deletions

View file

@ -1,5 +1,5 @@
package mage.client.deck.generator; package mage.client.deck.generator;
import mage.Constants.CardType; import mage.Constants.CardType;
import mage.Constants.ColoredManaSymbol; import mage.Constants.ColoredManaSymbol;
import mage.Mana; import mage.Mana;
@ -13,7 +13,7 @@ import mage.interfaces.rate.RateCallback;
import mage.sets.Sets; import mage.sets.Sets;
import mage.utils.CardUtil; import mage.utils.CardUtil;
import mage.utils.DeckBuilder; import mage.utils.DeckBuilder;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -21,31 +21,31 @@ import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
import java.util.List; import java.util.List;
/** /**
* Generates random card pool and builds a deck. * Generates random card pool and builds a deck.
* *
* @author nantuko * @author nantuko
*/ */
public class DeckGenerator { public class DeckGenerator {
private static JDialog dlg; private static JDialog dlg;
private static String selectedColors; private static String selectedColors;
private static JComboBox formats; private static JComboBox formats;
private static final int SPELL_CARD_POOL_SIZE = 180; private static final int SPELL_CARD_POOL_SIZE = 180;
private static final int DECK_LANDS = 16; private static final int DECK_LANDS = 16;
private static final int MAX_NON_BASIC_SOURCE = DECK_LANDS / 2; private static final int MAX_NON_BASIC_SOURCE = DECK_LANDS / 2;
private static final boolean GENERATE_RANDOM_BASIC_LAND = true; private static final boolean GENERATE_RANDOM_BASIC_LAND = true;
private static final int MAX_TRIES = 4096; private static final int MAX_TRIES = 4096;
private static Deck deck = new Deck(); private static Deck deck = new Deck();
private static final int ADDITIONAL_CARDS_FOR_3_COLOR_DECKS = 20; private static final int ADDITIONAL_CARDS_FOR_3_COLOR_DECKS = 20;
private static String colors = "GWUBR"; private static String colors = "GWUBR";
/** /**
* Opens color chooser dialog. Generates deck. * Opens color chooser dialog. Generates deck.
* Saves generated deck and use it as selected deck to play. * Saves generated deck and use it as selected deck to play.
@ -55,33 +55,33 @@ public class DeckGenerator {
public static String generateDeck() { public static String generateDeck() {
JPanel p0 = new JPanel(); JPanel p0 = new JPanel();
p0.setLayout(new BoxLayout(p0, BoxLayout.Y_AXIS)); p0.setLayout(new BoxLayout(p0, BoxLayout.Y_AXIS));
JLabel text = new JLabel("Choose color for your deck: "); JLabel text = new JLabel("Choose color for your deck: ");
text.setAlignmentX(Component.CENTER_ALIGNMENT); text.setAlignmentX(Component.CENTER_ALIGNMENT);
p0.add(text); p0.add(text);
p0.add(Box.createVerticalStrut(5)); p0.add(Box.createVerticalStrut(5));
String chosen = MageFrame.getPreferences().get("genDeckColor", "u"); String chosen = MageFrame.getPreferences().get("genDeckColor", "u");
final ColorsChooser colorsChooser = new ColorsChooser(chosen); final ColorsChooser colorsChooser = new ColorsChooser(chosen);
p0.add(colorsChooser); p0.add(colorsChooser);
p0.add(Box.createVerticalStrut(5)); p0.add(Box.createVerticalStrut(5));
JLabel text2 = new JLabel("(X - random color)"); JLabel text2 = new JLabel("(X - random color)");
text2.setAlignmentX(Component.CENTER_ALIGNMENT); text2.setAlignmentX(Component.CENTER_ALIGNMENT);
p0.add(text2); p0.add(text2);
p0.add(Box.createVerticalStrut(5)); p0.add(Box.createVerticalStrut(5));
JPanel jPanel = new JPanel(); JPanel jPanel = new JPanel();
JLabel text3 = new JLabel("Choose format:"); JLabel text3 = new JLabel("Choose format:");
formats = new JComboBox(ConstructedFormats.getTypes()); formats = new JComboBox(ConstructedFormats.getTypes());
formats.setSelectedIndex(0); formats.setSelectedIndex(0);
formats.setPreferredSize(new Dimension(100, 25)); formats.setPreferredSize(new Dimension(300, 25));
formats.setMaximumSize(new Dimension(100, 25)); formats.setMaximumSize(new Dimension(300, 25));
formats.setAlignmentX(Component.LEFT_ALIGNMENT); formats.setAlignmentX(Component.LEFT_ALIGNMENT);
jPanel.add(text3); jPanel.add(text3);
jPanel.add(formats); jPanel.add(formats);
p0.add(jPanel); p0.add(jPanel);
final JButton btnGenerate = new JButton("Ok"); final JButton btnGenerate = new JButton("Ok");
btnGenerate.addActionListener(new ActionListener() { btnGenerate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -104,7 +104,7 @@ public class DeckGenerator {
dlg = optionPane.createDialog("Generating deck"); dlg = optionPane.createDialog("Generating deck");
dlg.setVisible(true); dlg.setVisible(true);
dlg.dispose(); dlg.dispose();
if (selectedColors != null) { if (selectedColors != null) {
buildDeck(); buildDeck();
try { try {
@ -119,44 +119,44 @@ public class DeckGenerator {
JOptionPane.showMessageDialog(null, "Couldn't generate deck. Try once again."); JOptionPane.showMessageDialog(null, "Couldn't generate deck. Try once again.");
} }
} }
return selectedColors; return selectedColors;
} }
/** /**
* Generates card pool * Generates card pool
*/ */
protected static void buildDeck() { protected static void buildDeck() {
List<ColoredManaSymbol> allowedColors = new ArrayList<ColoredManaSymbol>(); List<ColoredManaSymbol> allowedColors = new ArrayList<ColoredManaSymbol>();
selectedColors = selectedColors.toUpperCase(); selectedColors = selectedColors.toUpperCase();
String format = (String)formats.getSelectedItem(); String format = (String)formats.getSelectedItem();
List<String> setsToUse = ConstructedFormats.getSetsByFormat(format); List<String> setsToUse = ConstructedFormats.getSetsByFormat(format);
if (setsToUse.isEmpty()) { if (setsToUse.isEmpty()) {
// use all // use all
setsToUse = CardsStorage.getSetCodes(); setsToUse = CardsStorage.getSetCodes();
} }
if (selectedColors.contains("X")) { if (selectedColors.contains("X")) {
selectedColors = getRandomColors(selectedColors); selectedColors = getRandomColors(selectedColors);
} }
for (int i = 0; i < selectedColors.length(); i++) { for (int i = 0; i < selectedColors.length(); i++) {
char c = selectedColors.charAt(i); char c = selectedColors.charAt(i);
allowedColors.add(ColoredManaSymbol.lookup(c)); allowedColors.add(ColoredManaSymbol.lookup(c));
} }
int cardPoolSize = SPELL_CARD_POOL_SIZE; int cardPoolSize = SPELL_CARD_POOL_SIZE;
if (selectedColors.length() > 2) { if (selectedColors.length() > 2) {
cardPoolSize += ADDITIONAL_CARDS_FOR_3_COLOR_DECKS; cardPoolSize += ADDITIONAL_CARDS_FOR_3_COLOR_DECKS;
} }
List<Card> spellCardPool = generateSpellCardPool(cardPoolSize, allowedColors, setsToUse); List<Card> spellCardPool = generateSpellCardPool(cardPoolSize, allowedColors, setsToUse);
List<Card> landCardPool = generateNonBasicLandCardPool(MAX_NON_BASIC_SOURCE, allowedColors, setsToUse); List<Card> landCardPool = generateNonBasicLandCardPool(MAX_NON_BASIC_SOURCE, allowedColors, setsToUse);
System.out.println("deck generator card pool: spells=" + spellCardPool.size() + ", lands=" + landCardPool.size()); System.out.println("deck generator card pool: spells=" + spellCardPool.size() + ", lands=" + landCardPool.size());
final List<String> setsToUseFinal = setsToUse; final List<String> setsToUseFinal = setsToUse;
deck = DeckBuilder.buildDeck(spellCardPool, allowedColors, landCardPool, new RateCallback() { deck = DeckBuilder.buildDeck(spellCardPool, allowedColors, landCardPool, new RateCallback() {
@Override @Override
public int rateCard(Card card) { public int rateCard(Card card) {
@ -175,7 +175,7 @@ public class DeckGenerator {
} }
}); });
} }
private static String getRandomColors(String _selectedColors) { private static String getRandomColors(String _selectedColors) {
StringBuilder generatedColors = new StringBuilder(); StringBuilder generatedColors = new StringBuilder();
Set<String> colors = new HashSet<String>(); Set<String> colors = new HashSet<String>();
@ -192,12 +192,12 @@ public class DeckGenerator {
} }
return generatedColors.toString(); return generatedColors.toString();
} }
private static char getRandomColor() { private static char getRandomColor() {
Random r = new Random(); Random r = new Random();
return colors.charAt(r.nextInt(colors.length())); return colors.charAt(r.nextInt(colors.length()));
} }
/** /**
* Generates card pool of cardsCount cards that have manacost of allowed colors. * Generates card pool of cardsCount cards that have manacost of allowed colors.
* *
@ -207,7 +207,7 @@ public class DeckGenerator {
*/ */
private static List<Card> generateSpellCardPool(int cardsCount, List<ColoredManaSymbol> allowedColors, List<String> setsToUse) { private static List<Card> generateSpellCardPool(int cardsCount, List<ColoredManaSymbol> allowedColors, List<String> setsToUse) {
List<Card> spellCardPool = new ArrayList<Card>(); List<Card> spellCardPool = new ArrayList<Card>();
int count = 0; int count = 0;
List<Card> cardPool = new ArrayList<Card>(); List<Card> cardPool = new ArrayList<Card>();
for (Card card : CardsStorage.getAllCards()) { for (Card card : CardsStorage.getAllCards()) {
@ -235,10 +235,10 @@ public class DeckGenerator {
} else { } else {
throw new IllegalStateException("Not enough cards to generate deck."); throw new IllegalStateException("Not enough cards to generate deck.");
} }
return spellCardPool; return spellCardPool;
} }
/** /**
* Check that card can be played using chosen (allowed) colors. * Check that card can be played using chosen (allowed) colors.
* *
@ -264,7 +264,7 @@ public class DeckGenerator {
} }
return true; return true;
} }
/** /**
* Generates card pool of land cards that can produce allowed colors. * Generates card pool of land cards that can produce allowed colors.
* *
@ -274,7 +274,7 @@ public class DeckGenerator {
*/ */
private static List<Card> generateNonBasicLandCardPool(int landsCount, List<ColoredManaSymbol> allowedColors, List<String> setsToUse) { private static List<Card> generateNonBasicLandCardPool(int landsCount, List<ColoredManaSymbol> allowedColors, List<String> setsToUse) {
List<Card> nonBasicLandCardPool = new ArrayList<Card>(); List<Card> nonBasicLandCardPool = new ArrayList<Card>();
int count = 0; int count = 0;
List<Card> landCards = new ArrayList<Card>(); List<Card> landCards = new ArrayList<Card>();
for (Card land : CardsStorage.getNonBasicLandCards()) { for (Card land : CardsStorage.getNonBasicLandCards()) {
@ -301,10 +301,10 @@ public class DeckGenerator {
} }
} }
} }
return nonBasicLandCardPool; return nonBasicLandCardPool;
} }
/** /**
* Checks that chosen card can produce mana of specific color. * Checks that chosen card can produce mana of specific color.
* *
@ -324,7 +324,7 @@ public class DeckGenerator {
} }
return false; return false;
} }
/** /**
* Get random basic land that can produce specified color mana. * Get random basic land that can produce specified color mana.
* Random here means random set and collector id for the same mana producing land. * Random here means random set and collector id for the same mana producing land.
@ -348,14 +348,14 @@ public class DeckGenerator {
if (color.equals(ColoredManaSymbol.W)) { if (color.equals(ColoredManaSymbol.W)) {
return Sets.findCard("Plains", GENERATE_RANDOM_BASIC_LAND); return Sets.findCard("Plains", GENERATE_RANDOM_BASIC_LAND);
} }
return null; return null;
} }
protected static boolean isColoredMana(String symbol) { protected static boolean isColoredMana(String symbol) {
return symbol.equals("W") || symbol.equals("G") || symbol.equals("U") || symbol.equals("B") || symbol.equals("R") || symbol.contains("/"); return symbol.equals("W") || symbol.equals("G") || symbol.equals("U") || symbol.equals("B") || symbol.equals("R") || symbol.contains("/");
} }
public static void main(String[] args) { public static void main(String[] args) {
Card selesnyaGuildMage = null; Card selesnyaGuildMage = null;
for (Card card : CardsStorage.getAllCards()) { for (Card card : CardsStorage.getAllCards()) {
@ -371,15 +371,15 @@ public class DeckGenerator {
allowedColors.add(ColoredManaSymbol.lookup('B')); allowedColors.add(ColoredManaSymbol.lookup('B'));
allowedColors.add(ColoredManaSymbol.lookup('R')); allowedColors.add(ColoredManaSymbol.lookup('R'));
System.out.println(DeckGenerator.cardFitsChosenColors(selesnyaGuildMage, allowedColors)); System.out.println(DeckGenerator.cardFitsChosenColors(selesnyaGuildMage, allowedColors));
allowedColors.clear(); allowedColors.clear();
allowedColors = new ArrayList<ColoredManaSymbol>(); allowedColors = new ArrayList<ColoredManaSymbol>();
allowedColors.add(ColoredManaSymbol.lookup('G')); allowedColors.add(ColoredManaSymbol.lookup('G'));
System.out.println(DeckGenerator.cardFitsChosenColors(selesnyaGuildMage, allowedColors)); System.out.println(DeckGenerator.cardFitsChosenColors(selesnyaGuildMage, allowedColors));
allowedColors.clear(); allowedColors.clear();
allowedColors = new ArrayList<ColoredManaSymbol>(); allowedColors = new ArrayList<ColoredManaSymbol>();
allowedColors.add(ColoredManaSymbol.lookup('W')); allowedColors.add(ColoredManaSymbol.lookup('W'));
System.out.println(DeckGenerator.cardFitsChosenColors(selesnyaGuildMage, allowedColors)); System.out.println(DeckGenerator.cardFitsChosenColors(selesnyaGuildMage, allowedColors));
} }
} }

View file

@ -157,9 +157,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
this.btnBooster.setVisible(true); this.btnBooster.setVisible(true);
this.btnClear.setVisible(true); this.btnClear.setVisible(true);
this.cbExpansionSet.setVisible(true); this.cbExpansionSet.setVisible(true);
cbExpansionSet.setModel(new DefaultComboBoxModel(Sets.getInstance().getSortedByReleaseDate())); cbExpansionSet.setModel(new DefaultComboBoxModel(ConstructedFormats.getTypes()));
cbExpansionSet.insertItemAt("-- All sets", 0);
cbExpansionSet.insertItemAt("-- Standard", 1);
cbExpansionSet.setSelectedIndex(0); cbExpansionSet.setSelectedIndex(0);
filterCards(); filterCards();
@ -216,14 +214,15 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
String name = jTextFieldSearch.getText().trim(); String name = jTextFieldSearch.getText().trim();
filter.add(new CardTextPredicate(name)); filter.add(new CardTextPredicate(name));
if (this.cbExpansionSet.getSelectedItem() instanceof ExpansionSet) { if (this.cbExpansionSet.isVisible()) {
filter.add(new ExpansionSetPredicate(((ExpansionSet) this.cbExpansionSet.getSelectedItem()).getCode())); String expansionSelection = this.cbExpansionSet.getSelectedItem().toString();
} else if (this.cbExpansionSet.getSelectedItem().equals("-- Standard")) { if (!expansionSelection.equals("- All Sets")) {
ArrayList<Predicate<Card>> expansionPredicates = new ArrayList<Predicate<Card>>(); ArrayList<Predicate<Card>> expansionPredicates = new ArrayList<Predicate<Card>>();
for (String setCode : ConstructedFormats.getSetsByFormat("Standard")) { for (String setCode : ConstructedFormats.getSetsByFormat(expansionSelection)) {
expansionPredicates.add(new ExpansionSetPredicate(setCode)); expansionPredicates.add(new ExpansionSetPredicate(setCode));
}
filter.add(Predicates.or(expansionPredicates));
} }
filter.add(Predicates.or(expansionPredicates));
} }
} }
@ -411,7 +410,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}); });
tbColor.add(rdoColorless); tbColor.add(rdoColorless);
cbExpansionSet.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"})); cbExpansionSet.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbExpansionSet.addActionListener(new java.awt.event.ActionListener() { cbExpansionSet.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
cbExpansionSetActionPerformed(evt); cbExpansionSetActionPerformed(evt);
@ -539,7 +538,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}); });
tbTypes.add(chkPiles); tbTypes.add(chkPiles);
cbSortBy.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"})); cbSortBy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbSortBy.addActionListener(new java.awt.event.ActionListener() { cbSortBy.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
cbSortByActionPerformed(evt); cbSortByActionPerformed(evt);
@ -605,8 +604,10 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
} }
}); });
cardCountLabel.setForeground(java.awt.SystemColor.textHighlightText);
cardCountLabel.setText("Card count:"); cardCountLabel.setText("Card count:");
cardCount.setForeground(java.awt.SystemColor.text);
cardCount.setText("0"); cardCount.setText("0");
jButtonRemoveFromMain.setText("-"); jButtonRemoveFromMain.setText("-");
@ -649,7 +650,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
.addComponent(cardCountLabel) .addComponent(cardCountLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cardCount, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cardCount, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(186, Short.MAX_VALUE)) .addContainerGap(121, Short.MAX_VALUE))
); );
jPanel1Layout.setVerticalGroup( jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -690,7 +691,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents

View file

@ -69,20 +69,23 @@ public final class CollectionViewerPanel extends JPanel {
JLabel label1 = new JLabel("Choose format:"); JLabel label1 = new JLabel("Choose format:");
label1.setAlignmentX(Component.LEFT_ALIGNMENT); label1.setAlignmentX(Component.LEFT_ALIGNMENT);
label1.setForeground(Color.white);
jPanel1.add(label1); jPanel1.add(label1);
formats = new JComboBox(ConstructedFormats.getTypes()); formats = new JComboBox(ConstructedFormats.getTypes());
formats.setSelectedItem(ConstructedFormats.getDefault()); formats.setSelectedItem(ConstructedFormats.getDefault());
formats.setPreferredSize(new Dimension(100, 25)); formats.setPreferredSize(new Dimension(250, 25));
formats.setMaximumSize(new Dimension(100, 25)); formats.setMaximumSize(new Dimension(250, 25));
formats.setAlignmentX(Component.LEFT_ALIGNMENT); formats.setAlignmentX(Component.LEFT_ALIGNMENT);
jPanel1.add(formats); jPanel1.add(formats);
JLabel label2 = new JLabel("Choose size:"); JLabel label2 = new JLabel("Choose size:");
label2.setAlignmentX(Component.LEFT_ALIGNMENT); label2.setAlignmentX(Component.LEFT_ALIGNMENT);
label2.setForeground(Color.white);
jPanel1.add(label2); jPanel1.add(label2);
small3x3 = new JRadioButton("3x3"); small3x3 = new JRadioButton("3x3");
small3x3.setForeground(Color.white);
boolean selected3x3 = MageFrame.getPreferences().get(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3x3).equals(MageBook.LAYOUT_3x3); boolean selected3x3 = MageFrame.getPreferences().get(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3x3).equals(MageBook.LAYOUT_3x3);
small3x3.setSelected(selected3x3); small3x3.setSelected(selected3x3);
small3x3.addActionListener(new ActionListener() { small3x3.addActionListener(new ActionListener() {
@ -96,6 +99,7 @@ public final class CollectionViewerPanel extends JPanel {
jPanel1.add(small3x3); jPanel1.add(small3x3);
big4x4 = new JRadioButton("4x4"); big4x4 = new JRadioButton("4x4");
big4x4.setForeground(Color.white);
big4x4.setSelected(!selected3x3); big4x4.setSelected(!selected3x3);
big4x4.addActionListener(new ActionListener() { big4x4.addActionListener(new ActionListener() {
@Override @Override
@ -109,6 +113,7 @@ public final class CollectionViewerPanel extends JPanel {
JLabel label3 = new JLabel("Switch tabs:"); JLabel label3 = new JLabel("Switch tabs:");
label3.setAlignmentX(Component.LEFT_ALIGNMENT); label3.setAlignmentX(Component.LEFT_ALIGNMENT);
label3.setForeground(Color.white);
jPanel1.add(label3); jPanel1.add(label3);
JPanel buttonPanel = new JPanel(); JPanel buttonPanel = new JPanel();

View file

@ -291,6 +291,7 @@ public class MageBook extends JComponent {
this.setsToDisplay = CardsStorage.getSetCodes(); this.setsToDisplay = CardsStorage.getSetCodes();
} }
addSetTabs(); addSetTabs();
tabs.get(0).execute();
} }
public void next() { public void next() {

View file

@ -1,13 +1,13 @@
package mage.client.util.sets; package mage.client.util.sets;
import mage.cards.ExpansionSet;
import mage.client.cards.CardsStorage;
import mage.sets.Sets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import mage.cards.ExpansionSet;
import mage.client.cards.CardsStorage;
import mage.sets.Sets;
/** /**
* Utility class for constructed formats. * Utility class for constructed formats.
@ -16,8 +16,31 @@ import java.util.List;
*/ */
public class ConstructedFormats { public class ConstructedFormats {
private static final String[] constructedFormats = {"M13", "ISD\\DKA\\AVR", "Standard", "Extended", "Modern", "All"}; private static final String[] constructedFormats = {"- All Sets", "- Standard", "- Extended", "- Modern",
"* Return to Ravnica Block", "Return to Ravnica", "Magic 2013",
"* Innistrad Block", "Avacyn Restored", "Dark Ascension", "Innistrad", "Magic 2012",
"* Scars of Mirrodin Block", "New Phyrexia", "Mirrodin Besieged", "Scars of Mirrodin", "Magic 2011",
"* Zendikar Block", "Rise of the Eldrazi", "Worldwake", "Zendikar", "Magic 2010",
"* Shards of Alara Block", "Alara Reborn", "Conflux", "Shards of Alara",
"* Shadowmoor Block", "Shadowmoor", "Eventide",
"* Lorwyn Block", "Lorwyn", "Morningtide",
"* Time Spiral Block", "Future Sight", "Planar Chaos", "Time Spiral", "Tenth Edition",
"* Ravnica Block", "Dissension", "Guildpact", "Ravnica: City of Guilds",
"* Kamigawa Block", "Saviors of Kamigawa", "Betrayers of Kamigawa", "Champions of Kamigawa","Ninth Edition",
"* Mirrodin Block", "Fifth Dawn", "Darksteel", "Mirrodin",
"* Onslaught Block", "Scourge", "Legions", "Onslaught","Eighth Edition",
"* Odyssey Block", "Judgment", "Torment", "Odyssey",
"* Invasion Block", "Apocalypse", "Planeshift", "Invasion","Seventh Edition",
"* Masquerade Block", "Prophecy", "Nemesis", "Mercadian Masques",
"* Urza Block", "Urza's Destiny", "Urza's Legacy", "Urza's Saga", "Sixth Edition",
"* Tempest Block", "Exodus", "Stronghold", "Tempest",
"* Mirage Block", "Weatherlight", "Visions", "Mirage", "Fifth Edition",
"* Ice Age Block", "Coldsnap", "Alliances", "Ice Age", "Fourth Edition",
"Homelands","Fallen Empires","The Dark","Legends","Antiquities", "Arabian Nights",
"Guru",
"Duel Decks: Elspeth vs. Tezzeret"
};
private ConstructedFormats() { private ConstructedFormats() {
} }
@ -30,33 +53,301 @@ public class ConstructedFormats {
} }
public static List<String> getSetsByFormat(String format) { public static List<String> getSetsByFormat(String format) {
if (format.equals("M13")) {
return m13; if (format.equals("Arabian Nights")) {
return Arrays.asList("ARN");
} }
if (format.equals("ISD\\DKA\\AVR")) { if (format.equals("Antiquities")) {
return innistradBlock; return Arrays.asList("ATQ");
} }
if (format.equals("Standard")) { if (format.equals("Legends")) {
return Arrays.asList("LEG");
}
if (format.equals("The Dark")) {
return Arrays.asList("DRK");
}
if (format.equals("Fallen Empires")) {
return Arrays.asList("FEM");
}
if (format.equals("Homelands")) {
return Arrays.asList("HML");
}
if (format.equals("* Ice Age Block")) {
return Arrays.asList("ICE", "ALL", "CSP");
}
if (format.equals("Ice Age")) {
return Arrays.asList("ICE");
}
if (format.equals("Alliances")) {
return Arrays.asList("ALL");
}
if (format.equals("Coldsnap")) {
return Arrays.asList("CSP");
}
if (format.equals("* Mirage Block")) {
return Arrays.asList("MIR", "VIS", "WTH");
}
if (format.equals("Mirage")) {
return Arrays.asList("MIR");
}
if (format.equals("Visions")) {
return Arrays.asList("VIS");
}
if (format.equals("Weatherlight")) {
return Arrays.asList("WTH");
}
if (format.equals("* Tempest Block")) {
return Arrays.asList("TMP", "STH", "EXO");
}
if (format.equals("Tempest")) {
return Arrays.asList("TMP");
}
if (format.equals("Stronghold")) {
return Arrays.asList("STH");
}
if (format.equals("Exodus")) {
return Arrays.asList("EXO");
}
if (format.equals("* Urza Block")) {
return Arrays.asList("USG", "ULG", "UDS");
}
if (format.equals("Urza's Saga")) {
return Arrays.asList("USG");
}
if (format.equals("Urza's Legacy")) {
return Arrays.asList("ULG");
}
if (format.equals("Urza's Destiny")) {
return Arrays.asList("UDS");
}
if (format.equals("* Masquerade Block")) {
return Arrays.asList("MMQ", "NMS", "PCY");
}
if (format.equals("Mercadian Masques")) {
return Arrays.asList("MMQ");
}
if (format.equals("Nemesis")) {
return Arrays.asList("NMS");
}
if (format.equals("Prophecy")) {
return Arrays.asList("PCY");
}
if (format.equals("* Invasion Block")) {
return Arrays.asList("INV", "PLS", "APC");
}
if (format.equals("Invasion")) {
return Arrays.asList("INV");
}
if (format.equals("Planeshift")) {
return Arrays.asList("PLS");
}
if (format.equals("Apocalypse")) {
return Arrays.asList("APC");
}
if (format.equals("* Odyssey Block")) {
return Arrays.asList("ODY", "TOR", "JUD");
}
if (format.equals("Odyssey")) {
return Arrays.asList("ODY");
}
if (format.equals("Torment")) {
return Arrays.asList("TOR");
}
if (format.equals("Judgment")) {
return Arrays.asList("JUD");
}
if (format.equals("* Onslaught Block")) {
return Arrays.asList("ONS", "LGN", "SCG");
}
if (format.equals("Onslaught")) {
return Arrays.asList("ONS");
}
if (format.equals("Legions")) {
return Arrays.asList("LGN");
}
if (format.equals("Scourge")) {
return Arrays.asList("SCG");
}
if (format.equals("* Mirrodin Block")) {
return Arrays.asList("MRD", "DST", "5DN");
}
if (format.equals("Mirrodin")) {
return Arrays.asList("MRD");
}
if (format.equals("Darksteel")) {
return Arrays.asList("DST");
}
if (format.equals("Fifth Dawn")) {
return Arrays.asList("5DN");
}
if (format.equals("* Kamigawa Block")) {
return Arrays.asList("CHK", "BOK", "SOK");
}
if (format.equals("Champions of Kamigawa")) {
return Arrays.asList("CHK");
}
if (format.equals("Betrayers of Kamigawa")) {
return Arrays.asList("BOK");
}
if (format.equals("Saviors of Kamigawa")) {
return Arrays.asList("SOK");
}
if (format.equals("* Ravnica Block")) {
return Arrays.asList("RAV", "GPT", "DIS");
}
if (format.equals("Ravnica: City of Guilds")) {
return Arrays.asList("RAV");
}
if (format.equals("Guildpact")) {
return Arrays.asList("GPT");
}
if (format.equals("Dissension")) {
return Arrays.asList("DIS");
}
if (format.equals("* Time Spiral Block")) {
return Arrays.asList("TSP", "TSB", "PLC", "FUT");
}
if (format.equals("Time Spiral")) {
return Arrays.asList("TSP", "TSB");
}
if (format.equals("Planar Chaos")) {
return Arrays.asList("PLC");
}
if (format.equals("Future Sight")) {
return Arrays.asList("FUT");
}
if (format.equals("* Lorwyn Block")) {
return Arrays.asList("LRW", "MOR");
}
if (format.equals("Lorwyn")) {
return Arrays.asList("LRW");
}
if (format.equals("Morningtide")) {
return Arrays.asList("MOR");
}
if (format.equals("* Shadowmoor Block")) {
return Arrays.asList("SHM", "EVE");
}
if (format.equals("Shadowmoor")) {
return Arrays.asList("SHM");
}
if (format.equals("Eventide")) {
return Arrays.asList("EVE");
}
if (format.equals("* Shards of Alara Block")) {
return Arrays.asList("ALA", "CON", "ARB");
}
if (format.equals("Alara Reborn")) {
return Arrays.asList("ALA");
}
if (format.equals("Conflux")) {
return Arrays.asList("CON");
}
if (format.equals("Shards of Alara")) {
return Arrays.asList("ARB");
}
if (format.equals("* Zendikar Block")) {
return Arrays.asList("ZEN", "WWK", "ROE");
}
if (format.equals("Zendikar")) {
return Arrays.asList("ZEN");
}
if (format.equals("Worldwake")) {
return Arrays.asList("WWK");
}
if (format.equals("Rise of the Eldrazi")) {
return Arrays.asList("ROE");
}
if (format.equals("* Scars of Mirrodin Block")) {
return Arrays.asList("SOM", "MBS", "NPH");
}
if (format.equals("Scars of Mirrodin")) {
return Arrays.asList("SOM");
}
if (format.equals("Mirrodin Besieged")) {
return Arrays.asList("MBS");
}
if (format.equals("New Phyrexia")) {
return Arrays.asList("NPH");
}
if (format.equals("* Innistrad Block")) {
return Arrays.asList("ISD", "DKA", "AVR");
}
if (format.equals("Innistrad")) {
return Arrays.asList("ISD");
}
if (format.equals("Dark Ascension")) {
return Arrays.asList("DKA");
}
if (format.equals("Avacyn Restored")) {
return Arrays.asList("AVR");
}
if (format.equals("* Return to Ravnica Block")) {
return Arrays.asList("RTR");
}
if (format.equals("Return to Ravnica")) {
return Arrays.asList("RTR");
}
if (format.equals("Fourth Edition")) {
return Arrays.asList("4ED");
}
if (format.equals("Fifth Edition")) {
return Arrays.asList("5ED");
}
if (format.equals("Sixth Edition")) {
return Arrays.asList("6ED");
}
if (format.equals("Seventh Edition")) {
return Arrays.asList("7ED");
}
if (format.equals("Eighth Edition")) {
return Arrays.asList("8ED");
}
if (format.equals("Ninth Edition")) {
return Arrays.asList("9ED");
}
if (format.equals("Tenth Edition")) {
return Arrays.asList("10E");
}
if (format.equals("Magic 2010")) {
return Arrays.asList("M10");
}
if (format.equals("Magic 2011")) {
return Arrays.asList("M11");
}
if (format.equals("Magic 2012")) {
return Arrays.asList("M12");
}
if (format.equals("Magic 2013")) {
return Arrays.asList("M13");
}
if (format.equals("Guru")) {
return Arrays.asList("GUR");
}
if (format.equals("Duel Decks: Elspeth vs. Tezzeret")) {
return Arrays.asList("DDF");
}
if (format.equals("- Standard")) {
return standard; return standard;
} }
if (format.equals("Extended")) { if (format.equals("- Extended")) {
return extended; return extended;
} }
if (format.equals("Modern")) { if (format.equals("- Modern")) {
return modern; return modern;
} }
return all; return all;
} }
private static void buildLists() { private static void buildLists() {
for (String setCode : CardsStorage.getSetCodes()) { for (String setCode : CardsStorage.getSetCodes()) {
ExpansionSet set = Sets.findSet(setCode); ExpansionSet set = Sets.findSet(setCode);
if (set.getReleaseDate().after(m13Date)) {
m13.add(set.getCode());
}
if (set.getReleaseDate().after(innistradBlockDate) && set.getReleaseDate().before(m13Date)) {
innistradBlock.add(set.getCode());
}
if (set.getReleaseDate().after(standardDate)) { if (set.getReleaseDate().after(standardDate)) {
standard.add(set.getCode()); standard.add(set.getCode());
} }
@ -68,18 +359,12 @@ public class ConstructedFormats {
} }
} }
} }
private static final List<String> m13= new ArrayList<String>();
private static final Date m13Date = new GregorianCalendar(2012, 6, 6).getTime();
private static final List<String> innistradBlock = new ArrayList<String>();
private static final Date innistradBlockDate = new GregorianCalendar(2011, 9, 29).getTime();
private static final List<String> standard = new ArrayList<String>(); private static final List<String> standard = new ArrayList<String>();
private static final Date standardDate = new GregorianCalendar(2010, 9, 20).getTime(); private static final Date standardDate = new GregorianCalendar(2011, 9, 29).getTime();
private static final List<String> extended = new ArrayList<String>(); private static final List<String> extended = new ArrayList<String>();
private static final Date extendedDate = new GregorianCalendar(2008, 9, 20).getTime(); private static final Date extendedDate = new GregorianCalendar(2009, 8, 20).getTime();
private static final List<String> modern = new ArrayList<String>(); private static final List<String> modern = new ArrayList<String>();
private static final Date modernDate = new GregorianCalendar(2003, 7, 20).getTime(); private static final Date modernDate = new GregorianCalendar(2003, 7, 20).getTime();