* M15 - Fixed that booster generation did also generate cards that are only included in supplemental products and not in boosters.

This commit is contained in:
LevelX2 2014-07-15 01:08:22 +02:00
parent 6d5ff0c1c4
commit 310347fc8b
4 changed files with 54 additions and 19 deletions

View file

@ -51,5 +51,11 @@ public class Magic2015 extends ExpansionSet {
this.numBoosterUncommon = 3;
this.numBoosterRare = 1;
this.ratioBoosterMythic = 8;
/* There are 15 additional cards, numbered 270284, 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;
}
}

View file

@ -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) {

View file

@ -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<CardInfo> 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<CardInfo> 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<CardInfo> mythic = CardRepository.instance.findCards(criteria);
if (numBoosterLands > 0) {
@ -268,6 +279,9 @@ public abstract class ExpansionSet implements Serializable {
public List<CardInfo> 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);
}

View file

@ -45,13 +45,13 @@ public class CardCriteria {
private String name;
private String rules;
private List<String> setCodes;
private List<CardType> types;
private List<CardType> notTypes;
private List<String> supertypes;
private List<String> notSupertypes;
private List<String> subtypes;
private List<Rarity> rarities;
private final List<String> setCodes;
private final List<CardType> types;
private final List<CardType> notTypes;
private final List<String> supertypes;
private final List<String> notSupertypes;
private final List<String> subtypes;
private final List<Rarity> 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<String>();
this.rarities = new ArrayList<Rarity>();
this.types = new ArrayList<CardType>();
this.notTypes = new ArrayList<CardType>();
this.supertypes = new ArrayList<String>();
this.notSupertypes = new ArrayList<String>();
this.subtypes = new ArrayList<String>();
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);
}