Search in sources :

Example 1 with CardTextPredicate

use of mage.filter.predicate.card.CardTextPredicate 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;
}
Also used : FilterCard(mage.filter.FilterCard) CardTextPredicate(mage.filter.predicate.card.CardTextPredicate) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) ExpansionSetPredicate(mage.filter.predicate.card.ExpansionSetPredicate) Predicate(mage.filter.predicate.Predicate) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) ColorlessPredicate(mage.filter.predicate.mageobject.ColorlessPredicate) CardTextPredicate(mage.filter.predicate.card.CardTextPredicate) ExpansionSetPredicate(mage.filter.predicate.card.ExpansionSetPredicate)

Aggregations

FilterCard (mage.filter.FilterCard)1 Predicate (mage.filter.predicate.Predicate)1 CardTextPredicate (mage.filter.predicate.card.CardTextPredicate)1 ExpansionSetPredicate (mage.filter.predicate.card.ExpansionSetPredicate)1 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)1 ColorlessPredicate (mage.filter.predicate.mageobject.ColorlessPredicate)1