use of mage.filter.predicate.card.ExpansionSetPredicate in project mage by magefree.
the class CardSelector method buildFilter.
private FilterCard buildFilter() {
FilterCard filter = new FilterCard();
String name = jTextFieldSearch.getText().trim();
filter.add(new CardTextPredicate(name, chkNames.isSelected(), chkTypes.isSelected(), chkRules.isSelected(), chkUnique.isSelected()));
if (limited) {
List<Predicate<MageObject>> predicates = new ArrayList<>();
if (this.tbGreen.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.GREEN));
}
if (this.tbRed.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.RED));
}
if (this.tbBlack.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.BLACK));
}
if (this.tbBlue.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.BLUE));
}
if (this.tbWhite.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.WHITE));
}
if (this.tbColorless.isSelected()) {
predicates.add(ColorlessPredicate.instance);
}
filter.add(Predicates.or(predicates));
predicates.clear();
if (this.tbLand.isSelected()) {
predicates.add(CardType.LAND.getPredicate());
}
if (this.tbArifiacts.isSelected()) {
predicates.add(CardType.ARTIFACT.getPredicate());
}
if (this.tbCreatures.isSelected()) {
predicates.add(CardType.CREATURE.getPredicate());
}
if (this.tbEnchantments.isSelected()) {
predicates.add(CardType.ENCHANTMENT.getPredicate());
}
if (this.tbInstants.isSelected()) {
predicates.add(CardType.INSTANT.getPredicate());
}
if (this.tbSorceries.isSelected()) {
predicates.add(CardType.SORCERY.getPredicate());
}
if (this.tbPlaneswalkers.isSelected()) {
predicates.add(CardType.PLANESWALKER.getPredicate());
}
filter.add(Predicates.or(predicates));
List<String> filteredSets = getFilteredSets();
if (!filteredSets.isEmpty()) {
List<Predicate<Card>> expansionPredicates = new ArrayList<>();
for (String setCode : filteredSets) {
expansionPredicates.add(new ExpansionSetPredicate(setCode));
}
filter.add(Predicates.or(expansionPredicates));
}
}
return filter;
}
Aggregations