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.CardType;
|
||||||
import mage.constants.ColoredManaSymbol;
|
import mage.constants.ColoredManaSymbol;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
|
import mage.constants.SuperType;
|
||||||
import mage.util.RandomUtil;
|
import mage.util.RandomUtil;
|
||||||
import mage.util.TournamentUtil;
|
import mage.util.TournamentUtil;
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ public final class DeckGenerator {
|
||||||
final CardCriteria nonBasicLandCriteria = new CardCriteria();
|
final CardCriteria nonBasicLandCriteria = new CardCriteria();
|
||||||
nonBasicLandCriteria.setCodes(sets);
|
nonBasicLandCriteria.setCodes(sets);
|
||||||
nonBasicLandCriteria.types(CardType.LAND);
|
nonBasicLandCriteria.types(CardType.LAND);
|
||||||
nonBasicLandCriteria.notSupertypes("Basic");
|
nonBasicLandCriteria.notSupertypes(SuperType.BASIC);
|
||||||
|
|
||||||
// Generate basic land cards
|
// Generate basic land cards
|
||||||
Map<String, List<CardInfo>> basicLands = generateBasicLands(setsToUse);
|
Map<String, List<CardInfo>> basicLands = generateBasicLands(setsToUse);
|
||||||
|
|
|
@ -458,7 +458,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet {
|
||||||
cardInfos.addAll(CardRepository.instance.findCards(new CardCriteria()
|
cardInfos.addAll(CardRepository.instance.findCards(new CardCriteria()
|
||||||
.setCodes(this.code)
|
.setCodes(this.code)
|
||||||
.rarities(rarity)
|
.rarities(rarity)
|
||||||
.subtypes("Lesson")));
|
.subtypes(SubType.LESSON)));
|
||||||
cardInfos.removeIf(cardInfo -> cardInfo.getCardNumberAsInt() > maxCardNumberInBooster);
|
cardInfos.removeIf(cardInfo -> cardInfo.getCardNumberAsInt() > maxCardNumberInBooster);
|
||||||
}
|
}
|
||||||
return cardInfos;
|
return cardInfos;
|
||||||
|
|
|
@ -5,6 +5,8 @@ import com.j256.ormlite.stmt.SelectArg;
|
||||||
import com.j256.ormlite.stmt.Where;
|
import com.j256.ormlite.stmt.Where;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
|
import mage.constants.SubType;
|
||||||
|
import mage.constants.SuperType;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
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<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> types;
|
||||||
private final List<CardType> notTypes;
|
private final List<CardType> notTypes;
|
||||||
private final List<String> supertypes;
|
private final List<SuperType> supertypes;
|
||||||
private final List<String> notSupertypes;
|
private final List<SuperType> notSupertypes;
|
||||||
private final List<String> subtypes;
|
private final List<SubType> subtypes;
|
||||||
private final List<Rarity> rarities;
|
private final List<Rarity> rarities;
|
||||||
private Boolean doubleFaced;
|
private Boolean doubleFaced;
|
||||||
private boolean black;
|
private boolean black;
|
||||||
|
@ -152,17 +154,17 @@ public class CardCriteria {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardCriteria supertypes(String... supertypes) {
|
public CardCriteria supertypes(SuperType... supertypes) {
|
||||||
this.supertypes.addAll(Arrays.asList(supertypes));
|
this.supertypes.addAll(Arrays.asList(supertypes));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardCriteria notSupertypes(String... supertypes) {
|
public CardCriteria notSupertypes(SuperType... supertypes) {
|
||||||
this.notSupertypes.addAll(Arrays.asList(supertypes));
|
this.notSupertypes.addAll(Arrays.asList(supertypes));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardCriteria subtypes(String... subtypes) {
|
public CardCriteria subtypes(SubType... subtypes) {
|
||||||
this.subtypes.addAll(Arrays.asList(subtypes));
|
this.subtypes.addAll(Arrays.asList(subtypes));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -251,17 +253,17 @@ public class CardCriteria {
|
||||||
clausesCount++;
|
clausesCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String superType : supertypes) {
|
for (SuperType superType : supertypes) {
|
||||||
where.like("supertypes", new SelectArg('%' + superType + '%'));
|
where.like("supertypes", new SelectArg('%' + superType.name() + '%'));
|
||||||
clausesCount++;
|
clausesCount++;
|
||||||
}
|
}
|
||||||
for (String subType : notSupertypes) {
|
for (SuperType superType : notSupertypes) {
|
||||||
where.not().like("supertypes", new SelectArg('%' + subType + '%'));
|
where.not().like("supertypes", new SelectArg('%' + superType.name() + '%'));
|
||||||
clausesCount++;
|
clausesCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String subType : subtypes) {
|
for (SubType subType : subtypes) {
|
||||||
where.like("subtypes", new SelectArg('%' + subType + '%'));
|
where.like("subtypes", new SelectArg('%' + subType.name() + '%'));
|
||||||
clausesCount++;
|
clausesCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,15 +391,15 @@ public class CardCriteria {
|
||||||
return notTypes;
|
return notTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getSupertypes() {
|
public List<SuperType> getSupertypes() {
|
||||||
return supertypes;
|
return supertypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getNotSupertypes() {
|
public List<SuperType> getNotSupertypes() {
|
||||||
return notSupertypes;
|
return notSupertypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getSubtypes() {
|
public List<SubType> getSubtypes() {
|
||||||
return subtypes;
|
return subtypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue