Search in sources :

Example 31 with ColorPredicate

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

the class SanctuaryInterveningIfTriggeredAbility method makeAndCondition.

private static Condition makeAndCondition(ObjectColor color1, ObjectColor color2) {
    FilterPermanent filter1 = new FilterPermanent();
    filter1.add(new ColorPredicate(color1));
    Condition condition1 = new PermanentsOnTheBattlefieldCondition(filter1);
    FilterPermanent filter2 = new FilterPermanent();
    filter2.add(new ColorPredicate(color2));
    Condition condition2 = new PermanentsOnTheBattlefieldCondition(filter2);
    return new CompoundCondition(condition1, condition2);
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) CompoundCondition(mage.abilities.condition.CompoundCondition) Condition(mage.abilities.condition.Condition) PermanentsOnTheBattlefieldCondition(mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition) InvertCondition(mage.abilities.condition.InvertCondition) FilterPermanent(mage.filter.FilterPermanent) PermanentsOnTheBattlefieldCondition(mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition) CompoundCondition(mage.abilities.condition.CompoundCondition)

Example 32 with ColorPredicate

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

the class SanctuaryInterveningIfTriggeredAbility method makeOrCondition.

private static Condition makeOrCondition(ObjectColor color1, ObjectColor color2) {
    FilterPermanent filter = new FilterPermanent();
    filter.add(Predicates.or(new ColorPredicate(color1), new ColorPredicate(color2)));
    return new PermanentsOnTheBattlefieldCondition(filter);
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) PermanentsOnTheBattlefieldCondition(mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition)

Example 33 with ColorPredicate

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

the class EarnestFellowshipEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
        if (permanent.getColor(game).hasColor()) {
            List<ColorPredicate> colorPredicates = new ArrayList<>();
            for (ObjectColor color : permanent.getColor(game).getColors()) {
                colorPredicates.add(new ColorPredicate(color));
            }
            FilterCard filterColors = new FilterCard("its colors");
            filterColors.add(Predicates.or(colorPredicates));
            Ability ability = new ProtectionAbility(filterColors);
            permanent.addAbility(ability, source.getSourceId(), game);
        }
    }
    return true;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterCard(mage.filter.FilterCard) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ArrayList(java.util.ArrayList) ObjectColor(mage.ObjectColor) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

Example 34 with ColorPredicate

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

the class PsychicAllergyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    if (player != null) {
        FilterPermanent filter = new FilterPermanent();
        filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(source.getSourceId() + "_color")));
        filter.add(TokenPredicate.FALSE);
        int damage = game.getBattlefield().countAll(filter, player.getId(), game);
        player.damage(damage, source.getSourceId(), source, game);
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) ObjectColor(mage.ObjectColor)

Example 35 with ColorPredicate

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

the class EmptyShrineKannushiProtectionAbility method canTarget.

@Override
public boolean canTarget(MageObject source, Game game) {
    ObjectColor color = new ObjectColor();
    for (Permanent permanent : game.getBattlefield().getAllActivePermanents(controllerId)) {
        ObjectColor permanentColor = permanent.getColor(game);
        if (permanentColor.isColorless()) {
            continue;
        }
        if (permanentColor.isBlack()) {
            color.setBlack(true);
        }
        if (permanentColor.isBlue()) {
            color.setBlue(true);
        }
        if (permanentColor.isGreen()) {
            color.setGreen(true);
        }
        if (permanentColor.isRed()) {
            color.setRed(true);
        }
        if (permanentColor.isWhite()) {
            color.setWhite(true);
        }
    }
    List<Predicate<MageObject>> colorPredicates = new ArrayList<>();
    if (color.isBlack()) {
        colorPredicates.add(new ColorPredicate(ObjectColor.BLACK));
    }
    if (color.isBlue()) {
        colorPredicates.add(new ColorPredicate(ObjectColor.BLUE));
    }
    if (color.isGreen()) {
        colorPredicates.add(new ColorPredicate(ObjectColor.GREEN));
    }
    if (color.isRed()) {
        colorPredicates.add(new ColorPredicate(ObjectColor.RED));
    }
    if (color.isWhite()) {
        colorPredicates.add(new ColorPredicate(ObjectColor.WHITE));
    }
    Filter protectionFilter = new FilterObject("the colors of permanents you control");
    protectionFilter.add(Predicates.or(colorPredicates));
    this.filter = protectionFilter;
    return super.canTarget(source, game);
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Permanent(mage.game.permanent.Permanent) Filter(mage.filter.Filter) FilterObject(mage.filter.FilterObject) ObjectColor(mage.ObjectColor) ArrayList(java.util.ArrayList) Predicate(mage.filter.predicate.Predicate) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate)

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