Package mage.filter

Examples of mage.filter.FilterPermanent


class NightRevelersCondition implements Condition {

    @Override
    public boolean apply(Game game, Ability source) {
        boolean conditionApplies = false;
        FilterPermanent filter = new FilterPermanent();
        filter.add(new SubtypePredicate("Human"));

        Set<UUID> opponents = game.getOpponents(source.getControllerId());
        for (UUID opponentId : opponents) {
            conditionApplies |= game.getBattlefield().countAll(filter, opponentId, game) > 0;
        }
View Full Code Here


    public boolean checkTrigger(GameEvent event, Game game) {
         if (event instanceof DamagedPlayerEvent) {
            DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
            Permanent p = game.getPermanent(event.getSourceId());
            if (damageEvent.isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId())) {
                FilterPermanent filter = new FilterPermanent("Equipment that player controls");
                filter.add(new SubtypePredicate("Equipment"));
                filter.add(new ControllerIdPredicate(event.getPlayerId()));
                filter.setMessage("creature controlled by " + game.getPlayer(event.getTargetId()).getName());

                this.getTargets().clear();
                this.addTarget(new TargetPermanent(filter));
                return true;
            }
View Full Code Here

        this.expansionSetCode = "BOK";
        this.subtype.add("Arcane");
        this.color.setBlue(true);
        // You may tap or untap target permanent, then you may tap or untap another target permanent.
        this.getSpellAbility().addEffect(new ToilsOfNightAndDayEffect());
        this.getSpellAbility().addTarget(new TargetPermanent(0, 2, new FilterPermanent(), false));
    }
View Full Code Here

        return new WorldpurgeEffect(this);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPermanent(), source.getControllerId(), source.getSourceId(), game)) {
            permanent.moveToZone(Zone.HAND, source.getSourceId(), game, false);
        }
        game.informPlayers("Worldpurge: All permanents returned to owners' hands");
        for (Player player : game.getPlayers().values()) {
            if (player != null) {
View Full Code Here

        UUID target = source.getFirstTarget();
        Player opponent = game.getPlayer(target);
        if (opponent != null) {
            boolean stop = false;
            while (!stop) {
                int count = game.getBattlefield().countAll(new FilterPermanent(), opponent.getId(), game);
                if (count > 0) {
                    int random = (int)(Math.random()*count);
                    int index = 0;
                    for (Permanent permanent : game.getBattlefield().getAllActivePermanents(opponent.getId())) {
                        if (index == random) {
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

        this.color.setWhite(true);

        // Catch
        // Gain control of target permanent until end of turn. Untap it. It gains haste until end of turn.
        getLeftHalfCard().getColor().setRed(true);
        getLeftHalfCard().getSpellAbility().addTarget(new TargetPermanent(new FilterPermanent()));
        getLeftHalfCard().getSpellAbility().addEffect(new GainControlTargetEffect(Duration.EndOfTurn));
        getLeftHalfCard().getSpellAbility().addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn));
        getLeftHalfCard().getSpellAbility().addEffect(new UntapTargetEffect());

        // Release
View Full Code Here

        if (protectionFilter == null) {
            Permanent permanent = game.getPermanent(source.getSourceId());
            if (permanent != null) {
                String color = (String) game.getState().getValue(permanent.getId() + "_color");
                if (color != null) {
                    protectionFilter = new FilterPermanent(color);
                    protectionFilter.add(new ColorPredicate(new ObjectColor(color)));
                }
            }
        }
        if (protectionFilter != null) {
View Full Code Here

        this.power = new MageInt(3);
        this.toughness = new MageInt(3);
       
        String rule = "Gain control of target Vampire for as long as you control Olivia Voldaren";

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

        this.addAbility(FlyingAbility.getInstance());

        // {1}{R}: Olivia Voldaren deals 1 damage to another target creature. That creature becomes a Vampire in addition to its other types. Put a +1/+1 counter on Olivia Voldaren.
        Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new ManaCostsImpl("{1}{R}"));
View Full Code Here

class SoullessOneDynamicCount implements DynamicValue {

    @Override
    public int calculate(Game game, Ability sourceAbility, Effect effect) {
        FilterPermanent zombiesBattlefield = new FilterPermanent("Zombies on the battlefield");
        FilterCard zombiesInGraveyard = new FilterCard("Zombie cards in all graveyards");
        zombiesBattlefield.add(new SubtypePredicate("Zombie"));
        zombiesInGraveyard.add(new SubtypePredicate("Zombie"));
       
        int count = game.getBattlefield().count(zombiesBattlefield, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
        for (UUID playerId : game.getPlayer(sourceAbility.getControllerId()).getInRange()) {
            Player player = game.getPlayer(playerId);
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.