Package mage.filter

Examples of mage.filter.FilterPermanent


    }

    @Override
    public boolean apply(Game game, Ability source) {
        boolean applied = false;
        FilterPermanent filter = new FilterPermanent();
        filter.add(Predicates.or(new SubtypePredicate("Equipment"),
                new SubtypePredicate("Aura")));
        Permanent targetCreature = game.getPermanent(source.getFirstTarget());
        if (targetCreature != null
                && targetCreature.getAttachments().size() > 0) {
            for (Permanent attachment : game.getBattlefield().getAllActivePermanents(filter, game)) {
View Full Code Here


        super(effect);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        FilterPermanent filter = new FilterPermanent();
        ObjectColor color = ((ChoiceColor) source.getChoices().get(0)).getColor();
        if (color != null) {
            filter.add(new ColorPredicate(color));

            for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
                permanent.moveToZone(Zone.HAND, source.getSourceId(), game, true);
            }
            return true;
View Full Code Here

        this.color.setBlue(true);
        this.power = new MageInt(0);
        this.toughness = new MageInt(1);

        FilterPermanent seasinger = new FilterPermanent();
        seasinger.add(new ControllerPredicate(TargetController.YOU));
        seasinger.add(new CardIdPredicate(this.getId()));

        // When you control no Islands, sacrifice Seasinger.
        this.addAbility(new SeasingerTriggeredAbility());

        // You may choose not to untap Seasinger during your untap step.
View Full Code Here

    }

    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        DamageCreatureEvent damageEvent = (DamageCreatureEvent) event;
        new SacrificeControllerEffect(new FilterPermanent(), damageEvent.getAmount(), "").apply(game, source);
        return true;
    }
View Full Code Here

        this.color.setBlack(true);
        this.power = new MageInt(1);
        this.toughness = new MageInt(1);

        // {X}: Crypt Rats deals X damage to each creature and each player. Spend only black mana this way.
        Effect effect = new DamageEverythingEffect(new ManacostVariableValue(), new FilterPermanent());
        effect.setText("{this} deals X damage to each creature and each player. Spend only black mana this way");
        Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect,new ManaCostsImpl("{X}"));
        VariableCost variableCost = ability.getManaCostsToPay().getVariableCosts().get(0);
        if (variableCost instanceof VariableManaCost) {
            ((VariableManaCost) variableCost).setFilter(filterBlack);
View Full Code Here

            for (Effect effect : ability.getEffects()) {
                if (effect instanceof DestroyTargetEffect) {
                    Player attackedPlayer = game.getPlayer(effect.getTargetPointer().getFirst(game, ability));
                    if (attackedPlayer != null) {
                        ability.getTargets().clear();
                        FilterPermanent filterEnchantment = new FilterEnchantmentPermanent("enchantment attacked player controls");
                        filterEnchantment.add(new ControllerIdPredicate(attackedPlayer.getId()));
                        Target target = new TargetPermanent(filterEnchantment);
                        ability.addTarget(target);
                        effect.setTargetPointer(new FirstTargetPointer());
                        break;
                    }
View Full Code Here

        if (event.getType() == EventType.DESTROYED_PERMANENT && event.getPlayerId().equals(controllerId)
                && game.getOpponents(this.getControllerId()).contains(game.getControllerId(event.getSourceId()))) {
            MageObject mageObject = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
            if (!mageObject.getCardType().contains(CardType.CREATURE)) {
                this.getTargets().clear();
                FilterPermanent filter = new FilterPermanent("target permanent that opponent controls");
                filter.add(new ControllerIdPredicate(game.getControllerId(event.getSourceId())));
                Target target = new TargetPermanent(filter);
                this.getTargets().add(target);
                return true;
            }
        }
View Full Code Here

        // All Slivers have "Pay 2 life: Return this permanent to its owner's hand."
        Effect effect = new ReturnToHandSourceEffect(true);
        effect.setText("Return this permanent to its owner's hand");
        Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new PayLifeCost(2));
        this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(ability, Duration.WhileOnBattlefield, new FilterPermanent("Sliver", "All Slivers"), "All Slivers have \"Pay 2 life: Return this permanent to its owner's hand")));
    }
View Full Code Here

        return new ViewFromAboveEffect(this);
    }

    @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 void adjustTargets(Ability ability, Game game) {
        if (ability instanceof SimpleActivatedAbility) {
            ability.getTargets().clear();
            FilterPermanent newFilter = filter.copy();
            newFilter.setMessage(new StringBuilder("artifact or creature with converted mana cost {").append(ability.getManaCostsToPay().getX()).append("}").toString());
            newFilter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, ability.getManaCostsToPay().getX()));
            Target target = new TargetPermanent(newFilter);
            ability.addTarget(target);
        }
    }
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.