Package mage.filter

Examples of mage.filter.FilterPermanent


    public boolean checkTrigger(GameEvent event, Game game) {
        if (event.getType() == EventType.DAMAGED_PLAYER && event.getSourceId().equals(this.sourceId)
                && ((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


    @Override
    public boolean apply(Game game, Ability source) {
       
        FilterPermanent filter = new FilterPermanent("artifacts, creatures, and enchantments");
   
   
        filter.add(Predicates.or(
                new CardTypePredicate(CardType.ARTIFACT),
                new CardTypePredicate(CardType.CREATURE),
                new CardTypePredicate(CardType.ENCHANTMENT)));
        filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, source.getManaCostsToPay().getX() + 1));

   
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
            permanent.destroy(source.getSourceId(), game, false);
        }
View Full Code Here

        this.getSpellAbility().addTarget(new TargetPermanent());
        // Cycling {5}{W}{U}{B}
        this.addAbility(new CyclingAbility(new ManaCostsImpl("{5}{W}{U}{B}")));
        // When you cycle Resounding Wave, return two target permanents to their owners' hands.
        Ability ability = new CycleTriggeredAbility(new ReturnToHandTargetEffect());
        TargetPermanent target = new TargetPermanent(2, new FilterPermanent("two target permanents"));
        ability.addTarget(target);
        this.addAbility(ability);
    }
View Full Code Here

            if (controller != null) {
                StringBuilder sb = new StringBuilder("Shall ").append(targetPlayer.getName()).append(" lose ").append(amount).append(" life?");
                if (controller.chooseUse(outcome, sb.toString(), game)) {
                    targetPlayer.loseLife(amount, game);
                } else {
                    int numberPermanents = game.getState().getBattlefield().countAll(new FilterPermanent(), targetPlayer.getId(), game);
                    if (numberPermanents > amount) {
                        int numberToSacrifice = numberPermanents - amount;
                        Target target = new TargetControlledPermanent(numberToSacrifice, numberToSacrifice, new FilterPermanent(), false);
                        targetPlayer.chooseTarget(Outcome.Sacrifice, target, source, game);
                        for (UUID uuid : target.getTargets()) {
                            Permanent permanent = game.getPermanent(uuid);
                            if (permanent != null) {
                                permanent.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true);
View Full Code Here

        this.addAbility(ability);
        // -9: Nicol Bolas, Planeswalker deals 7 damage to target player. That player discards seven cards, then sacrifices seven permanents.
        ability = new LoyaltyAbility(new DamageTargetEffect(7), -9);
        ability.addTarget(new TargetPlayer());
        ability.addEffect(new DiscardTargetEffect(7));
        ability.addEffect(new SacrificeEffect(new FilterPermanent(), 7, "then"));
        this.addAbility(ability);
    }
View Full Code Here

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

        // Sacrifice Dauntless Escort: Creatures you control are indestructible this turn.
        FilterPermanent filter = new FilterControlledCreaturePermanent("Creatures you control");
        Effect effect = new GainAbilityAllEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn, filter, false);
        effect.setText("Creatures you control are indestructible this turn");
        this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new SacrificeSourceCost()));
    }
View Full Code Here

        if (controller != null) {
            ChoiceColor choice = new ChoiceColor();
            controller.choose(outcome, choice, game);
            if (choice.getColor() != null) {
                final int damage = source.getManaCostsToPay().getX();
                FilterPermanent filter = new FilterCreaturePermanent();
                filter.add(new ColorPredicate(choice.getColor()));
                for (Permanent permanent:game.getBattlefield().getActivePermanents(filter, source.getControllerId(), id, game)) {
                    permanent.damage(damage, source.getSourceId(), game, false, true);
                }
                return true;
            }
View Full Code Here

        return new KarrthusEffect(this);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        FilterPermanent filter = new FilterPermanent();
        filter.add(new SubtypePredicate("Dragon"));
        List<Permanent> dragons = game.getBattlefield().getAllActivePermanents(filter, game);
        for (Permanent dragon : dragons) {
            ContinuousEffect effect = new KarrthusControlEffect(source.getControllerId());
            effect.setTargetPointer(new FixedTarget(dragon.getId()));
            game.addEffect(effect, source);
View Full Code Here

}

class AkkiUnderminerAbility extends TriggeredAbilityImpl {

    public AkkiUnderminerAbility() {
        super(Zone.BATTLEFIELD, new SacrificeEffect(new FilterPermanent(), 1, ""));
    }
View Full Code Here

    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        Permanent creature = game.getPermanent(event.getTargetId());
        Player controller = game.getPlayer(source.getControllerId());
        if (creature != null && controller != null) {
            Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterPermanent(), true);
            if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
                return false;
            }
            controller.chooseTarget(Outcome.Detriment, target, source, game);
            if (target.getTargets().size() > 0) {
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.