Package mage.filter.predicate.mageobject

Examples of mage.filter.predicate.mageobject.ColorPredicate


    }

    @Override
    public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
        FilterPermanent filter = new FilterPermanent("white permanent");
        filter.add(new ColorPredicate(ObjectColor.WHITE));

        if (game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0) {
            card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
        } else {
            card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
View Full Code Here


    @Override
    public boolean apply(Game game, Ability source) {
        Player you = game.getPlayer(source.getControllerId());
        Cards cards = new CardsImpl();
        FilterCard filterWhite = new FilterCard("white card");
        filterWhite.add(new ColorPredicate(ObjectColor.WHITE));
        FilterCard filterBlue = new FilterCard("blue card");
        filterBlue.add(new ColorPredicate(ObjectColor.BLUE));
        FilterCard filterBlack = new FilterCard("black card");
        filterBlack.add(new ColorPredicate(ObjectColor.BLACK));
        FilterCard filterRed = new FilterCard("red card");
        filterRed.add(new ColorPredicate(ObjectColor.RED));
        FilterCard filterGreen = new FilterCard("green card");
        filterGreen.add(new ColorPredicate(ObjectColor.GREEN));
        TargetCardInLibrary targetWhite = new TargetCardInLibrary(filterWhite);
        TargetCardInLibrary targetBlue = new TargetCardInLibrary(filterBlue);
        TargetCardInLibrary targetBlack = new TargetCardInLibrary(filterBlack);
        TargetCardInLibrary targetRed = new TargetCardInLibrary(filterRed);
        TargetCardInLibrary targetGreen = new TargetCardInLibrary(filterGreen);
View Full Code Here

            ChoiceColor choice = new ChoiceColor();
            player.choose(outcome, choice, game);
            if (choice.getColor() != null) {
                game.informPlayers(new StringBuilder(player.getName()).append(" chooses ").append(choice.getColor()).toString());
                FilterPermanent filter = new FilterPermanent();
                filter.add(new ColorPredicate(choice.getColor()));
                new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
                return true;
            }
        }
        return false;
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Permanent creature = game.getPermanent(source.getSourceId());
        if (creature != null) {
            ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
            protectionFilter.add(new ColorPredicate(choice.getColor()));
            protectionFilter.setMessage(choice.getChoice());
            ProtectionAbility ability = new ProtectionAbility(protectionFilter);
            creature.addAbility(ability, source.getSourceId(), game);
            return true;
        }
View Full Code Here

        ChoiceColor choice = new ChoiceColor();
        controller.choose(outcome, choice, game);
        if (choice.getColor() != null) {
            game.informPlayers(new StringBuilder(controller.getName()).append(" chooses ").append(choice.getColor()).toString());
            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 CreateTokenEffect(new SaprolingToken(), cardsWithColor).apply(game, source);
            }
            return true;
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Permanent creature = game.getPermanent(source.getSourceId());
        if (creature != null) {
            ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
            protectionFilter.add(new ColorPredicate(choice.getColor()));
            protectionFilter.setMessage(choice.getChoice());
            ((ProtectionAbility)ability).setFilter(protectionFilter);
            creature.addAbility(ability, source.getSourceId(), game);
            return true;
        }
View Full Code Here

        if (permanent == null) {
            return false;
        }

        FilterPermanent filter = new FilterPermanent("black permanent");
        filter.add(new ColorPredicate(ObjectColor.BLACK));

        if (game.getBattlefield().countAll(filter, source.getControllerId(), game) == 0) {
            permanent.damage(2, source.getSourceId(), game, false, true);
        } else {
            permanent.destroy(source.getSourceId(), game, false);
View Full Code Here

    }

    @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;
    }
View Full Code Here

    public boolean apply(Game game, Ability source) {
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
            if (permanent.getColor().hasColor()) {
                List<ColorPredicate> colorPredicates = new ArrayList<>();
                for (ObjectColor color : permanent.getColor().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);
View Full Code Here

                && ((DamagedPlayerEvent) event).isCombatDamage()) {
            Player player = game.getPlayer(event.getTargetId());
            if (player != null) {
                FilterPermanent filter = new FilterPermanent("black or red permanent controlled by " + player.getName());
                filter.add(Predicates.or(
                    new ColorPredicate(ObjectColor.BLACK),
                    new ColorPredicate(ObjectColor.RED)));
                filter.add(new ControllerIdPredicate(event.getTargetId()));

                this.getTargets().clear();
                this.addTarget(new TargetPermanent(filter));
                return true;
View Full Code Here

TOP

Related Classes of mage.filter.predicate.mageobject.ColorPredicate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.