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 cf424ae636..ab060fd3f2 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 @@ -25,6 +25,10 @@ public class ConstructedFormats { public static final String EXTENDED = "- Extended"; public static final String FRONTIER = "- Frontier"; public static final String MODERN = "- Modern"; + public static final String VINTAGE_LEGACY = "- Vintage / Legacy"; + ; + public static final String CUSTOM = "- Custom"; + ; public static final Standard STANDARD_CARDS = new Standard(); private static final Map> underlyingSetCodesPerFormat = new HashMap<>(); @@ -50,50 +54,49 @@ public class ConstructedFormats { } public static void ensureLists() { - if (getSetsByFormat(ConstructedFormats.STANDARD) == null) { + if (underlyingSetCodesPerFormat.isEmpty()) { buildLists(); } } private static void buildLists() { + underlyingSetCodesPerFormat.put(STANDARD, new ArrayList<>()); + underlyingSetCodesPerFormat.put(EXTENDED, new ArrayList<>()); + underlyingSetCodesPerFormat.put(FRONTIER, new ArrayList<>()); + underlyingSetCodesPerFormat.put(MODERN, new ArrayList<>()); + underlyingSetCodesPerFormat.put(VINTAGE_LEGACY, new ArrayList<>()); + underlyingSetCodesPerFormat.put(CUSTOM, new ArrayList<>()); final Map expansionInfo = new HashMap<>(); formats.clear(); // prevent NPE on sorting if this is not the first try for (ExpansionInfo set : ExpansionRepository.instance.getAll()) { expansionInfo.put(set.getName(), set); formats.add(set.getName()); + + underlyingSetCodesPerFormat.put(set.getName(), new ArrayList<>()); + underlyingSetCodesPerFormat.get(set.getName()).add(set.getCode()); + + // create the play formats + if (set.getType().equals(SetType.CUSTOM_SET)) { + underlyingSetCodesPerFormat.get(CUSTOM).add(set.getCode()); + continue; + } + underlyingSetCodesPerFormat.get(VINTAGE_LEGACY).add(set.getCode()); if (set.getType().equals(SetType.CORE) || set.getType().equals(SetType.EXPANSION) || set.getType().equals(SetType.SUPPLEMENTAL_STANDARD_LEGAL)) { if (STANDARD_CARDS.getSetCodes().contains(set.getCode())) { - if (underlyingSetCodesPerFormat.get(STANDARD) == null) { - underlyingSetCodesPerFormat.put(STANDARD, new ArrayList<>()); - } underlyingSetCodesPerFormat.get(STANDARD).add(set.getCode()); } if (set.getReleaseDate().after(extendedDate)) { - if (underlyingSetCodesPerFormat.get(EXTENDED) == null) { - underlyingSetCodesPerFormat.put(EXTENDED, new ArrayList<>()); - } underlyingSetCodesPerFormat.get(EXTENDED).add(set.getCode()); } if (set.getReleaseDate().after(frontierDate)) { - if (underlyingSetCodesPerFormat.get(FRONTIER) == null) { - underlyingSetCodesPerFormat.put(FRONTIER, new ArrayList<>()); - } underlyingSetCodesPerFormat.get(FRONTIER).add(set.getCode()); } if (set.getReleaseDate().after(modernDate)) { - 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()); - + // Create the Block formats if (set.getType().equals(SetType.EXPANSION) && set.getBlockName() != null) { String blockDisplayName = getBlockDisplayName(set.getBlockName()); if (underlyingSetCodesPerFormat.get(blockDisplayName) == null) { @@ -209,10 +212,13 @@ public class ConstructedFormats { }); if (!formats.isEmpty()) { + formats.add(0, CUSTOM); + formats.add(0, VINTAGE_LEGACY); formats.add(0, MODERN); - formats.add(0, FRONTIER); formats.add(0, EXTENDED); + formats.add(0, FRONTIER); formats.add(0, STANDARD); + } formats.add(0, ALL); } diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Legacy.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Legacy.java index f8c24589b7..13fc442863 100644 --- a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Legacy.java +++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Legacy.java @@ -24,11 +24,13 @@ * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. -*/ - + */ package mage.deck; +import mage.cards.ExpansionSet; +import mage.cards.Sets; import mage.cards.decks.Constructed; +import mage.constants.SetType; /** * @@ -38,7 +40,11 @@ public class Legacy extends Constructed { public Legacy() { super("Constructed - Legacy"); - + for (ExpansionSet set : Sets.getInstance().values()) { + if (set.getSetType() != SetType.CUSTOM_SET) { + setCodes.add(set.getCode()); + } + } banned.add("Advantageous Proclamation"); banned.add("Amulet of Quoz"); banned.add("Ancestral Recall"); @@ -112,6 +118,6 @@ public class Legacy extends Constructed { banned.add("Worldknit"); banned.add("Yawgmoth's Bargain"); banned.add("Yawgmoth's Will"); - + } } diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Vintage.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Vintage.java index 8646bcf290..1dcdb14614 100644 --- a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Vintage.java +++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Vintage.java @@ -27,7 +27,10 @@ */ package mage.deck; +import mage.cards.ExpansionSet; +import mage.cards.Sets; import mage.cards.decks.Constructed; +import mage.constants.SetType; /** * @@ -37,7 +40,11 @@ public class Vintage extends Constructed { public Vintage() { super("Constructed - Vintage"); - + for (ExpansionSet set : Sets.getInstance().values()) { + if (set.getSetType() != SetType.CUSTOM_SET) { + setCodes.add(set.getCode()); + } + } banned.add("Advantageous Proclamation"); banned.add("Amulet of Quoz"); banned.add("Backup Plan"); diff --git a/Mage.Server/src/main/java/mage/server/Session.java b/Mage.Server/src/main/java/mage/server/Session.java index 602281c4e8..d6aabf7a06 100644 --- a/Mage.Server/src/main/java/mage/server/Session.java +++ b/Mage.Server/src/main/java/mage/server/Session.java @@ -284,7 +284,7 @@ public class Session { lockSet = true; logger.debug("SESSION LOCK SET sessionId: " + sessionId); } else { - logger.error("CAN'T GET LOCK - userId: " + userId); + logger.error("CAN'T GET LOCK - userId: " + userId + " hold count: " + lock.getHoldCount()); } User user = UserManager.getInstance().getUser(userId); if (user == null || !user.isConnected()) { diff --git a/Mage/src/main/java/mage/cards/decks/Constructed.java b/Mage/src/main/java/mage/cards/decks/Constructed.java index 5851f1ec66..dc15a1e9ce 100644 --- a/Mage/src/main/java/mage/cards/decks/Constructed.java +++ b/Mage/src/main/java/mage/cards/decks/Constructed.java @@ -48,9 +48,6 @@ public class Constructed extends DeckValidator { protected List setCodes = new ArrayList<>(); protected List rarities = new ArrayList<>(); - protected boolean allowAllCustomSets = false; - protected Set allowedCustomSetCodes = new HashSet<>(); - public Constructed() { super("Constructed"); } @@ -173,12 +170,7 @@ public class Constructed extends DeckValidator { * @return Whether the set is legal in this format. */ protected boolean isSetAllowed(String code) { - // To check here for custom set makes no sens IMHO because the format does define what's aloowed and what not -// if (Sets.isCustomSet(code)) { -// return allowAllCustomSets || allowedCustomSetCodes.contains(code); -// } else { return setCodes.isEmpty() || setCodes.contains(code); -// } } /**