mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
CardCriteria: use constants instead of strings for supertype and subtype
This commit is contained in:
parent
79b30c04f9
commit
5287e1aa4d
3 changed files with 20 additions and 17 deletions
|
@ -11,6 +11,7 @@ import mage.client.util.sets.ConstructedFormats;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SuperType;
|
||||
import mage.util.RandomUtil;
|
||||
import mage.util.TournamentUtil;
|
||||
|
||||
|
@ -153,7 +154,7 @@ public final class DeckGenerator {
|
|||
final CardCriteria nonBasicLandCriteria = new CardCriteria();
|
||||
nonBasicLandCriteria.setCodes(sets);
|
||||
nonBasicLandCriteria.types(CardType.LAND);
|
||||
nonBasicLandCriteria.notSupertypes("Basic");
|
||||
nonBasicLandCriteria.notSupertypes(SuperType.BASIC);
|
||||
|
||||
// Generate basic land cards
|
||||
Map<String, List<CardInfo>> basicLands = generateBasicLands(setsToUse);
|
||||
|
|
|
@ -458,7 +458,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet {
|
|||
cardInfos.addAll(CardRepository.instance.findCards(new CardCriteria()
|
||||
.setCodes(this.code)
|
||||
.rarities(rarity)
|
||||
.subtypes("Lesson")));
|
||||
.subtypes(SubType.LESSON)));
|
||||
cardInfos.removeIf(cardInfo -> cardInfo.getCardNumberAsInt() > maxCardNumberInBooster);
|
||||
}
|
||||
return cardInfos;
|
||||
|
|
|
@ -5,6 +5,8 @@ import com.j256.ormlite.stmt.SelectArg;
|
|||
import com.j256.ormlite.stmt.Where;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -23,9 +25,9 @@ public class CardCriteria {
|
|||
private final List<String> ignoreSetCodes; // sets to ignore, use with little amount of sets (example: ignore sets with snow lands)
|
||||
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<SuperType> supertypes;
|
||||
private final List<SuperType> notSupertypes;
|
||||
private final List<SubType> subtypes;
|
||||
private final List<Rarity> rarities;
|
||||
private Boolean doubleFaced;
|
||||
private boolean black;
|
||||
|
@ -152,17 +154,17 @@ public class CardCriteria {
|
|||
return this;
|
||||
}
|
||||
|
||||
public CardCriteria supertypes(String... supertypes) {
|
||||
public CardCriteria supertypes(SuperType... supertypes) {
|
||||
this.supertypes.addAll(Arrays.asList(supertypes));
|
||||
return this;
|
||||
}
|
||||
|
||||
public CardCriteria notSupertypes(String... supertypes) {
|
||||
public CardCriteria notSupertypes(SuperType... supertypes) {
|
||||
this.notSupertypes.addAll(Arrays.asList(supertypes));
|
||||
return this;
|
||||
}
|
||||
|
||||
public CardCriteria subtypes(String... subtypes) {
|
||||
public CardCriteria subtypes(SubType... subtypes) {
|
||||
this.subtypes.addAll(Arrays.asList(subtypes));
|
||||
return this;
|
||||
}
|
||||
|
@ -251,17 +253,17 @@ public class CardCriteria {
|
|||
clausesCount++;
|
||||
}
|
||||
|
||||
for (String superType : supertypes) {
|
||||
where.like("supertypes", new SelectArg('%' + superType + '%'));
|
||||
for (SuperType superType : supertypes) {
|
||||
where.like("supertypes", new SelectArg('%' + superType.name() + '%'));
|
||||
clausesCount++;
|
||||
}
|
||||
for (String subType : notSupertypes) {
|
||||
where.not().like("supertypes", new SelectArg('%' + subType + '%'));
|
||||
for (SuperType superType : notSupertypes) {
|
||||
where.not().like("supertypes", new SelectArg('%' + superType.name() + '%'));
|
||||
clausesCount++;
|
||||
}
|
||||
|
||||
for (String subType : subtypes) {
|
||||
where.like("subtypes", new SelectArg('%' + subType + '%'));
|
||||
for (SubType subType : subtypes) {
|
||||
where.like("subtypes", new SelectArg('%' + subType.name() + '%'));
|
||||
clausesCount++;
|
||||
}
|
||||
|
||||
|
@ -389,15 +391,15 @@ public class CardCriteria {
|
|||
return notTypes;
|
||||
}
|
||||
|
||||
public List<String> getSupertypes() {
|
||||
public List<SuperType> getSupertypes() {
|
||||
return supertypes;
|
||||
}
|
||||
|
||||
public List<String> getNotSupertypes() {
|
||||
public List<SuperType> getNotSupertypes() {
|
||||
return notSupertypes;
|
||||
}
|
||||
|
||||
public List<String> getSubtypes() {
|
||||
public List<SubType> getSubtypes() {
|
||||
return subtypes;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue