Package mage.filter

Examples of mage.filter.FilterPermanent


        Permanent triggeringCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (triggeringCreature == null) {
            triggeringCreature = (Permanent) game.getLastKnownInformation(getTargetPointer().getFirst(game, source), Zone.BATTLEFIELD);
        }
        if (triggeringCreature != null) {
            FilterPermanent filter = new FilterPermanent("another permanent you control that shares a card type with " + triggeringCreature.getName());
            filter.add(Predicates.not(new PermanentIdPredicate(triggeringCreature.getId())));
            filter.add(new ControllerPredicate(TargetController.YOU));
            Set<CardTypePredicate> cardTypes = new HashSet<CardTypePredicate>();
            for (CardType cardType :triggeringCreature.getCardType()) {
                cardTypes.add(new CardTypePredicate(cardType));
            }
            filter.add(Predicates.or(cardTypes));
            TargetPermanent target = new TargetPermanent(1,1,filter, true);
            Player controller = game.getPlayer(source.getControllerId());
            if (controller != null) {
                if (target.canChoose(controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) {
                    Permanent returningCreature = game.getPermanent(target.getFirstTarget());
View Full Code Here


        this.color.setGreen(true);
        this.color.setWhite(true);

        // Other permanents you control have hexproof.
        this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(HexproofAbility.getInstance(), Duration.WhileOnBattlefield, new FilterPermanent(), true)));
    }
View Full Code Here

        super.init(source, game);
        // add all creatures in range
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            for (UUID playerId : controller.getInRange()) {
                FilterPermanent playerFilter = filter.copy();
                playerFilter.add(new OwnerIdPredicate(playerId));
                for (Permanent permanent :game.getBattlefield().getActivePermanents(playerFilter, playerId, game)) {
                    objects.add(permanent.getId());
                }
            }
        }
View Full Code Here

    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            boolean lessCreatures = false;
            boolean lessLife = false;
            FilterPermanent filter= new FilterCreaturePermanent();
            int count = game.getBattlefield().countAll(filter, controller.getId(), game);
            for (UUID uuid : game.getOpponents(controller.getId())) {
                Player opponent = game.getPlayer(uuid);
                if (opponent != null) {
                    if (opponent.getLife() > controller.getLife()) {
View Full Code Here

        Player targetPlayer = game.getPlayer(source.getFirstTarget());
        if (targetPlayer == null) {
            return false;
        }
        targetPlayer.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true);
        FilterPermanent filter = new FilterPermanent("and each creature he or she controls");
        filter.add(new CardTypePredicate(CardType.CREATURE));
        filter.add(new ControllerIdPredicate(targetPlayer.getId()));
        List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
        for (Permanent permanent: permanents) {
            permanent.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true);
        }
        return true;
View Full Code Here

    @Override
    public int calculate(Game game, Ability sourceAbility, Effect effect) {
        int value = 0;
        Permanent permanent = game.getPermanent(sourceAbility.getSourceId());
        if (permanent != null && permanent.getImprinted().size() > 0) {
            FilterPermanent filterPermanent = new FilterPermanent();
            filterPermanent.add(new NamePredicate(game.getCard(permanent.getImprinted().get(0)).getName()));
            value = game.getBattlefield().count(filterPermanent, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
        }
        return value;
    }
View Full Code Here

        if (player != null) {
            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

        this.color.setWhite(true);
        this.power = new MageInt(2);
        this.toughness = new MageInt(2);

        // All Slivers have shroud.
        this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(ShroudAbility.getInstance(), Duration.WhileOnBattlefield, new FilterPermanent("Sliver", "All Slivers"))));
    }
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

class ChromaSpringjackShepherdCount implements DynamicValue {

    @Override
    public int calculate(Game game, Ability sourceAbility, Effect effect) {
        int chroma = 0;
        for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterPermanent(), sourceAbility.getControllerId(), game)) {
            chroma += permanent.getManaCost().getMana().getWhite();
        }
        return chroma;
    }
View Full Code Here

TOP

Related Classes of mage.filter.FilterPermanent

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.