* Fixed handling of standard set rotation(fixes #3260).

This commit is contained in:
LevelX2 2017-04-29 23:17:52 +02:00
parent be03cf7a8f
commit ab352a3c6b

View file

@ -25,10 +25,10 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.deck;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.GregorianCalendar;
@ -56,13 +56,18 @@ public class Standard extends Constructed {
}
});
int blocksAdded = 0;
for (Iterator<ExpansionSet> iter = sets.iterator(); iter.hasNext() && blocksAdded < 3; ) {
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 a fall block, 4 blocks are added
blocksToAdd++;
}
blocksAdded++;
}
}
@ -72,4 +77,11 @@ public class Standard extends Constructed {
banned.add("Smuggler's Copter");
banned.add("Felidar Guardian");
}
private static boolean isFallBlock(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) > 8 || cal.get(Calendar.MONTH) < 2;
}
}