diff --git a/Mage.Sets/src/mage/sets/Magic2015.java b/Mage.Sets/src/mage/sets/Magic2015.java index 759de70744d..1f4c022760f 100644 --- a/Mage.Sets/src/mage/sets/Magic2015.java +++ b/Mage.Sets/src/mage/sets/Magic2015.java @@ -51,5 +51,11 @@ public class Magic2015 extends ExpansionSet { this.numBoosterUncommon = 3; this.numBoosterRare = 1; this.ratioBoosterMythic = 8; + /* There are 15 additional cards, numbered 270–284, that don't appear in Magic + 2015 booster packs. These are reprints from earlier sets that are present in + some supplemental products, including sample decks and the Deck Builder's Toolkit. + These additional cards have a Magic 2015 expansion symbol and are legal in all + formats in which Magic 2015 is legal. */ + this.maxCardNumberInBooster = 269; } } diff --git a/Mage.Sets/src/mage/sets/avacynrestored/MidvastProtector.java b/Mage.Sets/src/mage/sets/avacynrestored/MidvastProtector.java index b252857dfd8..941226fde58 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/MidvastProtector.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/MidvastProtector.java @@ -56,10 +56,10 @@ public class MidvastProtector extends CardImpl { this.toughness = new MageInt(3); // When Midvast Protector enters the battlefield, target creature you control gains protection from the color of your choice until end of turn. - EntersBattlefieldTriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), false); - ability.addTarget(new TargetControlledCreaturePermanent()); - ability.addChoice(new ChoiceColor()); - this.addAbility(ability); + EntersBattlefieldTriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), false); + ability.addTarget(new TargetControlledCreaturePermanent()); + ability.addChoice(new ChoiceColor()); + this.addAbility(ability); } public MidvastProtector(final MidvastProtector card) { diff --git a/Mage/src/mage/cards/ExpansionSet.java b/Mage/src/mage/cards/ExpansionSet.java index a1835ea17ab..62388aeb577 100644 --- a/Mage/src/mage/cards/ExpansionSet.java +++ b/Mage/src/mage/cards/ExpansionSet.java @@ -64,6 +64,7 @@ public abstract class ExpansionSet implements Serializable { protected int ratioBoosterMythic; protected String packageName; + protected int maxCardNumberInBooster; public ExpansionSet(String name, String code, String packageName, Date releaseDate, SetType setType) { this.name = name; @@ -71,6 +72,7 @@ public abstract class ExpansionSet implements Serializable { this.releaseDate = releaseDate; this.setType = setType; this.packageName = packageName; + this.maxCardNumberInBooster = Integer.MAX_VALUE; } public String getName() { @@ -116,14 +118,23 @@ public abstract class ExpansionSet implements Serializable { CardCriteria criteria = new CardCriteria(); criteria.setCodes(this.code).rarities(Rarity.UNCOMMON).doubleFaced(false); + if (maxCardNumberInBooster != Integer.MAX_VALUE) { + criteria.maxCardNumber(maxCardNumberInBooster); + } List uncommon = CardRepository.instance.findCards(criteria); criteria = new CardCriteria(); criteria.setCodes(this.code).rarities(Rarity.RARE).doubleFaced(false); + if (maxCardNumberInBooster != Integer.MAX_VALUE) { + criteria.maxCardNumber(maxCardNumberInBooster); + } List rare = CardRepository.instance.findCards(criteria); criteria = new CardCriteria(); criteria.setCodes(this.code).rarities(Rarity.MYTHIC).doubleFaced(false); + if (maxCardNumberInBooster != Integer.MAX_VALUE) { + criteria.maxCardNumber(maxCardNumberInBooster); + } List mythic = CardRepository.instance.findCards(criteria); if (numBoosterLands > 0) { @@ -268,6 +279,9 @@ public abstract class ExpansionSet implements Serializable { public List getCommon() { CardCriteria criteria = new CardCriteria(); criteria.setCodes(this.code).rarities(Rarity.COMMON).doubleFaced(false); + if (maxCardNumberInBooster != Integer.MAX_VALUE) { + criteria.maxCardNumber(maxCardNumberInBooster); + } return CardRepository.instance.findCards(criteria); } diff --git a/Mage/src/mage/cards/repository/CardCriteria.java b/Mage/src/mage/cards/repository/CardCriteria.java index 0209020ae4c..ccf251e87a0 100644 --- a/Mage/src/mage/cards/repository/CardCriteria.java +++ b/Mage/src/mage/cards/repository/CardCriteria.java @@ -45,13 +45,13 @@ public class CardCriteria { private String name; private String rules; - private List setCodes; - private List types; - private List notTypes; - private List supertypes; - private List notSupertypes; - private List subtypes; - private List rarities; + private final List setCodes; + private final List types; + private final List notTypes; + private final List supertypes; + private final List notSupertypes; + private final List subtypes; + private final List rarities; private Boolean doubleFaced; private boolean black; private boolean blue; @@ -62,15 +62,16 @@ public class CardCriteria { private String sortBy; private Long start; private Long count; + private int maxCardNumber; public CardCriteria() { - this.setCodes = new ArrayList(); - this.rarities = new ArrayList(); - this.types = new ArrayList(); - this.notTypes = new ArrayList(); - this.supertypes = new ArrayList(); - this.notSupertypes = new ArrayList(); - this.subtypes = new ArrayList(); + this.setCodes = new ArrayList<>(); + this.rarities = new ArrayList<>(); + this.types = new ArrayList<>(); + this.notTypes = new ArrayList<>(); + this.supertypes = new ArrayList<>(); + this.notSupertypes = new ArrayList<>(); + this.subtypes = new ArrayList<>(); this.black = true; this.blue = true; @@ -78,6 +79,8 @@ public class CardCriteria { this.red = true; this.white = true; this.colorless = true; + + this.maxCardNumber = Integer.MAX_VALUE; } public CardCriteria black(boolean black) { @@ -170,6 +173,11 @@ public class CardCriteria { return this; } + public CardCriteria maxCardNumber(int maxCardNumber) { + this.maxCardNumber = maxCardNumber; + return this; + } + public CardCriteria setOrderBy(String sortBy) { this.sortBy = sortBy; return this; @@ -211,7 +219,7 @@ public class CardCriteria { } - if (types.size() != 7) { //if all types selected - no selection needed + if (types.size() != 9) { //if all types selected - no selection needed for (CardType type : types) { where.like("types", new SelectArg('%' + type.name() + '%')); } @@ -273,12 +281,19 @@ public class CardCriteria { } } + if (maxCardNumber != Integer.MAX_VALUE) { + where.le("cardNumber", maxCardNumber); + clausesCount++; + } + if (clausesCount > 0) { where.and(clausesCount); } else { where.eq("cardNumber", new SelectArg(0)); } + + if (start != null) { qb.offset(start); }