Search in sources :

Example 6 with ColorPredicate

use of mage.filter.predicate.mageobject.ColorPredicate 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)

Example 7 with ColorPredicate

use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.

the class FaithsShieldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject mageObject = game.getObject(source.getSourceId());
    if (controller != null && mageObject != null) {
        if (FatefulHourCondition.instance.apply(game, source)) {
            ChoiceColor choice = new ChoiceColor();
            if (!controller.choose(Outcome.Protect, choice, game)) {
                return false;
            }
            if (choice.getColor() != null) {
                game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
                FilterCard filter = new FilterCard();
                filter.add(new ColorPredicate(choice.getColor()));
                filter.setMessage(choice.getChoice());
                Ability ability = new ProtectionAbility(filter);
                game.addEffect(new GainAbilityControlledEffect(ability, Duration.EndOfTurn), source);
                game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
                return true;
            }
        } else {
            game.addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), source);
            return true;
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) GainProtectionFromColorTargetEffect(mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) MageObject(mage.MageObject) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) ChoiceColor(mage.choices.ChoiceColor) GainAbilityControllerEffect(mage.abilities.effects.common.continuous.GainAbilityControllerEffect)

Example 8 with ColorPredicate

use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.

the class JihadOpponentCondition method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    UUID chosenOpponent = (UUID) game.getState().getValue(getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY);
    FilterPermanent filter = new FilterPermanent();
    filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(getSourceId() + "_color")));
    filter.add(TokenPredicate.FALSE);
    return game.getBattlefield().countAll(filter, chosenOpponent, game) == 0;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) ObjectColor(mage.ObjectColor) UUID(java.util.UUID)

Example 9 with ColorPredicate

use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.

the class JihadOpponentCondition method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID chosenOpponent = (UUID) game.getState().getValue(source.getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY);
    FilterPermanent filter = new FilterPermanent();
    filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(source.getSourceId() + "_color")));
    filter.add(TokenPredicate.FALSE);
    return game.getBattlefield().countAll(filter, chosenOpponent, game) > 0;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) ObjectColor(mage.ObjectColor) UUID(java.util.UUID)

Example 10 with ColorPredicate

use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.

the class NoxiousVaporsEffect method chooseCardForColor.

private void chooseCardForColor(ObjectColor color, Set<Card> chosenCards, Player player, Game game, Ability source) {
    FilterCard filter = new FilterCard();
    filter.add(new ColorPredicate(color));
    TargetCardInHand target = new TargetCardInHand(filter);
    if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            chosenCards.add(card);
        }
    }
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) TargetCardInHand(mage.target.common.TargetCardInHand) FilterCard(mage.filter.FilterCard) FilterNonlandCard(mage.filter.common.FilterNonlandCard) Card(mage.cards.Card)

Aggregations

ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)54 Player (mage.players.Player)28 FilterCard (mage.filter.FilterCard)20 ObjectColor (mage.ObjectColor)18 FilterPermanent (mage.filter.FilterPermanent)16 Permanent (mage.game.permanent.Permanent)16 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)14 ChoiceColor (mage.choices.ChoiceColor)14 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)10 Ability (mage.abilities.Ability)6 UUID (java.util.UUID)5 MageObject (mage.MageObject)5 Card (mage.cards.Card)5 FilterObject (mage.filter.FilterObject)5 CardsImpl (mage.cards.CardsImpl)4 ArrayList (java.util.ArrayList)3 ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)3 TargetPlayer (mage.target.TargetPlayer)3 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)3