Updating standard (don't merge until 9/24) (#8297)

* removed rotated cards from standard ban list

* updated standard legality to handle sets releasing after fall set inn the same year

* some more updates to standard

* small change
This commit is contained in:
Evan Kranzler 2021-09-24 22:07:12 -04:00 committed by GitHub
parent c6e385e321
commit b895611c4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 46 deletions

View file

@ -5,7 +5,11 @@ import mage.cards.Sets;
import mage.cards.decks.Constructed;
import mage.constants.SetType;
import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author BetaSteward_at_googlemail.com
@ -17,61 +21,39 @@ public class Standard extends Constructed {
setCodes.addAll(makeLegalSets());
banned.add("Agent of Treachery");
banned.add("Cauldron Familiar");
banned.add("Escape to the Wilds");
banned.add("Field of the Dead");
banned.add("Fires of Invention");
banned.add("Growth Spiral");
banned.add("Lucky Clover");
banned.add("Oko, Thief of Crowns");
banned.add("Omnath, Locus of Creation");
banned.add("Once Upon a Time");
banned.add("Teferi, Time Raveler");
banned.add("Uro, Titan of Nature's Wrath");
banned.add("Wilderness Reclamation");
banned.add("Veil of Summer");
}
private static boolean isFallSet(ExpansionSet set) {
Calendar cal = Calendar.getInstance();
cal.setTime(set.getReleaseDate());
// Fall sets are normally released during or after September
return set.getSetType() == SetType.EXPANSION && (cal.get(Calendar.MONTH) > 7);
// Fall sets are normally released during or after September and before November
return set.getSetType() == SetType.EXPANSION
&& Calendar.SEPTEMBER <= cal.get(Calendar.MONTH)
&& cal.get(Calendar.MONTH) < Calendar.NOVEMBER;
}
static List<String> makeLegalSets() {
List<String> codes = new ArrayList<>();
GregorianCalendar current = new GregorianCalendar();
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 fallSetsAdded = 0;
Date earliestDate = null;
// Get the second most recent fall set that's been released.
for (ExpansionSet set : sets) {
if (set.getReleaseDate().after(current.getTime())) {
continue;
}
if (isFallSet(set)) {
fallSetsAdded++;
if (fallSetsAdded == 2) {
earliestDate = set.getReleaseDate();
break;
}
}
}
for (ExpansionSet set : sets) {
boolean isDateCompatible = earliestDate != null && !set.getReleaseDate().before(earliestDate) /*!set.getReleaseDate().after(current.getTime())*/; // no after date restrict for early tests and beta
if (set.getSetType().isStandardLegal() && isDateCompatible) {
codes.add(set.getCode());
}
}
return codes;
Date earliestDate = Sets
.getInstance()
.values()
.stream()
.filter(set -> !set.getReleaseDate().after(current.getTime()))
.filter(Standard::isFallSet)
.sorted(ExpansionSet.getComparator())
.skip(1)
.findFirst()
.get()
.getReleaseDate();
return Sets.getInstance()
.values()
.stream()
.filter(set -> set.getSetType().isStandardLegal())
.filter(set -> !set.getReleaseDate().before(earliestDate))
// .filter(set -> !set.getReleaseDate().after(current.getTime())) // no after date restrict for early tests and beta
.map(ExpansionSet::getCode)
.collect(Collectors.toList());
}
}

View file

@ -87,6 +87,19 @@ public abstract class ExpansionSet implements Serializable {
}
}
private static enum ExpansionSetComparator implements Comparator<ExpansionSet> {
instance;
@Override
public int compare(ExpansionSet lhs, ExpansionSet rhs) {
return lhs.getReleaseDate().after(rhs.getReleaseDate()) ? -1 : 1;
}
}
public static ExpansionSetComparator getComparator() {
return ExpansionSetComparator.instance;
}
protected final List<SetCardInfo> cards = new ArrayList<>();
protected String name;