mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Fixed some problems with constructed formats definition and custom sets.
This commit is contained in:
parent
7dfcb15c3c
commit
9a00dd20ca
5 changed files with 45 additions and 34 deletions
|
@ -25,6 +25,10 @@ public class ConstructedFormats {
|
||||||
public static final String EXTENDED = "- Extended";
|
public static final String EXTENDED = "- Extended";
|
||||||
public static final String FRONTIER = "- Frontier";
|
public static final String FRONTIER = "- Frontier";
|
||||||
public static final String MODERN = "- Modern";
|
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();
|
public static final Standard STANDARD_CARDS = new Standard();
|
||||||
|
|
||||||
private static final Map<String, List<String>> underlyingSetCodesPerFormat = new HashMap<>();
|
private static final Map<String, List<String>> underlyingSetCodesPerFormat = new HashMap<>();
|
||||||
|
@ -50,50 +54,49 @@ public class ConstructedFormats {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureLists() {
|
public static void ensureLists() {
|
||||||
if (getSetsByFormat(ConstructedFormats.STANDARD) == null) {
|
if (underlyingSetCodesPerFormat.isEmpty()) {
|
||||||
buildLists();
|
buildLists();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void 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<String, ExpansionInfo> expansionInfo = new HashMap<>();
|
final Map<String, ExpansionInfo> expansionInfo = new HashMap<>();
|
||||||
formats.clear(); // prevent NPE on sorting if this is not the first try
|
formats.clear(); // prevent NPE on sorting if this is not the first try
|
||||||
for (ExpansionInfo set : ExpansionRepository.instance.getAll()) {
|
for (ExpansionInfo set : ExpansionRepository.instance.getAll()) {
|
||||||
expansionInfo.put(set.getName(), set);
|
expansionInfo.put(set.getName(), set);
|
||||||
formats.add(set.getName());
|
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 (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 (STANDARD_CARDS.getSetCodes().contains(set.getCode())) {
|
||||||
if (underlyingSetCodesPerFormat.get(STANDARD) == null) {
|
|
||||||
underlyingSetCodesPerFormat.put(STANDARD, new ArrayList<>());
|
|
||||||
}
|
|
||||||
underlyingSetCodesPerFormat.get(STANDARD).add(set.getCode());
|
underlyingSetCodesPerFormat.get(STANDARD).add(set.getCode());
|
||||||
}
|
}
|
||||||
if (set.getReleaseDate().after(extendedDate)) {
|
if (set.getReleaseDate().after(extendedDate)) {
|
||||||
if (underlyingSetCodesPerFormat.get(EXTENDED) == null) {
|
|
||||||
underlyingSetCodesPerFormat.put(EXTENDED, new ArrayList<>());
|
|
||||||
}
|
|
||||||
underlyingSetCodesPerFormat.get(EXTENDED).add(set.getCode());
|
underlyingSetCodesPerFormat.get(EXTENDED).add(set.getCode());
|
||||||
}
|
}
|
||||||
if (set.getReleaseDate().after(frontierDate)) {
|
if (set.getReleaseDate().after(frontierDate)) {
|
||||||
if (underlyingSetCodesPerFormat.get(FRONTIER) == null) {
|
|
||||||
underlyingSetCodesPerFormat.put(FRONTIER, new ArrayList<>());
|
|
||||||
}
|
|
||||||
underlyingSetCodesPerFormat.get(FRONTIER).add(set.getCode());
|
underlyingSetCodesPerFormat.get(FRONTIER).add(set.getCode());
|
||||||
}
|
}
|
||||||
if (set.getReleaseDate().after(modernDate)) {
|
if (set.getReleaseDate().after(modernDate)) {
|
||||||
if (underlyingSetCodesPerFormat.get(MODERN) == null) {
|
|
||||||
underlyingSetCodesPerFormat.put(MODERN, new ArrayList<>());
|
|
||||||
}
|
|
||||||
underlyingSetCodesPerFormat.get(MODERN).add(set.getCode());
|
underlyingSetCodesPerFormat.get(MODERN).add(set.getCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (underlyingSetCodesPerFormat.get(set.getName()) == null) {
|
// Create the Block formats
|
||||||
underlyingSetCodesPerFormat.put(set.getName(), new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
underlyingSetCodesPerFormat.get(set.getName()).add(set.getCode());
|
|
||||||
|
|
||||||
if (set.getType().equals(SetType.EXPANSION) && set.getBlockName() != null) {
|
if (set.getType().equals(SetType.EXPANSION) && set.getBlockName() != null) {
|
||||||
String blockDisplayName = getBlockDisplayName(set.getBlockName());
|
String blockDisplayName = getBlockDisplayName(set.getBlockName());
|
||||||
if (underlyingSetCodesPerFormat.get(blockDisplayName) == null) {
|
if (underlyingSetCodesPerFormat.get(blockDisplayName) == null) {
|
||||||
|
@ -209,10 +212,13 @@ public class ConstructedFormats {
|
||||||
|
|
||||||
});
|
});
|
||||||
if (!formats.isEmpty()) {
|
if (!formats.isEmpty()) {
|
||||||
|
formats.add(0, CUSTOM);
|
||||||
|
formats.add(0, VINTAGE_LEGACY);
|
||||||
formats.add(0, MODERN);
|
formats.add(0, MODERN);
|
||||||
formats.add(0, FRONTIER);
|
|
||||||
formats.add(0, EXTENDED);
|
formats.add(0, EXTENDED);
|
||||||
|
formats.add(0, FRONTIER);
|
||||||
formats.add(0, STANDARD);
|
formats.add(0, STANDARD);
|
||||||
|
|
||||||
}
|
}
|
||||||
formats.add(0, ALL);
|
formats.add(0, ALL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,13 @@
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.deck;
|
package mage.deck;
|
||||||
|
|
||||||
|
import mage.cards.ExpansionSet;
|
||||||
|
import mage.cards.Sets;
|
||||||
import mage.cards.decks.Constructed;
|
import mage.cards.decks.Constructed;
|
||||||
|
import mage.constants.SetType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -38,7 +40,11 @@ public class Legacy extends Constructed {
|
||||||
|
|
||||||
public Legacy() {
|
public Legacy() {
|
||||||
super("Constructed - 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("Advantageous Proclamation");
|
||||||
banned.add("Amulet of Quoz");
|
banned.add("Amulet of Quoz");
|
||||||
banned.add("Ancestral Recall");
|
banned.add("Ancestral Recall");
|
||||||
|
@ -112,6 +118,6 @@ public class Legacy extends Constructed {
|
||||||
banned.add("Worldknit");
|
banned.add("Worldknit");
|
||||||
banned.add("Yawgmoth's Bargain");
|
banned.add("Yawgmoth's Bargain");
|
||||||
banned.add("Yawgmoth's Will");
|
banned.add("Yawgmoth's Will");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,10 @@
|
||||||
*/
|
*/
|
||||||
package mage.deck;
|
package mage.deck;
|
||||||
|
|
||||||
|
import mage.cards.ExpansionSet;
|
||||||
|
import mage.cards.Sets;
|
||||||
import mage.cards.decks.Constructed;
|
import mage.cards.decks.Constructed;
|
||||||
|
import mage.constants.SetType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -37,7 +40,11 @@ public class Vintage extends Constructed {
|
||||||
|
|
||||||
public Vintage() {
|
public Vintage() {
|
||||||
super("Constructed - 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("Advantageous Proclamation");
|
||||||
banned.add("Amulet of Quoz");
|
banned.add("Amulet of Quoz");
|
||||||
banned.add("Backup Plan");
|
banned.add("Backup Plan");
|
||||||
|
|
|
@ -284,7 +284,7 @@ public class Session {
|
||||||
lockSet = true;
|
lockSet = true;
|
||||||
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
|
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
|
||||||
} else {
|
} 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);
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
if (user == null || !user.isConnected()) {
|
if (user == null || !user.isConnected()) {
|
||||||
|
|
|
@ -48,9 +48,6 @@ public class Constructed extends DeckValidator {
|
||||||
protected List<String> setCodes = new ArrayList<>();
|
protected List<String> setCodes = new ArrayList<>();
|
||||||
protected List<Rarity> rarities = new ArrayList<>();
|
protected List<Rarity> rarities = new ArrayList<>();
|
||||||
|
|
||||||
protected boolean allowAllCustomSets = false;
|
|
||||||
protected Set<String> allowedCustomSetCodes = new HashSet<>();
|
|
||||||
|
|
||||||
public Constructed() {
|
public Constructed() {
|
||||||
super("Constructed");
|
super("Constructed");
|
||||||
}
|
}
|
||||||
|
@ -173,12 +170,7 @@ public class Constructed extends DeckValidator {
|
||||||
* @return Whether the set is legal in this format.
|
* @return Whether the set is legal in this format.
|
||||||
*/
|
*/
|
||||||
protected boolean isSetAllowed(String code) {
|
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);
|
return setCodes.isEmpty() || setCodes.contains(code);
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue