Search in sources :

Example 41 with ColorPredicate

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

the class JeweledSpiritEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact();
    if (controller != null && controller.choose(outcome, choice, game)) {
        FilterCard protectionFilter = new FilterCard();
        if (choice.isArtifactSelected()) {
            protectionFilter.add(CardType.ARTIFACT.getPredicate());
        } else {
            protectionFilter.add(new ColorPredicate(choice.getColor()));
        }
        protectionFilter.setMessage(choice.getChoice());
        ProtectionAbility protectionAbility = new ProtectionAbility(protectionFilter);
        ContinuousEffect effect = new GainAbilitySourceEffect(protectionAbility, Duration.EndOfTurn);
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) ChoiceColorOrArtifact(mage.choices.ChoiceColorOrArtifact) Player(mage.players.Player) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 42 with ColorPredicate

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

the class SungoldSentinelEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    ChoiceColor choice = new ChoiceColor(true);
    player.choose(outcome, choice, game);
    Ability ability = HexproofBaseAbility.getFirstFromColor(choice.getColor());
    game.addEffect(new GainAbilitySourceEffect(ability, Duration.EndOfTurn), source);
    FilterCreaturePermanent filter = new FilterCreaturePermanent();
    filter.add(new ColorPredicate(choice.getColor()));
    game.addEffect(new CantBeBlockedByAllSourceEffect(filter, Duration.EndOfTurn), source);
    return true;
}
Also used : EntersBattlefieldOrAttacksSourceTriggeredAbility(mage.abilities.common.EntersBattlefieldOrAttacksSourceTriggeredAbility) ConditionalActivatedAbility(mage.abilities.decorator.ConditionalActivatedAbility) HexproofBaseAbility(mage.abilities.keyword.HexproofBaseAbility) Ability(mage.abilities.Ability) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) CantBeBlockedByAllSourceEffect(mage.abilities.effects.common.combat.CantBeBlockedByAllSourceEffect) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 43 with ColorPredicate

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

the class SuddenDemiseDamageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ChoiceColor choice = new ChoiceColor();
    if (controller != null && controller.choose(outcome, choice, game)) {
        final int damage = source.getManaCostsToPay().getX();
        FilterPermanent filter = new FilterCreaturePermanent();
        filter.add(new ColorPredicate(choice.getColor()));
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
            permanent.damage(damage, source.getSourceId(), source, game, false, true);
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ChoiceColor(mage.choices.ChoiceColor)

Example 44 with ColorPredicate

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

the class WardSliverGainAbilityControlledEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (protectionFilter == null) {
        Permanent permanent = game.getPermanent(source.getSourceId());
        if (permanent != null) {
            ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
            if (color != null) {
                protectionFilter = new FilterPermanent(color.getDescription());
                protectionFilter.add(new ColorPredicate(color));
            }
        }
    }
    if (protectionFilter != null) {
        for (Permanent perm : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_ALL_SLIVERS, game)) {
            perm.addAbility(new ProtectionAbility(protectionFilter), source.getSourceId(), game);
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ObjectColor(mage.ObjectColor) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

Example 45 with ColorPredicate

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

the class WashOutEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Set<Card> cardsToReturn = new LinkedHashSet<>();
    ChoiceColor choice = new ChoiceColor();
    if (controller != null && controller.choose(Outcome.ReturnToHand, choice, game)) {
        ObjectColor color = choice.getColor();
        FilterPermanent filter = new FilterPermanent();
        filter.add(new ColorPredicate(color));
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
            cardsToReturn.add((Card) permanent);
        }
        return controller.moveCards(cardsToReturn, Zone.HAND, source, game);
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) ObjectColor(mage.ObjectColor) ChoiceColor(mage.choices.ChoiceColor) 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