mirror of
https://github.com/correl/mage.git
synced 2025-04-11 17:00:08 -09:00
reworked standard legality to handle the return of core sets and removal of blocks
This commit is contained in:
parent
ed5e145ec0
commit
633dcd927d
2 changed files with 53 additions and 37 deletions
Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.deck;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -31,33 +30,42 @@ public class Brawl extends Constructed {
|
|||
return lhs.getReleaseDate().after(rhs.getReleaseDate()) ? -1 : 1;
|
||||
}
|
||||
});
|
||||
int blocksAdded = 0;
|
||||
int blocksToAdd = 3;
|
||||
for (Iterator<ExpansionSet> iter = sets.iterator(); iter.hasNext() && blocksAdded < blocksToAdd;) {
|
||||
ExpansionSet set = iter.next();
|
||||
if (set.getSetType() == SetType.CORE || set.getSetType() == SetType.EXPANSION || set.getSetType() == SetType.SUPPLEMENTAL_STANDARD_LEGAL) { // 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) {
|
||||
if (blocksAdded == 0 && !isFallBlock(set)) { // if the most current block is no fall block, 4 blocks are added
|
||||
blocksToAdd++;
|
||||
}
|
||||
blocksAdded++;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get all sets released on or after the second most recent fall set's release
|
||||
for (ExpansionSet set : sets) {
|
||||
if ((set.getSetType() == SetType.CORE
|
||||
|| set.getSetType() == SetType.EXPANSION
|
||||
|| set.getSetType() == SetType.SUPPLEMENTAL_STANDARD_LEGAL)
|
||||
&& (!set.getReleaseDate().before(earliestDate)
|
||||
&& !set.getReleaseDate().after(current.getTime()))) {
|
||||
setCodes.add(set.getCode());
|
||||
}
|
||||
}
|
||||
banned.add("Baral, Chief of Compliance");
|
||||
banned.add("Smuggler's Copter");
|
||||
banned.add("Sorcerers' Spyglass");
|
||||
}
|
||||
|
||||
private static boolean isFallBlock(ExpansionSet set) {
|
||||
private static boolean isFallSet(ExpansionSet set) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(set.getReleaseDate());
|
||||
// Sets from fall block are normally released in September and January
|
||||
return cal.get(Calendar.MONTH) > 7 || cal.get(Calendar.MONTH) < 2;
|
||||
// Fall sets are normally released during or after September
|
||||
return set.getSetType() == SetType.EXPANSION
|
||||
&& (cal.get(Calendar.MONTH) > 7);
|
||||
}
|
||||
|
||||
public Brawl(String name) {
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
|
||||
package mage.deck;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.Sets;
|
||||
|
@ -29,23 +28,31 @@ public class Standard extends Constructed {
|
|||
return lhs.getReleaseDate().after(rhs.getReleaseDate()) ? -1 : 1;
|
||||
}
|
||||
});
|
||||
int blocksAdded = 0;
|
||||
int blocksToAdd = 3;
|
||||
for (Iterator<ExpansionSet> iter = sets.iterator(); iter.hasNext() && blocksAdded < blocksToAdd;) {
|
||||
ExpansionSet set = iter.next();
|
||||
if (set.getSetType() == SetType.CORE || set.getSetType() == SetType.EXPANSION || set.getSetType() == SetType.SUPPLEMENTAL_STANDARD_LEGAL) { // 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) {
|
||||
if (blocksAdded == 0 && !isFallBlock(set)) { // if the most current block is no fall block, 4 blocks are added
|
||||
blocksToAdd++;
|
||||
}
|
||||
blocksAdded++;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get all sets released on or after the second most recent fall set's release
|
||||
for (ExpansionSet set : sets) {
|
||||
if ((set.getSetType() == SetType.CORE
|
||||
|| set.getSetType() == SetType.EXPANSION
|
||||
|| set.getSetType() == SetType.SUPPLEMENTAL_STANDARD_LEGAL)
|
||||
&& (!set.getReleaseDate().before(earliestDate)
|
||||
&& !set.getReleaseDate().after(current.getTime()))) {
|
||||
setCodes.add(set.getCode());
|
||||
}
|
||||
}
|
||||
banned.add("Attune with Aether"); // since 2018-01-15
|
||||
banned.add("Aetherworks Marvel");
|
||||
banned.add("Felidar Guardian");
|
||||
|
@ -55,10 +62,11 @@ public class Standard extends Constructed {
|
|||
banned.add("Smuggler's Copter");
|
||||
}
|
||||
|
||||
private static boolean isFallBlock(ExpansionSet set) {
|
||||
private static boolean isFallSet(ExpansionSet set) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(set.getReleaseDate());
|
||||
// Sets from fall block are normally released in September and January
|
||||
return cal.get(Calendar.MONTH) > 7 || cal.get(Calendar.MONTH) < 2;
|
||||
// Fall sets are normally released during or after September
|
||||
return set.getSetType() == SetType.EXPANSION
|
||||
&& (cal.get(Calendar.MONTH) > 7);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue