Package mage.filter

Examples of mage.filter.FilterPermanent


    @Override
    public boolean apply(Game game, Ability source) {
        Permanent permanent = game.getPermanent(source.getFirstTarget());
        if (permanent != null) {
            FilterPermanent filter = new FilterPermanent();
            filter.add(new NamePredicate(permanent.getName()));
            for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
                perm.moveToZone(Zone.HAND, source.getSourceId(), game, false);
            }
        }
        return true;
View Full Code Here


        // Target player loses 1 life, discards a card, then sacrifices a permanent.
        this.getSpellAbility().addTarget(new TargetPlayer());
        this.getSpellAbility().addEffect(new LoseLifeTargetEffect(1));
        this.getSpellAbility().addEffect(new DiscardTargetEffect(1));
        this.getSpellAbility().addEffect(new SacrificeEffect(new FilterPermanent(),1,"then that player"));

        // Cipher (Then you may exile this spell card encoded on a creature you control. Whenever that creature deals combat damage to a player, its controller may cast a copy of the encoded card without paying its mana cost.)
        this.getSpellAbility().addEffect(new CipherEffect());

    }
View Full Code Here

        }

        @Override
        public boolean apply(Game game, Ability source) {

            FilterPermanent filterEnchantments = new FilterPermanent();
            filterEnchantments.add(new CardTypePredicate(CardType.ENCHANTMENT));

            for (Permanent permanent : game.getBattlefield().getActivePermanents(filterEnchantments, source.getControllerId(), source.getSourceId(), game)) {
                Player controller = game.getPlayer(permanent.getControllerId());
                if (controller != null) {
                    controller.damage(2, permanent.getId(), game, false, true);
                    game.informPlayers("2 damage assigned to " + controller.getName() + " from " + permanent.getName());
                }
            }

            filterEnchantments.add(new SubtypePredicate("Aura"));
            for (Permanent auraEnchantment : game.getBattlefield().getActivePermanents(filterEnchantments, source.getControllerId(), source.getSourceId(), game)) {
                if (auraEnchantment.getAttachedTo() != null) {
                    Permanent attachedToCreature = game.getPermanent(auraEnchantment.getAttachedTo());
                    if (attachedToCreature != null && attachedToCreature.getCardType().contains(CardType.CREATURE)) {
                        attachedToCreature.damage(2, auraEnchantment.getId(), game, false, true);
View Full Code Here

        this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(4)), false));

        // +1: Tap target permanent, then untap another target permanent.
        LoyaltyAbility ability1 = new LoyaltyAbility(new RalZarekTapUntapEffect(), 1);
        ability1.addTarget(new TargetPermanent(2, 2, new FilterPermanent(), false));
        this.addAbility(ability1);

        // -2: Ral Zarek deals 3 damage to target creature or player.
        LoyaltyAbility ability2 = new LoyaltyAbility(new DamageTargetEffect(3), -2);
        ability2.addTarget(new TargetCreatureOrPlayer());
View Full Code Here

        this.expansionSetCode = "DGM";
        this.color.setBlue(true);

        // You may tap or untap target permanent, then you may tap or untap another target permanent
        this.getSpellAbility().addEffect(new HiddenStringsEffect());
        this.getSpellAbility().addTarget(new TargetPermanent(0, 2, new FilterPermanent(), false));

        // Cipher
        this.getSpellAbility().addEffect(new CipherEffect());
    }
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());
        Player targetPlayer = game.getPlayer(source.getFirstTarget());
        if (player != null && targetPlayer != null) {
            int count = game.getBattlefield().countAll(new FilterPermanent(), targetPlayer.getId(), game);
            TargetPermanent target = new TargetPermanent(0, count, new FilterPermanent("permanents to put in the first pile"), false);
            List<Permanent> pile1 = new ArrayList<>();
            target.setRequired(false);
            if (player.choose(Outcome.Neutral, target, source.getSourceId(), game)) {
                List<UUID> targets = target.getTargets();
                for (UUID targetId : targets) {
View Full Code Here

        Player controller = game.getPlayer(source.getControllerId());
        Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
        if (permanent != null && controller != null) {
            Player owner = game.getPlayer(permanent.getOwnerId());
            if (owner != null) {
                int plains = game.getBattlefield().countAll(new FilterPermanent("Plains", "Plains you control"), source.getControllerId(), game);
                int xValue = Math.min(plains, owner.getLibrary().size());
                Cards cards = new CardsImpl();
                Deque<UUID> cardIds = new LinkedList<>();
                for (int i = 0; i < xValue; i++) {
                    Card card = owner.getLibrary().removeFromTop(game);
View Full Code Here

    }

    @Override
    public boolean applies(GameEvent event, Ability source, Game game) {
        if (event.getType() == GameEvent.EventType.DECLARE_ATTACKER && source.getSourceId().equals(event.getSourceId())) {
            FilterPermanent filter = new FilterPermanent();
            filter.add(new SubtypePredicate("Island"));

            if (game.getBattlefield().countAll(filter, event.getTargetId(), game) == 0) {
                return true;
            }
        }
View Full Code Here

        if (targetPlayer != null) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(new ControllerIdPredicate(targetPlayer.getId()));
            RestrictionEffect effect = new CantBlockAllEffect(filter, Duration.EndOfTurn);
            game.addEffect(effect, source);
            FilterPermanent filter2 = new FilterPermanent();
            filter2.add(new ControllerIdPredicate(targetPlayer.getId()));
            filter2.add(Predicates.or(new ColorPredicate(ObjectColor.WHITE),
                    new ColorPredicate(ObjectColor.BLUE)));
            filter2.add(new CardTypePredicate(CardType.CREATURE));
            for (Permanent creature : game.getBattlefield().getAllActivePermanents(filter2, targetPlayer.getId(), game)) {
                creature.damage(1, source.getSourceId(), game, false, true);
            }
            return true;
        }
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            int islands = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
            FilterPermanent creatureFilter = new FilterCreaturePermanent();
            creatureFilter.add(new ControllerPredicate(TargetController.OPPONENT));
            creatureFilter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, islands +1));
            for (Permanent permanent: game.getBattlefield().getActivePermanents(creatureFilter, source.getControllerId(), source.getSourceId(), game)) {
                controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
            }
            return true;
        }
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.