diff --git a/Mage.Client/src/main/java/mage/client/deck/generator/DeckGenerator.java b/Mage.Client/src/main/java/mage/client/deck/generator/DeckGenerator.java index 4c5c006cc3..55fba392e7 100644 --- a/Mage.Client/src/main/java/mage/client/deck/generator/DeckGenerator.java +++ b/Mage.Client/src/main/java/mage/client/deck/generator/DeckGenerator.java @@ -420,7 +420,7 @@ public class DeckGenerator { if (landSets.isEmpty()) { for (String setCode :setsToUse) { ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode); - ExpansionInfo [] blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName()); + List blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName()); for (ExpansionInfo blockSet: blockSets) { if (blockSet.hasBasicLands()) { landSets.add(blockSet.getCode()); diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/CollectionViewerPanel.java b/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/CollectionViewerPanel.java index b22a59dd37..e0a43c0818 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/CollectionViewerPanel.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/CollectionViewerPanel.java @@ -91,7 +91,7 @@ public final class CollectionViewerPanel extends JPanel { label1.setForeground(Color.white); jPanel1.add(label1); - formats = new JComboBox(ConstructedFormats.getTypes()); + formats = new JComboBox<>(ConstructedFormats.getTypes()); formats.setSelectedItem(ConstructedFormats.getDefault()); formats.setPreferredSize(new Dimension(250, 25)); formats.setMaximumSize(new Dimension(250, 25)); diff --git a/Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java b/Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java index e8844de45b..1c4a9c2697 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java @@ -76,7 +76,7 @@ public class AddLandDialog extends MageDialog { for (String setCode :deck.getExpansionSetCodes()) { ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode); if (expansionInfo != null) { - ExpansionInfo [] blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName()); + List blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName()); for (ExpansionInfo blockSet: blockSets) { if (blockSet.hasBasicLands()) { this.setCodesland.add(blockSet.getCode()); diff --git a/Mage.Client/src/main/java/mage/client/util/sets/ConstructedFormats.java b/Mage.Client/src/main/java/mage/client/util/sets/ConstructedFormats.java index a33aed3355..5cd0fe2b2b 100644 --- a/Mage.Client/src/main/java/mage/client/util/sets/ConstructedFormats.java +++ b/Mage.Client/src/main/java/mage/client/util/sets/ConstructedFormats.java @@ -1,11 +1,15 @@ package mage.client.util.sets; import java.util.ArrayList; -import java.util.Arrays; import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; import java.util.Date; import java.util.GregorianCalendar; +import java.util.HashMap; import java.util.List; +import java.util.Map; + import mage.cards.repository.ExpansionInfo; import mage.cards.repository.ExpansionRepository; import mage.constants.SetType; @@ -18,599 +22,32 @@ import mage.constants.SetType; public class ConstructedFormats { private static final GregorianCalendar calendar = new GregorianCalendar(); - public static final String ALL = "- All Sets"; public static final String STANDARD = "- Standard"; public static final String EXTENDED = "- Extended"; public static final String MODERN = "- Modern"; - - private static final String[] constructedFormats = { - ALL, STANDARD, EXTENDED, MODERN, - "* Khans of Tarkir Block", "Khans of Tarkir", "Fate Reforged", "Dragons of Tarkir", - "* Theros Block", "Theros", "Born of the Gods", "Journey into Nyx", - "* Return to Ravnica Block", "Return to Ravnica", "Gatecrash", "Dragon's Maze", - "* Innistrad Block", "Innistrad", "Dark Ascension", "Avacyn Restored", - "* Scars of Mirrodin Block", "Scars of Mirrodin", "Mirrodin Besieged", "New Phyrexia", - "* Zendikar Block", "Zendikar", "Worldwake", "Rise of the Eldrazi", - "* Shards of Alara Block", "Shards of Alara", "Conflux", "Alara Reborn", - "* Shadowmoor Block", "Shadowmoor", "Eventide", - "* Lorwyn Block", "Lorwyn", "Morningtide", - "* Time Spiral Block", "Time Spiral", "Planar Chaos", "Future Sight", - "* Ravnica Block", "Ravnica: City of Guilds", "Guildpact", "Dissension", - "* Kamigawa Block", "Champions of Kamigawa", "Betrayers of Kamigawa", "Saviors of Kamigawa", - "* Mirrodin Block", "Mirrodin", "Darksteel", "Fifth Dawn", - "* Onslaught Block", "Onslaught", "Legions", "Scourge", - "* Odyssey Block", "Odyssey", "Torment", "Judgment", - "* Invasion Block", "Invasion", "Planeshift", "Apocalypse", - "* Masquerade Block", "Mercadian Masques", "Nemesis", "Prophecy", - "* Urza Block", "Urza's Saga", "Urza's Legacy", "Urza's Destiny", - "* Tempest Block", "Tempest", "Stronghold", "Exodus", - "* Mirage Block", "Mirage", "Visions", "Weatherlight", - "* Ice Age Block", "Ice Age", "Alliances", "Coldsnap", - "Homelands", "Fallen Empires", "The Dark", "Legends", "Antiquities", "Arabian Nights", - "Magic Origins", - "Magic 2015", - "Magic 2014", - "Magic 2013", - "Magic 2012", - "Magic 2011", - "Magic 2010", - "Tenth Edition", - "Ninth Edition", - "Eighth Edition", - "Seventh Edition", - "Sixth Edition", - "Fifth Edition", - "Fourth Edition", - "Revised Edition", "Unlimited Edition", "Limited Edition Beta", "Limited Edition Alpha", - "Tempest Remastered", - "Vintage Masters", - "Conspiracy", - "Modern Masters 2015", - "Modern Masters", - "Masters Edition", - "Masters Edition II", - "Masters Edition III", - "Masters Edition IV", - "Archenemy", - "Commander 2014 Edition", - "Commander 2013 Edition", - "Commander", - "Planechase 2012", - "Planechase", - "Portal", "Portal Second Age", "Portal Three Kingdoms","Starter 1999","Starter 2000", - - "Duel Decks: Anthology, Divine vs. Demonic", - "Duel Decks: Anthology, Elves vs. Goblins", - "Duel Decks: Anthology, Garruk vs. Liliana", - "Duel Decks: Anthology, Jace vs. Chandra", - "Duel Decks: Ajani vs. Nicol Bolas", - "Duel Decks: Divine vs. Demonic", - "Duel Decks: Elspeth vs. Kiora", - "Duel Decks: Elspeth vs. Tezzeret", - "Duel Decks: Elves vs. Goblins", - "Duel Decks: Garruk vs. Liliana", - "Duel Decks: Heroes vs. Monsters", - "Duel Decks: Izzet vs. Golgari", - "Duel Decks: Jace vs. Chandra", - "Duel Decks: Jace vs. Vraska", - "Duel Decks: Knights vs. Dragons", - "Duel Decks: Phyrexia vs. the Coalition", - "Duel Decks: Sorin vs. Tibalt", - "Duel Decks: Speed vs. Cunning", - "Duel Decks: Venser vs. Koth", - - "Friday Night Magic", - "Game Day", - "Grand Prix", - "Guru", - "Judge Promo", - "Launch Party", - "Media Inserts", - "Magic Player Rewards", - "Prerelease Events", - "Unhinged", - "World Magic Cup Qualifier", - "WPN Gateway", - }; + private static final Map> underlyingSetCodesPerFormat = new HashMap<>(); + private static final List formats = new ArrayList(); + private ConstructedFormats() { } public static String[] getTypes() { - return constructedFormats; + return formats.toArray(new String[0]); } public static String getDefault() { - return constructedFormats[1]; + return STANDARD; } - - public static List getSetsByFormat(String format) { - if (format.equals("* Khans of Tarkir Block")) { - return Arrays.asList("KTK", "FRF", "DTK"); - } - if (format.equals("Dragons of Tarkir")) { - return Arrays.asList("DTK"); - } - if (format.equals("Fate Reforged")) { - return Arrays.asList("FRF"); - } - if (format.equals("Khans of Tarkir")) { - return Arrays.asList("KTK"); - } - if (format.equals("* Theros Block")) { - return Arrays.asList("THS", "BNG", "JOU"); - } - if (format.equals("Journey into Nyx")) { - return Arrays.asList("JOU"); - } - if (format.equals("Born of the Gods")) { - return Arrays.asList("BNG"); - } - if (format.equals("Theros")) { - return Arrays.asList("THS"); - } - if (format.equals("Arabian Nights")) { - return Arrays.asList("ARN"); - } - if (format.equals("Antiquities")) { - return Arrays.asList("ATQ"); - } - 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("ARB"); - } - if (format.equals("Conflux")) { - return Arrays.asList("CON"); - } - if (format.equals("Shards of Alara")) { - return Arrays.asList("ALA"); - } - 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", "GTC", "DGM"); - } - if (format.equals("Return to Ravnica")) { - return Arrays.asList("RTR"); - } - if (format.equals("Gatecrash")) { - return Arrays.asList("GTC"); - } - if (format.equals("Dragon's Maze")) { - return Arrays.asList("DGM"); - } - if (format.equals("Limited Edition Alpha")) { - return Arrays.asList("LEA"); - } - if (format.equals("Limited Edition Beta")) { - return Arrays.asList("LEB"); - } - if (format.equals("Unlimited Edition")) { - return Arrays.asList("2ED"); - } - if (format.equals("Revised Edition")) { - return Arrays.asList("3ED"); - } - 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("Magic 2014")) { - return Arrays.asList("M14"); - } - if (format.equals("Magic 2015")) { - return Arrays.asList("M15"); - } - if (format.equals("Magic Origins")) { - return Arrays.asList("ORI"); - } - if (format.equals("Archenemy")) { - return Arrays.asList("ARC"); - } - if (format.equals("Planechase")) { - return Arrays.asList("HOP"); - } - if (format.equals("Commander")) { - return Arrays.asList("CMD"); - } - if (format.equals("Commander 2013 Edition")) { - return Arrays.asList("C13"); - } - if (format.equals("Commander 2014 Edition")) { - return Arrays.asList("C14"); - } - if (format.equals("Planechase 2012")) { - return Arrays.asList("PC2"); - } - if (format.equals("Tempest Remastered")) { - return Arrays.asList("TPR"); - } - if (format.equals("Modern Masters")) { - return Arrays.asList("MMA"); - } - if (format.equals("Modern Masters 2015")) { - return Arrays.asList("MMB"); - } - if (format.equals("Masters Edition")) { - return Arrays.asList("MED"); - } - if (format.equals("Masters Edition II")) { - return Arrays.asList("ME2"); - } - if (format.equals("Masters Edition III")) { - return Arrays.asList("ME3"); - } - if (format.equals("Masters Edition IV")) { - return Arrays.asList("ME4"); - } - if (format.equals("Conspiracy")) { - return Arrays.asList("CNS"); - } - if (format.equals("Vintage Masters")) { - return Arrays.asList("VMA"); - } - if (format.equals("Friday Night Magic")) { - return Arrays.asList("FNMP"); - } - if (format.equals("Game Day")) { - return Arrays.asList("MGDC"); - } - if (format.equals("Grand Prix")) { - return Arrays.asList("GPX"); - } - if (format.equals("Launch Party")) { - return Arrays.asList("MLP"); - } - if (format.equals("Magic Player Rewards")) { - return Arrays.asList("MPRP"); - } - if (format.equals("Media Inserts")) { - return Arrays.asList("MBP"); - } - if (format.equals("Prerelease Events")) { - return Arrays.asList("PTC"); - } - if (format.equals("World Magic Cup Qualifier")) { - return Arrays.asList("WMCQ"); - } - if (format.equals("WPN Gateway")) { - return Arrays.asList("GRC"); - } - if (format.equals("Guru")) { - return Arrays.asList("GUR"); - } - if (format.equals("Judge Promo")) { - return Arrays.asList("JR"); - } - if (format.equals("Unhinged")) { - return Arrays.asList("UNH"); - } - if (format.equals("Portal")) { - return Arrays.asList("POR"); - } - if (format.equals("Portal Second Age")) { - return Arrays.asList("PO2"); - } - if (format.equals("Portal Three Kingdoms")) { - return Arrays.asList("PTK"); - } - if (format.equals("Starter 1999")) { - return Arrays.asList("S99"); - } - if (format.equals("Starter 2000")) { - return Arrays.asList("S00"); - } - if (format.equals("Duel Decks: Anthology, Divine vs. Demonic")) { - return Arrays.asList("DD3A"); - } - if (format.equals("Duel Decks: Anthology, Elves vs. Goblins")) { - return Arrays.asList("DD3B"); - } - if (format.equals("Duel Decks: Anthology, Garruk vs. Liliana")) { - return Arrays.asList("DD3C"); - } - if (format.equals("Duel Decks: Anthology, Jace vs. Chandra")) { - return Arrays.asList("DD3D"); - } - if (format.equals("Duel Decks: Elves vs. Goblins")) { - return Arrays.asList("EVG"); - } - if (format.equals("Duel Decks: Jace vs. Chandra")) { - return Arrays.asList("DD2"); - } - if (format.equals("Duel Decks: Divine vs. Demonic")) { - return Arrays.asList("DDC"); - } - if (format.equals("Duel Decks: Garruk vs. Liliana")) { - return Arrays.asList("DDD"); - } - if (format.equals("Duel Decks: Phyrexia vs. the Coalition")) { - return Arrays.asList("DDE"); - } - if (format.equals("Duel Decks: Elspeth vs. Kiora")) { - return Arrays.asList("DDO"); - } - if (format.equals("Duel Decks: Elspeth vs. Tezzeret")) { - return Arrays.asList("DDF"); - } - if (format.equals("Duel Decks: Knights vs. Dragons")) { - return Arrays.asList("DDG"); - } - if (format.equals("Duel Decks: Ajani vs. Nicol Bolas")) { - return Arrays.asList("DDH"); - } - if (format.equals("Duel Decks: Venser vs. Koth")) { - return Arrays.asList("DDI"); - } - if (format.equals("Duel Decks: Izzet vs. Golgari")) { - return Arrays.asList("DDJ"); - } - if (format.equals("Duel Decks: Sorin vs. Tibalt")) { - return Arrays.asList("DDK"); - } - if (format.equals("Duel Decks: Heroes vs. Monsters")) { - return Arrays.asList("DDL"); - } - if (format.equals("Duel Decks: Jace vs. Vraska")) { - return Arrays.asList("DDM"); - } - if (format.equals("Duel Decks: Speed vs. Cunning")) { - return Arrays.asList("DDN"); - } - - if (format.equals(STANDARD)) { - return standard; - } - if (format.equals(EXTENDED)) { - return extended; - } - if (format.equals(MODERN)) { - return modern; - } + + public static List getSetsByFormat(final String format) { + if(!format.equals(ALL)) { + return underlyingSetCodesPerFormat.get(format); + } return all; + } private static void buildLists() { @@ -622,28 +59,171 @@ public class ConstructedFormats { else { cutoff = new GregorianCalendar(calendar.get(Calendar.YEAR) - 2, Calendar.SEPTEMBER, 1); } - + final Map expansionInfo = new HashMap(); for (ExpansionInfo set : ExpansionRepository.instance.getAll()) { + expansionInfo.put(set.getName(), set); + formats.add(set.getName()); if (set.getType().equals(SetType.CORE) || set.getType().equals(SetType.EXPANSION)) { if (set.getReleaseDate().after(cutoff.getTime())) { - standard.add(set.getCode()); + if(underlyingSetCodesPerFormat.get(STANDARD) == null) { + underlyingSetCodesPerFormat.put(STANDARD, new ArrayList()); + } + underlyingSetCodesPerFormat.get(STANDARD).add(set.getCode()); } if (set.getReleaseDate().after(extendedDate)) { - extended.add(set.getCode()); + if(underlyingSetCodesPerFormat.get(EXTENDED) == null) { + underlyingSetCodesPerFormat.put(EXTENDED, new ArrayList()); + } + underlyingSetCodesPerFormat.get(EXTENDED).add(set.getCode()); } if (set.getReleaseDate().after(modernDate)) { - modern.add(set.getCode()); + if(underlyingSetCodesPerFormat.get(MODERN) == null) { + underlyingSetCodesPerFormat.put(MODERN, new ArrayList()); + } + underlyingSetCodesPerFormat.get(MODERN).add(set.getCode()); } } + + if(underlyingSetCodesPerFormat.get(set.getName()) == null) { + underlyingSetCodesPerFormat.put(set.getName(), new ArrayList()); + } + + underlyingSetCodesPerFormat.get(set.getName()).add(set.getCode()); + + if(set.getType().equals(SetType.EXPANSION) && set.getBlockName() != null) { + String blockDisplayName = getBlockDisplayName(set.getBlockName()); + if(underlyingSetCodesPerFormat.get(blockDisplayName) == null) { + underlyingSetCodesPerFormat.put(blockDisplayName, new ArrayList()); + } + + underlyingSetCodesPerFormat.get(blockDisplayName).add(set.getCode()); + + if(expansionInfo.get(blockDisplayName) == null) { + expansionInfo.put(blockDisplayName, set); + formats.add(blockDisplayName); + } + + if(expansionInfo.get(blockDisplayName).getReleaseDate().after(set.getReleaseDate())) { + expansionInfo.put(blockDisplayName, set); + } + + } + + if(set.getType().equals(SetType.SUPPLEMENTAL) && set.getBlockName() != null) { + if(expansionInfo.get(set.getBlockName()) == null) { + expansionInfo.put(set.getBlockName(), set); + } + + if(expansionInfo.get(set.getBlockName()).getReleaseDate().before(set.getReleaseDate())) { + expansionInfo.put(set.getBlockName(), set); + } + } } + + Collections.sort(formats, new Comparator() { + + @Override + public int compare(String name1, String name2) { + ExpansionInfo expansionInfo1 = expansionInfo.get(name1); + ExpansionInfo expansionInfo2 = expansionInfo.get(name2); + + if(expansionInfo1.getType().compareTo(expansionInfo2.getType()) == 0) { + SetType setType = expansionInfo1.getType(); + if(setType.equals(SetType.EXPANSION)) { + + if(expansionInfo1.getBlockName() == null) { + if(expansionInfo2.getBlockName() == null) { + return expansionInfo2.getReleaseDate().compareTo(expansionInfo1.getReleaseDate()); + } + + return 1; + } + + if(expansionInfo2.getBlockName() == null) { + return -1; + } + + //Block comparison + if(name1.endsWith("Block") && name2.endsWith("Block")) { + return expansionInfo2.getReleaseDate().compareTo(expansionInfo1.getReleaseDate()); + } + + if(name1.endsWith("Block")) { + if(expansionInfo1.getBlockName().equals(expansionInfo2.getBlockName())) { + return -1; + } + } + + if(name2.endsWith("Block")) { + if(expansionInfo1.getBlockName().equals(expansionInfo2.getBlockName())) { + return 1; + } + } + + return expansionInfo2.getReleaseDate().compareTo(expansionInfo1.getReleaseDate()); + + } else if(setType.equals(SetType.SUPPLEMENTAL)) { + if(expansionInfo1.getBlockName() == null) { + if(expansionInfo2.getBlockName() == null) { + return expansionInfo2.getReleaseDate().compareTo(expansionInfo1.getReleaseDate()); + } + + return -1; + } + + if(expansionInfo2.getBlockName() == null) { + return 1; + } + + if(expansionInfo1.getBlockName().equals(expansionInfo2.getBlockName())) { + //If release date is the same, sort alphabetically. + if(expansionInfo2.getReleaseDate().compareTo(expansionInfo1.getReleaseDate()) == 0) { + return name1.compareTo(name2); + } + return expansionInfo2.getReleaseDate().compareTo(expansionInfo1.getReleaseDate()); + } + + if(expansionInfo1.getBlockName().startsWith("Duel Decks")) { + if(expansionInfo1.getBlockName().startsWith("Duel Decks: Anthology")) { + return 1; + } + return 1; + } + if(expansionInfo2.getBlockName().startsWith("Duel Decks")) { + return -1; + } + + ExpansionInfo blockInfo1 = expansionInfo.get(expansionInfo1.getBlockName()); + ExpansionInfo blockInfo2 = expansionInfo.get(expansionInfo2.getBlockName()); + + return blockInfo2.getReleaseDate().compareTo(blockInfo1.getReleaseDate()); + + + } else { + return expansionInfo2.getReleaseDate().compareTo(expansionInfo1.getReleaseDate()); + } + } + return expansionInfo1.getType().compareTo(expansionInfo2.getType()); + } + + }); + + formats.add(0, MODERN); + formats.add(0, EXTENDED); + formats.add(0, STANDARD); + formats.add(0, ALL); + } + + private static String getBlockDisplayName(String blockName) { + StringBuilder builder = new StringBuilder(); + builder.append("* ").append(blockName).append(" Block"); + + return builder.toString(); } - private static final List standard = new ArrayList<>(); - private static final List extended = new ArrayList<>(); private static final Date extendedDate = new GregorianCalendar(2009, 8, 20).getTime(); - private static final List modern = new ArrayList<>(); private static final Date modernDate = new GregorianCalendar(2003, 7, 20).getTime(); // for all sets just return empty list diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ShadowmooreBlock.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ShadowmoorBlock.java similarity index 90% rename from Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ShadowmooreBlock.java rename to Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ShadowmoorBlock.java index fcb0ed8c35..bbe6963ee7 100644 --- a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ShadowmooreBlock.java +++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ShadowmoorBlock.java @@ -34,10 +34,10 @@ import mage.cards.decks.Constructed; * * @author BetaSteward_at_googlemail.com */ -public class ShadowmooreBlock extends Constructed { +public class ShadowmoorBlock extends Constructed { - public ShadowmooreBlock() { - super("Constructed - Shadowmoore Block"); + public ShadowmoorBlock() { + super("Constructed - Shadowmoor Block"); setCodes.add("SHM"); setCodes.add("EVE"); } diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index 8f4bda9b1a..576680673b 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -1549,7 +1549,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { if (landSets.isEmpty()) { for (String setCode :deck.getExpansionSetCodes()) { ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode); - ExpansionInfo [] blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName()); + List blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName()); for (ExpansionInfo blockSet: blockSets) { if (blockSet.hasBasicLands()) { landSets.add(blockSet.getCode()); diff --git a/Mage.Sets/src/mage/sets/AjaniVsNicolBolas.java b/Mage.Sets/src/mage/sets/AjaniVsNicolBolas.java index deb92113d2..f1841bc409 100644 --- a/Mage.Sets/src/mage/sets/AjaniVsNicolBolas.java +++ b/Mage.Sets/src/mage/sets/AjaniVsNicolBolas.java @@ -44,7 +44,8 @@ public class AjaniVsNicolBolas extends ExpansionSet { } private AjaniVsNicolBolas() { - super("Duel Decks: Ajani vs. Nicol Bolas", "DDH", "mage.sets.ajanivsnicolbolas", new GregorianCalendar(2011, 9, 2).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Ajani vs. Nicol Bolas", "DDH", "mage.sets.ajanivsnicolbolas", new GregorianCalendar(2011, 9, 2).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/AnthologyDivineVsDemonic.java b/Mage.Sets/src/mage/sets/AnthologyDivineVsDemonic.java index 49d8981170..3e5bd72f44 100644 --- a/Mage.Sets/src/mage/sets/AnthologyDivineVsDemonic.java +++ b/Mage.Sets/src/mage/sets/AnthologyDivineVsDemonic.java @@ -43,7 +43,8 @@ public class AnthologyDivineVsDemonic extends ExpansionSet { } private AnthologyDivineVsDemonic() { - super("Duel Decks: Anthology, Divine vs. Demonic", "DD3A", "mage.sets.anthologydivinevsdemonic", new GregorianCalendar(2014, 12, 5).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Anthology, Divine vs. Demonic", "DD3A", "mage.sets.anthologydivinevsdemonic", new GregorianCalendar(2014, 12, 5).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks: Anthology"; this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/AnthologyElvesVsGoblins.java b/Mage.Sets/src/mage/sets/AnthologyElvesVsGoblins.java index cafe6bba64..c1fee60718 100644 --- a/Mage.Sets/src/mage/sets/AnthologyElvesVsGoblins.java +++ b/Mage.Sets/src/mage/sets/AnthologyElvesVsGoblins.java @@ -43,7 +43,8 @@ public class AnthologyElvesVsGoblins extends ExpansionSet { } private AnthologyElvesVsGoblins() { - super("Duel Decks: Anthology, Elves vs. Goblins", "DD3B", "mage.sets.anthologyelvesvsgoblins", new GregorianCalendar(2014, 12, 5).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Anthology, Elves vs. Goblins", "DD3B", "mage.sets.anthologyelvesvsgoblins", new GregorianCalendar(2014, 12, 5).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks: Anthology"; this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/AnthologyGarrukVsLiliana.java b/Mage.Sets/src/mage/sets/AnthologyGarrukVsLiliana.java index 72c66622df..b2e57d8d26 100644 --- a/Mage.Sets/src/mage/sets/AnthologyGarrukVsLiliana.java +++ b/Mage.Sets/src/mage/sets/AnthologyGarrukVsLiliana.java @@ -43,7 +43,8 @@ public class AnthologyGarrukVsLiliana extends ExpansionSet { } private AnthologyGarrukVsLiliana() { - super("Duel Decks: Anthology, Garruk vs. Liliana", "DD3C", "mage.sets.anthologygarrukvsliliana", new GregorianCalendar(2014, 12, 5).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Anthology, Garruk vs. Liliana", "DD3C", "mage.sets.anthologygarrukvsliliana", new GregorianCalendar(2014, 12, 5).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks: Anthology"; this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/AnthologyJaceVsChandra.java b/Mage.Sets/src/mage/sets/AnthologyJaceVsChandra.java index c21ca185a3..19ef4402bb 100644 --- a/Mage.Sets/src/mage/sets/AnthologyJaceVsChandra.java +++ b/Mage.Sets/src/mage/sets/AnthologyJaceVsChandra.java @@ -43,7 +43,8 @@ public class AnthologyJaceVsChandra extends ExpansionSet { } private AnthologyJaceVsChandra() { - super("Duel Decks: Anthology, Jace vs. Chandra", "DD3D", "mage.sets.anthologyjacevschandra", new GregorianCalendar(2014, 12, 5).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Anthology, Jace vs. Chandra", "DD3D", "mage.sets.anthologyjacevschandra", new GregorianCalendar(2014, 12, 5).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks: Anthology"; this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/Archenemy.java b/Mage.Sets/src/mage/sets/Archenemy.java index 0501dfc436..f4cd5f5dbc 100644 --- a/Mage.Sets/src/mage/sets/Archenemy.java +++ b/Mage.Sets/src/mage/sets/Archenemy.java @@ -45,7 +45,8 @@ public class Archenemy extends ExpansionSet { } private Archenemy() { - super("Archenemy", "ARC", "mage.sets.archenemy", new GregorianCalendar(2010, 6, 18).getTime(), SetType.NON_STANDARD_LEGAL_SETS); + super("Archenemy", "ARC", "mage.sets.archenemy", new GregorianCalendar(2010, 6, 18).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Command Zone"; } } diff --git a/Mage.Sets/src/mage/sets/SixthEdition.java b/Mage.Sets/src/mage/sets/ClassicSixthEdition.java similarity index 82% rename from Mage.Sets/src/mage/sets/SixthEdition.java rename to Mage.Sets/src/mage/sets/ClassicSixthEdition.java index bafe94c2d2..f8b987af32 100644 --- a/Mage.Sets/src/mage/sets/SixthEdition.java +++ b/Mage.Sets/src/mage/sets/ClassicSixthEdition.java @@ -36,16 +36,16 @@ import mage.constants.SetType; * * @author North */ -public class SixthEdition extends ExpansionSet { +public class ClassicSixthEdition extends ExpansionSet { - private static final SixthEdition fINSTANCE = new SixthEdition(); + private static final ClassicSixthEdition fINSTANCE = new ClassicSixthEdition(); - public static SixthEdition getInstance() { + public static ClassicSixthEdition getInstance() { return fINSTANCE; } - private SixthEdition() { - super("Sixth Edition", "6ED", "mage.sets.sixthedition", new GregorianCalendar(1999, 3, 28).getTime(), SetType.CORE); + private ClassicSixthEdition() { + super("Classic Sixth Edition", "6ED", "mage.sets.classicsixthedition", new GregorianCalendar(1999, 3, 28).getTime(), SetType.CORE); this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/Commander.java b/Mage.Sets/src/mage/sets/Commander.java index 5863ef66c2..e5e9dfad9e 100644 --- a/Mage.Sets/src/mage/sets/Commander.java +++ b/Mage.Sets/src/mage/sets/Commander.java @@ -47,7 +47,8 @@ public class Commander extends ExpansionSet { } private Commander() { - super("Magic: The Gathering-Commander", "CMD", "mage.sets.commander", new GregorianCalendar(2011, 6, 17).getTime(), SetType.NON_STANDARD_LEGAL_SETS); + super("Commander", "CMD", "mage.sets.commander", new GregorianCalendar(2011, 6, 17).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Command Zone"; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Commander2013.java b/Mage.Sets/src/mage/sets/Commander2013.java index 889193a232..1666d72e3c 100644 --- a/Mage.Sets/src/mage/sets/Commander2013.java +++ b/Mage.Sets/src/mage/sets/Commander2013.java @@ -47,7 +47,8 @@ public class Commander2013 extends ExpansionSet { } private Commander2013() { - super("Commander 2013 Edition", "C13", "mage.sets.commander2013", new GregorianCalendar(2013, 11, 01).getTime(), SetType.NON_STANDARD_LEGAL_SETS); + super("Commander 2013 Edition", "C13", "mage.sets.commander2013", new GregorianCalendar(2013, 11, 01).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Command Zone"; } } diff --git a/Mage.Sets/src/mage/sets/Commander2014.java b/Mage.Sets/src/mage/sets/Commander2014.java index 106ec7edf4..f244477b23 100644 --- a/Mage.Sets/src/mage/sets/Commander2014.java +++ b/Mage.Sets/src/mage/sets/Commander2014.java @@ -45,7 +45,8 @@ public class Commander2014 extends ExpansionSet { } private Commander2014() { - super("Commander 2014 Edition", "C14", "mage.sets.commander2014", new GregorianCalendar(2014, 11, 07).getTime(), SetType.NON_STANDARD_LEGAL_SETS); + super("Commander 2014 Edition", "C14", "mage.sets.commander2014", new GregorianCalendar(2014, 11, 07).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Command Zone"; } } diff --git a/Mage.Sets/src/mage/sets/Conspiracy.java b/Mage.Sets/src/mage/sets/Conspiracy.java index 561ef75498..cb0ad96e7c 100644 --- a/Mage.Sets/src/mage/sets/Conspiracy.java +++ b/Mage.Sets/src/mage/sets/Conspiracy.java @@ -47,7 +47,8 @@ import mage.constants.SetType; } private Conspiracy() { - super("Magic: The Gathering-Conspiracy", "CNS", "mage.sets.conspiracy", new GregorianCalendar(2014, 6, 6).getTime(), SetType.NON_STANDARD_LEGAL_SETS); + super("Conspiracy", "CNS", "mage.sets.conspiracy", new GregorianCalendar(2014, 6, 6).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Conspiracy"; this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; diff --git a/Mage.Sets/src/mage/sets/DivineVsDemonic.java b/Mage.Sets/src/mage/sets/DivineVsDemonic.java index 4d131e492b..2d68911f5f 100644 --- a/Mage.Sets/src/mage/sets/DivineVsDemonic.java +++ b/Mage.Sets/src/mage/sets/DivineVsDemonic.java @@ -45,7 +45,8 @@ public class DivineVsDemonic extends ExpansionSet { } private DivineVsDemonic() { - super("Duel Decks: Divine vs. Demonic", "DDC", "mage.sets.divinevsdemonic", new GregorianCalendar(2009, 04, 10).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Divine vs. Demonic", "DDC", "mage.sets.divinevsdemonic", new GregorianCalendar(2009, 04, 10).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/DragonsOfTarkir.java b/Mage.Sets/src/mage/sets/DragonsOfTarkir.java index d44ef26f23..7ab3b140e6 100644 --- a/Mage.Sets/src/mage/sets/DragonsOfTarkir.java +++ b/Mage.Sets/src/mage/sets/DragonsOfTarkir.java @@ -47,7 +47,7 @@ public class DragonsOfTarkir extends ExpansionSet { private DragonsOfTarkir() { super("Dragons of Tarkir", "DTK", "mage.sets.dragonsoftarkir", new GregorianCalendar(2015, 3, 27).getTime(), SetType.EXPANSION); - this.blockName = "Dragons of Tarkir"; + this.blockName = "Khans of Tarkir"; this.hasBoosters = true; this.hasBasicLands = true; this.numBoosterLands = 1; diff --git a/Mage.Sets/src/mage/sets/ElspethVsKiora.java b/Mage.Sets/src/mage/sets/ElspethVsKiora.java index d0d033a473..48f151f597 100644 --- a/Mage.Sets/src/mage/sets/ElspethVsKiora.java +++ b/Mage.Sets/src/mage/sets/ElspethVsKiora.java @@ -43,7 +43,8 @@ public class ElspethVsKiora extends ExpansionSet { } private ElspethVsKiora() { - super("Duel Decks: Elspeth vs. Kiora", "DDO", "mage.sets.elspethvskiora", new GregorianCalendar(2015, 2, 27).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Elspeth vs. Kiora", "DDO", "mage.sets.elspethvskiora", new GregorianCalendar(2015, 2, 27).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/ElspethvsTezzeret.java b/Mage.Sets/src/mage/sets/ElspethVsTezzeret.java similarity index 51% rename from Mage.Sets/src/mage/sets/ElspethvsTezzeret.java rename to Mage.Sets/src/mage/sets/ElspethVsTezzeret.java index d043b5b501..77e968d6b0 100644 --- a/Mage.Sets/src/mage/sets/ElspethvsTezzeret.java +++ b/Mage.Sets/src/mage/sets/ElspethVsTezzeret.java @@ -5,15 +5,16 @@ import mage.constants.SetType; import java.util.GregorianCalendar; -public class ElspethvsTezzeret extends ExpansionSet { - private static final ElspethvsTezzeret fINSTANCE = new ElspethvsTezzeret(); +public class ElspethVsTezzeret extends ExpansionSet { + private static final ElspethVsTezzeret fINSTANCE = new ElspethVsTezzeret(); - public static ElspethvsTezzeret getInstance() { + public static ElspethVsTezzeret getInstance() { return fINSTANCE; } - private ElspethvsTezzeret() { - super("Duel Decks: Elspeth vs. Tezzeret", "DDF", "mage.sets.elspethvstezzeret", new GregorianCalendar(2010, 8, 3).getTime(), SetType.DUEL_DECK); + private ElspethVsTezzeret() { + super("Duel Decks: Elspeth vs. Tezzeret", "DDF", "mage.sets.elspethvstezzeret", new GregorianCalendar(2010, 8, 3).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/ElvesVsGoblins.java b/Mage.Sets/src/mage/sets/ElvesVsGoblins.java index 76ebfb9f35..bfd14e3f89 100644 --- a/Mage.Sets/src/mage/sets/ElvesVsGoblins.java +++ b/Mage.Sets/src/mage/sets/ElvesVsGoblins.java @@ -23,7 +23,8 @@ public class ElvesVsGoblins extends ExpansionSet { } private ElvesVsGoblins() { - super("Duel Decks: Elves vs. Goblins", "EVG", "mage.sets.elvesvsgoblins", new GregorianCalendar(2007, 11, 16).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Elves vs. Goblins", "EVG", "mage.sets.elvesvsgoblins", new GregorianCalendar(2007, 11, 16).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/GarrukVsLiliana.java b/Mage.Sets/src/mage/sets/GarrukVsLiliana.java index e61f55243f..7679ffab7f 100644 --- a/Mage.Sets/src/mage/sets/GarrukVsLiliana.java +++ b/Mage.Sets/src/mage/sets/GarrukVsLiliana.java @@ -23,7 +23,8 @@ public class GarrukVsLiliana extends ExpansionSet { } private GarrukVsLiliana() { - super("Duel Decks: Garruk vs. Liliana", "DDD", "mage.sets.garrukvsliliana", new GregorianCalendar(2009, 10, 30).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Garruk vs. Liliana", "DDD", "mage.sets.garrukvsliliana", new GregorianCalendar(2009, 10, 30).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Heroesvsmonsters.java b/Mage.Sets/src/mage/sets/HeroesVsMonsters.java similarity index 85% rename from Mage.Sets/src/mage/sets/Heroesvsmonsters.java rename to Mage.Sets/src/mage/sets/HeroesVsMonsters.java index 01c18a3a05..e59b9e4183 100644 --- a/Mage.Sets/src/mage/sets/Heroesvsmonsters.java +++ b/Mage.Sets/src/mage/sets/HeroesVsMonsters.java @@ -36,15 +36,16 @@ import mage.constants.SetType; * @author LevelX2 */ -public class Heroesvsmonsters extends ExpansionSet { - private static final Heroesvsmonsters fINSTANCE = new Heroesvsmonsters(); +public class HeroesVsMonsters extends ExpansionSet { + private static final HeroesVsMonsters fINSTANCE = new HeroesVsMonsters(); - public static Heroesvsmonsters getInstance() { + public static HeroesVsMonsters getInstance() { return fINSTANCE; } - private Heroesvsmonsters() { - super("Duel Decks: Heroes vs. Monsters", "DDL", "mage.sets.heroesvsmonsters", new GregorianCalendar(2013, 9, 6).getTime(), SetType.DUEL_DECK); + private HeroesVsMonsters() { + super("Duel Decks: Heroes vs. Monsters", "DDL", "mage.sets.heroesvsmonsters", new GregorianCalendar(2013, 9, 6).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/IzzetVsGolgari.java b/Mage.Sets/src/mage/sets/IzzetVsGolgari.java index 922fb79bdc..5d658d8b88 100644 --- a/Mage.Sets/src/mage/sets/IzzetVsGolgari.java +++ b/Mage.Sets/src/mage/sets/IzzetVsGolgari.java @@ -44,7 +44,8 @@ public class IzzetVsGolgari extends ExpansionSet { } private IzzetVsGolgari() { - super("Duel Decks: Izzet vs. Golgari", "DDJ", "mage.sets.izzetvsgolgari", new GregorianCalendar(2012, 9, 7).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Izzet vs. Golgari", "DDJ", "mage.sets.izzetvsgolgari", new GregorianCalendar(2012, 9, 7).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/JaceVsChandra.java b/Mage.Sets/src/mage/sets/JaceVsChandra.java index f3dfc422b6..09bccd30bb 100644 --- a/Mage.Sets/src/mage/sets/JaceVsChandra.java +++ b/Mage.Sets/src/mage/sets/JaceVsChandra.java @@ -23,7 +23,8 @@ public class JaceVsChandra extends ExpansionSet { } private JaceVsChandra() { - super("Duel Decks: Jace vs. Chandra", "DD2", "mage.sets.jacevschandra", new GregorianCalendar(2008, 11, 07).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Jace vs. Chandra", "DD2", "mage.sets.jacevschandra", new GregorianCalendar(2008, 11, 07).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/JaceVsVraska.java b/Mage.Sets/src/mage/sets/JaceVsVraska.java index f454ec804c..5910247d01 100644 --- a/Mage.Sets/src/mage/sets/JaceVsVraska.java +++ b/Mage.Sets/src/mage/sets/JaceVsVraska.java @@ -45,7 +45,8 @@ public class JaceVsVraska extends ExpansionSet { } private JaceVsVraska() { - super("Duel Decks: Jace vs. Vraska", "DDM", "mage.sets.jacevsvraska", new GregorianCalendar(2014, 3, 14).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Jace vs. Vraska", "DDM", "mage.sets.jacevsvraska", new GregorianCalendar(2014, 3, 14).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/KnightsVsDragons.java b/Mage.Sets/src/mage/sets/KnightsVsDragons.java index e15ab13a93..326ae6336f 100644 --- a/Mage.Sets/src/mage/sets/KnightsVsDragons.java +++ b/Mage.Sets/src/mage/sets/KnightsVsDragons.java @@ -45,7 +45,8 @@ public class KnightsVsDragons extends ExpansionSet { } private KnightsVsDragons() { - super("Duel Decks: Knights vs. Dragons", "DDG", "mage.sets.knightsvsdragons", new GregorianCalendar(2011, 4, 1).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Knights vs. Dragons", "DDG", "mage.sets.knightsvsdragons", new GregorianCalendar(2011, 4, 1).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/MastersEdition.java b/Mage.Sets/src/mage/sets/MastersEdition.java index 02c6fe2ac0..07e20a0483 100644 --- a/Mage.Sets/src/mage/sets/MastersEdition.java +++ b/Mage.Sets/src/mage/sets/MastersEdition.java @@ -44,7 +44,7 @@ public class MastersEdition extends ExpansionSet { } private MastersEdition() { - super("Masters Edition", "MED", "mage.sets.mastersedition", new GregorianCalendar(2007, 9, 10).getTime(), SetType.REPRINT); + super("Masters Edition", "MED", "mage.sets.mastersedition", new GregorianCalendar(2007, 9, 10).getTime(), SetType.MAGIC_ONLINE); this.hasBasicLands = true; this.hasBoosters = true; this.numBoosterLands = 1; diff --git a/Mage.Sets/src/mage/sets/MastersEditionII.java b/Mage.Sets/src/mage/sets/MastersEditionII.java index c966abe386..0637ada20b 100644 --- a/Mage.Sets/src/mage/sets/MastersEditionII.java +++ b/Mage.Sets/src/mage/sets/MastersEditionII.java @@ -44,7 +44,7 @@ public class MastersEditionII extends ExpansionSet { } private MastersEditionII() { - super("Masters Edition II", "ME2", "mage.sets.masterseditionii", new GregorianCalendar(2008, 9, 22).getTime(), SetType.REPRINT); + super("Masters Edition II", "ME2", "mage.sets.masterseditionii", new GregorianCalendar(2008, 9, 22).getTime(), SetType.MAGIC_ONLINE); this.hasBasicLands = true; this.hasBoosters = true; this.numBoosterLands = 1; diff --git a/Mage.Sets/src/mage/sets/MastersEditionIII.java b/Mage.Sets/src/mage/sets/MastersEditionIII.java index 8197b774d5..60e9932212 100644 --- a/Mage.Sets/src/mage/sets/MastersEditionIII.java +++ b/Mage.Sets/src/mage/sets/MastersEditionIII.java @@ -44,7 +44,7 @@ public class MastersEditionIII extends ExpansionSet { } private MastersEditionIII() { - super("Masters Edition III", "ME3", "mage.sets.masterseditioniii", new GregorianCalendar(2009, 9, 7).getTime(), SetType.REPRINT); + super("Masters Edition III", "ME3", "mage.sets.masterseditioniii", new GregorianCalendar(2009, 9, 7).getTime(), SetType.MAGIC_ONLINE); this.hasBasicLands = true; this.hasBoosters = true; this.numBoosterLands = 1; diff --git a/Mage.Sets/src/mage/sets/MastersEditionIV.java b/Mage.Sets/src/mage/sets/MastersEditionIV.java index 47eb48ab5b..2c9f75e2a5 100644 --- a/Mage.Sets/src/mage/sets/MastersEditionIV.java +++ b/Mage.Sets/src/mage/sets/MastersEditionIV.java @@ -45,7 +45,7 @@ public class MastersEditionIV extends ExpansionSet { } private MastersEditionIV() { - super("Masters Edition IV", "ME4", "mage.sets.masterseditioniv", new GregorianCalendar(2011, 1, 10).getTime(), SetType.REPRINT); + super("Masters Edition IV", "ME4", "mage.sets.masterseditioniv", new GregorianCalendar(2011, 1, 10).getTime(), SetType.MAGIC_ONLINE); this.hasBasicLands = true; this.hasBoosters = true; this.numBoosterLands = 1; diff --git a/Mage.Sets/src/mage/sets/ModernMasters.java b/Mage.Sets/src/mage/sets/ModernMasters.java index 956fdbfa87..0c3aa0a998 100644 --- a/Mage.Sets/src/mage/sets/ModernMasters.java +++ b/Mage.Sets/src/mage/sets/ModernMasters.java @@ -47,7 +47,8 @@ public class ModernMasters extends ExpansionSet { } private ModernMasters() { - super("Modern Masters", "MMA", "mage.sets.modernmasters", new GregorianCalendar(2013, 6, 7).getTime(), SetType.REPRINT); + super("Modern Masters", "MMA", "mage.sets.modernmasters", new GregorianCalendar(2013, 6, 7).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Reprint"; this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; diff --git a/Mage.Sets/src/mage/sets/ModernMasters2015.java b/Mage.Sets/src/mage/sets/ModernMasters2015.java index 7f853bd0b1..f8c02d017e 100644 --- a/Mage.Sets/src/mage/sets/ModernMasters2015.java +++ b/Mage.Sets/src/mage/sets/ModernMasters2015.java @@ -47,7 +47,8 @@ public class ModernMasters2015 extends ExpansionSet { } private ModernMasters2015() { - super("Modern Masters 2015", "MMB", "mage.sets.modernmasters2015", new GregorianCalendar(2015, 5, 22).getTime(), SetType.REPRINT); + super("Modern Masters 2015", "MMB", "mage.sets.modernmasters2015", new GregorianCalendar(2015, 5, 22).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Reprint"; this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterLands = 0; diff --git a/Mage.Sets/src/mage/sets/PhyrexiaVsTheCoalition.java b/Mage.Sets/src/mage/sets/PhyrexiaVsTheCoalition.java index 42be2f93ba..2f3e323aea 100644 --- a/Mage.Sets/src/mage/sets/PhyrexiaVsTheCoalition.java +++ b/Mage.Sets/src/mage/sets/PhyrexiaVsTheCoalition.java @@ -44,7 +44,8 @@ public class PhyrexiaVsTheCoalition extends ExpansionSet { } private PhyrexiaVsTheCoalition() { - super("Duel Decks: Phyrexia vs. the Coalition", "DDE", "mage.sets.phyrexiavsthecoalition", new GregorianCalendar(2010, 3, 19).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Phyrexia vs. the Coalition", "DDE", "mage.sets.phyrexiavsthecoalition", new GregorianCalendar(2010, 3, 19).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/Planechase.java b/Mage.Sets/src/mage/sets/Planechase.java index d25acafebc..887b7e9490 100644 --- a/Mage.Sets/src/mage/sets/Planechase.java +++ b/Mage.Sets/src/mage/sets/Planechase.java @@ -45,7 +45,8 @@ public class Planechase extends ExpansionSet { } private Planechase() { - super("Planechase", "HOP", "mage.sets.planechase", new GregorianCalendar(2009, 8, 4).getTime(), SetType.NON_STANDARD_LEGAL_SETS); + super("Planechase", "HOP", "mage.sets.planechase", new GregorianCalendar(2009, 8, 4).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Command Zone"; } } diff --git a/Mage.Sets/src/mage/sets/Planechase2012.java b/Mage.Sets/src/mage/sets/Planechase2012.java index 135ec7f264..d30b624223 100644 --- a/Mage.Sets/src/mage/sets/Planechase2012.java +++ b/Mage.Sets/src/mage/sets/Planechase2012.java @@ -45,7 +45,8 @@ public class Planechase2012 extends ExpansionSet { } private Planechase2012() { - super("Planechase (2012 Edition)", "PC2", "mage.sets.planechase2012", new GregorianCalendar(2012, 6, 1).getTime(), SetType.NON_STANDARD_LEGAL_SETS); + super("Planechase 2012 Edition", "PC2", "mage.sets.planechase2012", new GregorianCalendar(2012, 6, 1).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Command Zone"; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Portal.java b/Mage.Sets/src/mage/sets/Portal.java index 0be0292a0a..a0800eed15 100644 --- a/Mage.Sets/src/mage/sets/Portal.java +++ b/Mage.Sets/src/mage/sets/Portal.java @@ -50,7 +50,8 @@ public class Portal extends ExpansionSet { } private Portal() { - super("Portal", "POR", "mage.sets.portal", new GregorianCalendar(1997, 5, 1).getTime(), SetType.REPRINT); + super("Portal", "POR", "mage.sets.portal", new GregorianCalendar(1997, 5, 1).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Beginner"; this.hasBasicLands = true; this.hasBoosters = true; this.numBoosterLands = 0; diff --git a/Mage.Sets/src/mage/sets/PortalSecondAge.java b/Mage.Sets/src/mage/sets/PortalSecondAge.java index 05256d6b62..8b58b50887 100644 --- a/Mage.Sets/src/mage/sets/PortalSecondAge.java +++ b/Mage.Sets/src/mage/sets/PortalSecondAge.java @@ -50,7 +50,8 @@ public class PortalSecondAge extends ExpansionSet { } private PortalSecondAge() { - super("Portal Second Age", "PO2", "mage.sets.portalsecondage", new GregorianCalendar(1998, 6, 24).getTime(), SetType.REPRINT); + super("Portal Second Age", "PO2", "mage.sets.portalsecondage", new GregorianCalendar(1998, 6, 24).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Beginner"; this.hasBasicLands = true; this.hasBoosters = true; this.numBoosterLands = 0; diff --git a/Mage.Sets/src/mage/sets/PortalThreeKingdoms.java b/Mage.Sets/src/mage/sets/PortalThreeKingdoms.java index 6c5c90e0f9..f64b880306 100644 --- a/Mage.Sets/src/mage/sets/PortalThreeKingdoms.java +++ b/Mage.Sets/src/mage/sets/PortalThreeKingdoms.java @@ -50,7 +50,8 @@ public class PortalThreeKingdoms extends ExpansionSet { } private PortalThreeKingdoms() { - super("Portal Three Kingsdoms", "PTK", "mage.sets.portalthreekingdoms", new GregorianCalendar(1999, 5, 1).getTime(), SetType.REPRINT); + super("Portal Three Kingdoms", "PTK", "mage.sets.portalthreekingdoms", new GregorianCalendar(1999, 5, 1).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Beginner"; this.hasBasicLands = true; this.hasBoosters = true; this.numBoosterLands = 2; diff --git a/Mage.Sets/src/mage/sets/SorinVsTibalt.java b/Mage.Sets/src/mage/sets/SorinVsTibalt.java index ddc79457cf..a990ab1cc1 100644 --- a/Mage.Sets/src/mage/sets/SorinVsTibalt.java +++ b/Mage.Sets/src/mage/sets/SorinVsTibalt.java @@ -44,7 +44,8 @@ public class SorinVsTibalt extends ExpansionSet { } private SorinVsTibalt() { - super("Duel Decks: Sorin vs. Tibalt", "DDK", "mage.sets.sorinvstibalt", new GregorianCalendar(2013, 3, 15).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Sorin vs. Tibalt", "DDK", "mage.sets.sorinvstibalt", new GregorianCalendar(2013, 3, 15).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/SpeedVsCunning.java b/Mage.Sets/src/mage/sets/SpeedVsCunning.java index bef9fd419c..4ef279712c 100644 --- a/Mage.Sets/src/mage/sets/SpeedVsCunning.java +++ b/Mage.Sets/src/mage/sets/SpeedVsCunning.java @@ -44,7 +44,8 @@ public class SpeedVsCunning extends ExpansionSet { } private SpeedVsCunning() { - super("Duel Decks: Speed vs. Cunning", "DDN", "mage.sets.speedvscunning", new GregorianCalendar(2014, 9, 5).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Speed vs. Cunning", "DDN", "mage.sets.speedvscunning", new GregorianCalendar(2014, 9, 5).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Starter1999.java b/Mage.Sets/src/mage/sets/Starter1999.java index 241051a5c1..0e3ad40a75 100644 --- a/Mage.Sets/src/mage/sets/Starter1999.java +++ b/Mage.Sets/src/mage/sets/Starter1999.java @@ -50,7 +50,8 @@ public class Starter1999 extends ExpansionSet { } private Starter1999() { - super("Starter1999", "S99", "mage.sets.starter1999", new GregorianCalendar(1999, 7, 1).getTime(), SetType.REPRINT); + super("Starter 1999", "S99", "mage.sets.starter1999", new GregorianCalendar(1999, 7, 1).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Beginner"; this.hasBasicLands = true; this.hasBoosters = true; this.numBoosterLands = 1; diff --git a/Mage.Sets/src/mage/sets/Starter2000.java b/Mage.Sets/src/mage/sets/Starter2000.java index 01e2f3b391..509b4bf077 100644 --- a/Mage.Sets/src/mage/sets/Starter2000.java +++ b/Mage.Sets/src/mage/sets/Starter2000.java @@ -50,7 +50,8 @@ public class Starter2000 extends ExpansionSet { } private Starter2000() { - super("Starter2000", "S00", "mage.sets.starter2000", new GregorianCalendar(2000, 7, 1).getTime(), SetType.REPRINT); + super("Starter 2000", "S00", "mage.sets.starter2000", new GregorianCalendar(2000, 7, 1).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Beginner"; this.hasBasicLands = true; this.hasBoosters = false; this.numBoosterLands = 1; diff --git a/Mage.Sets/src/mage/sets/TempestRemastered.java b/Mage.Sets/src/mage/sets/TempestRemastered.java index cf18da587a..d6170d0d9a 100644 --- a/Mage.Sets/src/mage/sets/TempestRemastered.java +++ b/Mage.Sets/src/mage/sets/TempestRemastered.java @@ -45,7 +45,7 @@ public class TempestRemastered extends ExpansionSet { } private TempestRemastered() { - super("Tempest Remastered", "TPR", "mage.sets.tempestremastered", new GregorianCalendar(2015, 5, 6).getTime(), SetType.REPRINT); + super("Tempest Remastered", "TPR", "mage.sets.tempestremastered", new GregorianCalendar(2015, 5, 6).getTime(), SetType.MAGIC_ONLINE); this.hasBasicLands = true; this.hasBoosters = true; this.numBoosterLands = 1; diff --git a/Mage.Sets/src/mage/sets/Tenth.java b/Mage.Sets/src/mage/sets/TenthEdition.java similarity index 86% rename from Mage.Sets/src/mage/sets/Tenth.java rename to Mage.Sets/src/mage/sets/TenthEdition.java index d1a351c214..fa20939446 100644 --- a/Mage.Sets/src/mage/sets/Tenth.java +++ b/Mage.Sets/src/mage/sets/TenthEdition.java @@ -36,16 +36,16 @@ import mage.cards.ExpansionSet; * * @author BetaSteward_at_googlemail.com */ -public class Tenth extends ExpansionSet { +public class TenthEdition extends ExpansionSet { - private static final Tenth fINSTANCE = new Tenth(); + private static final TenthEdition fINSTANCE = new TenthEdition(); - public static Tenth getInstance() { + public static TenthEdition getInstance() { return fINSTANCE; } - private Tenth() { - super("Tenth Edition", "10E", "mage.sets.tenth", new GregorianCalendar(2007, 6, 14).getTime(), SetType.CORE); + private TenthEdition() { + super("Tenth Edition", "10E", "mage.sets.tenthedition", new GregorianCalendar(2007, 6, 14).getTime(), SetType.CORE); this.hasBoosters = true; this.numBoosterLands = 1; this.numBoosterCommon = 10; diff --git a/Mage.Sets/src/mage/sets/VenserVsKoth.java b/Mage.Sets/src/mage/sets/VenserVsKoth.java index 57c4a4af48..aaa41b203b 100644 --- a/Mage.Sets/src/mage/sets/VenserVsKoth.java +++ b/Mage.Sets/src/mage/sets/VenserVsKoth.java @@ -45,7 +45,8 @@ public class VenserVsKoth extends ExpansionSet { } private VenserVsKoth() { - super("Duel Decks: Venser vs. Koth", "DDI", "mage.sets.venservskoth", new GregorianCalendar(2012, 3, 30).getTime(), SetType.DUEL_DECK); + super("Duel Decks: Venser vs. Koth", "DDI", "mage.sets.venservskoth", new GregorianCalendar(2012, 3, 30).getTime(), SetType.SUPPLEMENTAL); + this.blockName = "Duel Decks"; this.hasBasicLands = false; } } diff --git a/Mage.Sets/src/mage/sets/VintageMasters.java b/Mage.Sets/src/mage/sets/VintageMasters.java index 06a50aec06..7bd4fa5c16 100644 --- a/Mage.Sets/src/mage/sets/VintageMasters.java +++ b/Mage.Sets/src/mage/sets/VintageMasters.java @@ -52,7 +52,7 @@ public class VintageMasters extends ExpansionSet { } private VintageMasters() { - super("Vintage Masters", "VMA", "mage.sets.vintagemasters", new GregorianCalendar(2014, 6, 16).getTime(), SetType.REPRINT); + super("Vintage Masters", "VMA", "mage.sets.vintagemasters", new GregorianCalendar(2014, 6, 16).getTime(), SetType.MAGIC_ONLINE); this.hasBasicLands = false; this.hasBoosters = true; this.numBoosterSpecial = 1; diff --git a/Mage/src/mage/cards/Sets.java b/Mage/src/mage/cards/Sets.java index f8ab9d12a2..4cd380b3fb 100644 --- a/Mage/src/mage/cards/Sets.java +++ b/Mage/src/mage/cards/Sets.java @@ -35,6 +35,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; + import mage.cards.decks.DeckCardInfo; import mage.cards.decks.DeckCardLists; import mage.cards.repository.CardCriteria; @@ -42,12 +43,8 @@ import mage.cards.repository.CardInfo; import mage.cards.repository.CardRepository; import mage.constants.CardType; import mage.constants.ColoredManaSymbol; -import static mage.constants.ColoredManaSymbol.B; -import static mage.constants.ColoredManaSymbol.G; -import static mage.constants.ColoredManaSymbol.R; -import static mage.constants.ColoredManaSymbol.U; -import static mage.constants.ColoredManaSymbol.W; import mage.util.ClassScanner; + import org.apache.log4j.Logger; /** diff --git a/Mage/src/mage/cards/repository/ExpansionRepository.java b/Mage/src/mage/cards/repository/ExpansionRepository.java index f7dbc779f8..29ab4b9c04 100644 --- a/Mage/src/mage/cards/repository/ExpansionRepository.java +++ b/Mage/src/mage/cards/repository/ExpansionRepository.java @@ -97,13 +97,12 @@ public enum ExpansionRepository { return sets; } - public ExpansionInfo[] getSetsFromBlock(String blockName) { - ExpansionInfo[] sets = new ExpansionInfo[0]; + public List getSetsFromBlock(String blockName) { + List sets = new LinkedList<>(); try { QueryBuilder qb = expansionDao.queryBuilder(); qb.where().eq("blockName", new SelectArg(blockName)); - List expansions = expansionDao.query(qb.prepare()); - sets = expansions.toArray(new ExpansionInfo[0]); + return expansionDao.query(qb.prepare()); } catch (SQLException ex) { } return sets; @@ -122,15 +121,46 @@ public enum ExpansionRepository { } return set; } + + public ExpansionInfo getSetByName(String setName) { + ExpansionInfo set = null; + try { + QueryBuilder qb = expansionDao.queryBuilder(); + qb.where().eq("name", new SelectArg(setName)); + List expansions = expansionDao.query(qb.prepare()); + if (expansions.size() > 0) { + set = expansions.get(0); + } + } catch (SQLException ex) { + } + return set; + } public List getAll() { try { - return expansionDao.queryForAll(); + QueryBuilder qb = expansionDao.queryBuilder(); + qb.orderBy("releaseDate", true); + return expansionDao.query(qb.prepare()); } catch (SQLException ex) { } return new ArrayList<>(); } - + + public List getAllSetNames() { + try { + QueryBuilder qb = expansionDao.queryBuilder(); + qb.orderBy("releaseDate", true); + List expansions = expansionDao.query(qb.prepare()); + List setNames = new LinkedList<>(); + for (ExpansionInfo expansionInfo : expansions) { + setNames.add(expansionInfo.getName()); + } + return setNames; + } catch (SQLException ex) { + } + return new ArrayList<>(); + } + public long getContentVersionFromDB() { try { ConnectionSource connectionSource = new JdbcConnectionSource(JDBC_URL); diff --git a/Mage/src/mage/constants/SetType.java b/Mage/src/mage/constants/SetType.java index eb19d7d8ec..8a2dffa503 100644 --- a/Mage/src/mage/constants/SetType.java +++ b/Mage/src/mage/constants/SetType.java @@ -5,11 +5,10 @@ package mage.constants; * @author North */ public enum SetType { - CORE("Core"), - DUEL_DECK("Duel Deck"), EXPANSION("Expansion"), - NON_STANDARD_LEGAL_SETS("Non-standard-legal sets"), - REPRINT("Reprint"), + CORE("Core"), + MAGIC_ONLINE("Magic Online"), + SUPPLEMENTAL("Supplemental"), PROMOTIONAL("Promotional"), JOKESET("Joke Set"); diff --git a/Mage/src/mage/util/TournamentUtil.java b/Mage/src/mage/util/TournamentUtil.java index b29b6a6df9..8d3ae3aaca 100644 --- a/Mage/src/mage/util/TournamentUtil.java +++ b/Mage/src/mage/util/TournamentUtil.java @@ -47,7 +47,7 @@ public class TournamentUtil { if (setCodesland.isEmpty()) { for (String setCode :setCodesDeck) { ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode); - ExpansionInfo [] blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName()); + List blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName()); for (ExpansionInfo blockSet: blockSets) { if (blockSet.hasBasicLands()) { setCodesland.add(blockSet.getCode());