Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from Sep 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -5,7 +5,11 @@
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
Expand All @@ -17,61 +21,39 @@ public Standard() {

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());
}
}
13 changes: 13 additions & 0 deletions Mage/src/main/java/mage/cards/ExpansionSet.java
Expand Up @@ -87,6 +87,19 @@ public boolean isFullArt() {
}
}

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;
Expand Down