Search in sources :

Example 11 with ColorPredicate

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

the class ParadisePlumeSpellCastTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ObjectColor color = (ObjectColor) game.getState().getValue(getSourceId() + "_color");
    if (color != null) {
        FilterSpell filter = new FilterSpell();
        filter.add(new ColorPredicate(color));
        Spell spell = game.getStack().getSpell(event.getTargetId());
        return (spell != null && filter.match(spell, getSourceId(), getControllerId(), game));
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterSpell(mage.filter.FilterSpell) ObjectColor(mage.ObjectColor) FilterSpell(mage.filter.FilterSpell) Spell(mage.game.stack.Spell)

Example 12 with ColorPredicate

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

the class ParasiticStrixTriggeredAbility method checkInterveningIfClause.

@Override
public boolean checkInterveningIfClause(Game game) {
    FilterPermanent filter = new FilterPermanent();
    filter.add(new ColorPredicate(ObjectColor.BLACK));
    if (game.getBattlefield().countAll(filter, this.controllerId, game) >= 1) {
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent)

Example 13 with ColorPredicate

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

the class ThroatSlitterTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (((DamagedPlayerEvent) event).isCombatDamage() && event.getSourceId().equals(sourceId)) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent("nonblack creature that player controls");
        filter.add(new ControllerIdPredicate(event.getPlayerId()));
        filter.add(Predicates.not(new ColorPredicate(ObjectColor.BLACK)));
        filter.setMessage("nonblack creature controlled by " + game.getPlayer(event.getTargetId()).getLogName());
        this.getTargets().clear();
        this.addTarget(new TargetPermanent(filter));
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent)

Example 14 with ColorPredicate

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

the class TrevaTheRenewerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    ChoiceColor choice = new ChoiceColor();
    if (controller.choose(outcome, choice, game)) {
        game.informPlayers(controller.getLogName() + " chooses " + choice.getColor());
        FilterPermanent filter = new FilterPermanent();
        filter.add(new ColorPredicate(choice.getColor()));
        int cardsWithColor = game.getBattlefield().count(filter, source.getSourceId(), controller.getId(), game);
        if (cardsWithColor > 0) {
            new GainLifeEffect(cardsWithColor).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) ChoiceColor(mage.choices.ChoiceColor) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 15 with ColorPredicate

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

the class GainProtectionFromColorTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (creature != null) {
        FilterCard protectionFilter = (FilterCard) ((ProtectionAbility) ability).getFilter();
        protectionFilter.add(new ColorPredicate(choice.getColor()));
        protectionFilter.setMessage(choice.getChoice());
        ((ProtectionAbility) ability).setFilter(protectionFilter);
        creature.addAbility(ability, source.getSourceId(), game);
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Permanent(mage.game.permanent.Permanent) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

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