Package mage.filter

Examples of mage.filter.Filter


        if (attachedTo == null) {
          if (perm.moveToZone(Zone.GRAVEYARD, null, this, false))
            somethingHappened = true;
        }
        else {
          Filter auraFilter = perm.getSpellAbility().getTargets().get(0).getFilter();
          if (!auraFilter.match(attachedTo) || attachedTo.hasProtectionFrom(perm)) {
            if (perm.moveToZone(Zone.GRAVEYARD, null, this, false))
              somethingHappened = true;
          }
        }
      }
View Full Code Here


    }

    @Override
    public boolean apply(Card input, Game game) {
        final Permanent permanent = game.getPermanent(toBeCheckedPermanentId);
        Filter filter;
        for (Target target : input.getSpellAbility().getTargets()) {
            filter = target.getFilter();
            if (filter.match(permanent, game)) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

    }

    @Override
    public boolean apply(Permanent input, Game game) {
        final Permanent permanent = game.getPermanent(toBeCheckedPermanentId);
        Filter filter;
        for (Target target : input.getSpellAbility().getTargets()) {
            filter = target.getFilter();
            if (filter.match(permanent, game)) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

                                    somethingHappened = true;
                                }
                            }
                        }
                        else {
                            Filter auraFilter = perm.getSpellAbility().getTargets().get(0).getFilter();
                            if (auraFilter instanceof FilterControlledCreaturePermanent) {
                                if (!((FilterControlledCreaturePermanent)auraFilter).match(attachedTo, perm.getId(), perm.getControllerId(), this)
                                        || attachedTo.cantBeEnchantedBy(perm, this)) {
                                    if (movePermanentToGraveyardWithInfo(perm)) {
                                        somethingHappened = true;
                                    }
                                }
                            } else {
                                if (!auraFilter.match(attachedTo, this) || attachedTo.cantBeEnchantedBy(perm, this)) {
                                    // handle bestow unattachment
                                    Card card = this.getCard(perm.getId());
                                    if (card != null && card.getCardType().contains(CardType.CREATURE)) {
                                        UUID wasAttachedTo = perm.getAttachedTo();
                                        perm.attachTo(null, this);
                                        fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED, wasAttachedTo, perm.getId(), perm.getControllerId()));
                                    } else {
                                        if (movePermanentToGraveyardWithInfo(perm)) {
                                            somethingHappened = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else if (target instanceof TargetPlayer) {
                        Player attachedToPlayer = getPlayer(perm.getAttachedTo());
                        if (attachedToPlayer == null) {
                            if (movePermanentToGraveyardWithInfo(perm)) {
                                somethingHappened = true;
                            }
                        }
                        else {
                            Filter auraFilter = perm.getSpellAbility().getTargets().get(0).getFilter();
                            if (!auraFilter.match(attachedToPlayer, this) || attachedToPlayer.hasProtectionFrom(perm, this)) {
                                if (movePermanentToGraveyardWithInfo(perm)) {
                                    somethingHappened = true;
                                }
                            }
                        }
View Full Code Here

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

            if (library.size() < 1) {
                return true;
            }
            CardsImpl cards = new CardsImpl();
            Card card;
            Filter filter = new FilterBasicLandCard();
            do {
                card = library.removeFromTop(game);
                if (card != null) {
                   
                    if (filter.match(card, game)) {
                        player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
                    } else {
                        cards.add(card);
                    }
                }
            } while (library.size() > 0 && card != null && !filter.match(card, game));

            if (!cards.isEmpty()) {
                for (Card cardToGrave: cards.getCards(game)) {
                    player.moveCardToGraveyardWithInfo(cardToGrave, source.getSourceId(), game, Zone.LIBRARY);
                }
View Full Code Here

            if (newPermanent != null) {
                for(Card enchantment : exileZone.getCards(game)) {
                    if (filterAura.match(enchantment, game)) {
                        boolean canTarget = false;
                        for (Target target : enchantment.getSpellAbility().getTargets()) {
                            Filter filter = target.getFilter();
                            if (filter.match(newPermanent, game)) {
                                canTarget = true;
                                break;
                            }
                        }
                        if (!canTarget) {
View Full Code Here

TOP

Related Classes of mage.filter.Filter

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.