mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
commit
9c202a2902
5 changed files with 69 additions and 57 deletions
|
@ -25,6 +25,11 @@
|
|||
<artifactId>mage-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-deck-constructed</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.jspf</groupId>
|
||||
<artifactId>jspf-core</artifactId>
|
||||
|
|
|
@ -13,6 +13,8 @@ import java.util.Map;
|
|||
import mage.cards.repository.ExpansionInfo;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.constants.SetType;
|
||||
import mage.deck.Standard;
|
||||
|
||||
|
||||
/**
|
||||
* Utility class for constructed formats (expansions and other editions).
|
||||
|
@ -27,6 +29,7 @@ public class ConstructedFormats {
|
|||
public static final String STANDARD = "- Standard";
|
||||
public static final String EXTENDED = "- Extended";
|
||||
public static final String MODERN = "- Modern";
|
||||
public static final Standard STANDARD_CARDS = new Standard();
|
||||
|
||||
private static final Map<String, List<String>> underlyingSetCodesPerFormat = new HashMap<>();
|
||||
private static final List<String> formats = new ArrayList<>();
|
||||
|
@ -57,21 +60,13 @@ public class ConstructedFormats {
|
|||
}
|
||||
|
||||
private static void buildLists() {
|
||||
GregorianCalendar cutoff;
|
||||
// month is zero based so January = 0
|
||||
if (calendar.get(Calendar.MONTH) > 8) {
|
||||
cutoff = new GregorianCalendar(calendar.get(Calendar.YEAR) - 1, Calendar.SEPTEMBER, 1);
|
||||
}
|
||||
else {
|
||||
cutoff = new GregorianCalendar(calendar.get(Calendar.YEAR) - 2, Calendar.SEPTEMBER, 1);
|
||||
}
|
||||
final Map<String, ExpansionInfo> 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());
|
||||
if (set.getType().equals(SetType.CORE) || set.getType().equals(SetType.EXPANSION)) {
|
||||
if (set.getReleaseDate().after(cutoff.getTime())) {
|
||||
if (STANDARD_CARDS.getSetCodes().contains(set.getCode())) {
|
||||
if(underlyingSetCodesPerFormat.get(STANDARD) == null) {
|
||||
underlyingSetCodesPerFormat.put(STANDARD, new ArrayList<String>());
|
||||
}
|
||||
|
|
|
@ -28,13 +28,16 @@
|
|||
|
||||
package mage.deck;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.Sets;
|
||||
import mage.cards.decks.Constructed;
|
||||
import mage.constants.SetType;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import mage.constants.SetType;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -45,18 +48,23 @@ public class Standard extends Constructed {
|
|||
public Standard() {
|
||||
super("Constructed - Standard");
|
||||
GregorianCalendar current = new GregorianCalendar();
|
||||
GregorianCalendar cutoff;
|
||||
// month is zero based so January = 0
|
||||
if (current.get(Calendar.MONTH) > 8) {
|
||||
cutoff = new GregorianCalendar(current.get(Calendar.YEAR) - 1, Calendar.SEPTEMBER, 1);
|
||||
}
|
||||
else {
|
||||
cutoff = new GregorianCalendar(current.get(Calendar.YEAR) - 2, Calendar.SEPTEMBER, 1);
|
||||
}
|
||||
for (ExpansionSet set: Sets.getInstance().values()) {
|
||||
if (set.getReleaseDate().after(cutoff.getTime()) &&
|
||||
(set.getSetType() == SetType.CORE || set.getSetType() == SetType.EXPANSION)){
|
||||
List<ExpansionSet> sets = new ArrayList(Sets.getInstance().values());
|
||||
Collections.sort(sets, new Comparator<ExpansionSet>() {
|
||||
@Override
|
||||
public int compare(final ExpansionSet lhs, ExpansionSet rhs) {
|
||||
return lhs.getReleaseDate().after(rhs.getReleaseDate()) ? -1 : 1;
|
||||
}
|
||||
});
|
||||
int blocksAdded = 0;
|
||||
for (Iterator<ExpansionSet> iter = sets.iterator(); iter.hasNext() && blocksAdded < 3; ) {
|
||||
ExpansionSet set = iter.next();
|
||||
if (set.getSetType() == SetType.CORE || set.getSetType() == SetType.EXPANSION) { // Still adding core sets because of Magic Origins
|
||||
setCodes.add(set.getCode());
|
||||
if (set.getReleaseDate().before(current.getTime()) // This stops spoiled sets from counting as "new" blocks
|
||||
&& set.getParentSet() == null
|
||||
&& set.getSetType() == SetType.EXPANSION) {
|
||||
blocksAdded++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ShadowsOverInnistrad extends ExpansionSet {
|
|||
}
|
||||
|
||||
private ShadowsOverInnistrad() {
|
||||
super("Shadows over Innistrad", "SOI", "mage.sets.shadowsoverinnistrad", new GregorianCalendar(2016, 4, 8).getTime(), SetType.EXPANSION);
|
||||
super("Shadows over Innistrad", "SOI", "mage.sets.shadowsoverinnistrad", new GregorianCalendar(2016, 3, 8).getTime(), SetType.EXPANSION);
|
||||
this.blockName = "Shadows over Innistrad";
|
||||
this.hasBoosters = true;
|
||||
this.numBoosterLands = 1;
|
||||
|
|
|
@ -60,6 +60,10 @@ public class Constructed extends DeckValidator {
|
|||
super(name);
|
||||
}
|
||||
|
||||
public List<String> getSetCodes() {
|
||||
return setCodes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate(Deck deck) {
|
||||
logger.debug("DECK validate start: " + name + " deckname: " + deck.getName());
|
||||
|
|
Loading…
Reference in a new issue