Search in sources :

Example 21 with ColorPredicate

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

the class SamiteElderEffect method apply.

public boolean apply(Game game, Ability source) {
    Permanent target = game.getPermanent(source.getFirstTarget());
    if (target != null) {
        for (ObjectColor color : target.getColor(game).getColors()) {
            FilterCard filter = new FilterCard(color.getDescription());
            filter.add(new ColorPredicate(color));
            game.addEffect(new GainAbilityControlledEffect(new ProtectionAbility(filter), Duration.EndOfTurn, new FilterControlledCreaturePermanent()), source);
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) ObjectColor(mage.ObjectColor) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent)

Example 22 with ColorPredicate

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

the class ConvokeEffect method addSpecialAction.

@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && game.getBattlefield().containsControlled(filterUntapped, source, game, 1)) {
        if (source.getAbilityType() == AbilityType.SPELL) {
            SpecialAction specialAction = new ConvokeSpecialAction(unpaid, this);
            specialAction.setControllerId(source.getControllerId());
            specialAction.setSourceId(source.getSourceId());
            // create filter for possible creatures to tap
            FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
            filter.add(TappedPredicate.UNTAPPED);
            if (unpaid.getMana().getGeneric() == 0) {
                List<ColorPredicate> colorPredicates = new ArrayList<>();
                if (unpaid.getMana().getBlack() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.BLACK));
                }
                if (unpaid.getMana().getBlue() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.BLUE));
                }
                if (unpaid.getMana().getRed() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.RED));
                }
                if (unpaid.getMana().getGreen() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.GREEN));
                }
                if (unpaid.getMana().getWhite() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.WHITE));
                }
                filter.add(Predicates.or(colorPredicates));
            }
            Target target = new TargetControlledCreaturePermanent(1, 1, filter, true);
            target.setTargetName("tap creature card as convoke's pay");
            specialAction.addTarget(target);
            if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
                game.getState().getSpecialActions().add(specialAction);
            }
        }
    }
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) SpecialAction(mage.abilities.SpecialAction) Target(mage.target.Target) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ArrayList(java.util.ArrayList) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 23 with ColorPredicate

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

the class DromarTheBanisherEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        ChoiceColor choice = new ChoiceColor();
        if (player.choose(outcome, choice, game)) {
            game.informPlayers(player.getLogName() + " chooses " + choice.getChoice());
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(new ColorPredicate(choice.getColor()));
            new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ReturnToHandFromBattlefieldAllEffect(mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 24 with ColorPredicate

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

the class ScryingGlassEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetOpponent = game.getPlayer(source.getFirstTarget());
    ChoiceColor color = new ChoiceColor();
    int amount = 0;
    if (controller != null && targetOpponent != null) {
        amount = controller.getAmount(1, Integer.MAX_VALUE, "Choose a number", game);
        controller.choose(Outcome.Discard, color, game);
        FilterCard filter = new FilterCard();
        filter.add(new ColorPredicate(color.getColor()));
        targetOpponent.revealCards(source, targetOpponent.getHand(), game);
        if (targetOpponent.getHand().count(filter, game) == amount) {
            game.informPlayers(controller.getLogName() + " has chosen the exact number and color of the revealed cards from " + targetOpponent.getName() + "'s hand. They draw a card.");
            controller.drawCards(1, source, game);
            return true;
        } else {
            game.informPlayers(controller.getLogName() + " has chosen incorrectly and will not draw a card.");
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) ChoiceColor(mage.choices.ChoiceColor)

Example 25 with ColorPredicate

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

the class AnHavvaInnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent("green creatures");
        filter.add(new ColorPredicate(ObjectColor.GREEN));
        int greenCreatures = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
        player.gainLife(greenCreatures + 1, game, source);
    }
    return true;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent)

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