Package mage.filter.predicate.permanent

Examples of mage.filter.predicate.permanent.ControllerIdPredicate


    @Override
    public boolean apply(Game game, Ability source) {
        UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(source.getSourceId(), game);
        if (defendingPlayerId != null) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(new ControllerIdPredicate(defendingPlayerId));
            filter.add(Predicates.not(new AbilityPredicate(FlyingAbility.class)));
            List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
            for (Permanent permanent : permanents) {
                permanent.damage(2, source.getSourceId(), game, false, true);
            }
View Full Code Here


        Player player = game.getPlayer(targetPointer.getFirst(game, source));
        if (player != null) {
            int amount = (Integer) getValue("damage");
            if (amount > 0) {
                FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + player.getName() + " controls");
                filter.add(new ControllerIdPredicate(player.getId()));
                TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
                if (target.canChoose(source.getControllerId(), game) && target.choose(Outcome.Damage, source.getControllerId(), source.getSourceId(), game)) {
                    UUID creature = target.getFirstTarget();
                    if (creature != null) {
                        game.getPermanent(creature).damage(amount, source.getSourceId(), game, false, true);
View Full Code Here

                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

                && 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

            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

        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            Map<Permanent, Integer> chosenCards = new HashMap<>(2);
            int maxCount = 0;
            FilterNonlandPermanent filter = new FilterNonlandPermanent("a nonland permanent " + controller.getName() + " doesn't control");
            filter.add(Predicates.not(new ControllerIdPredicate(controller.getId())));
            //Players each choose a legal permanent
            PlayerList playerList = game.getState().getPlayerList();
            while (!playerList.get().equals(controller.getId()) && controller.isInGame()) {
                playerList.getNext();
            }
View Full Code Here

        if (source.getFirstTarget() == null) {
            return false;
        }

        FilterLandPermanent filter = new FilterLandPermanent();
        filter.add(new ControllerIdPredicate(source.getFirstTarget()));

        List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
        for (Permanent land : lands) {
            land.tap(game);
        }
View Full Code Here

    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
        if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls with toughness 2 or less");
            UUID defenderId = game.getCombat().getDefendingPlayerId(sourceId, game);
            filter.add(new ControllerIdPredicate(defenderId));
            filter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, 3));

            this.getTargets().clear();
            TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
            this.addTarget(target);
View Full Code Here

    public boolean apply(Game game, Ability source) {
        Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
            if (opponent != null) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(new TappedPredicate());
            filter.add(new ControllerIdPredicate(opponent.getId()));
            return new DrawCardSourceControllerEffect(game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game)).apply(game, source);
        }
        return false;
    }
View Full Code Here

            for(UUID opponentId : game.getOpponents(ability.getControllerId())) {
                Player opponent = game.getPlayer(opponentId);
                if (opponent != null) {
                    ability.getTargets().clear();
                    FilterCreaturePermanent filter = new FilterCreaturePermanent(new StringBuilder("creature from opponent ").append(opponent.getName()).toString());
                    filter.add(new ControllerIdPredicate(opponentId));
                    TargetCreaturePermanent target = new TargetCreaturePermanent(0,1, filter,false);
                    ability.addTarget(target);
                }
            }
        }
View Full Code Here

TOP

Related Classes of mage.filter.predicate.permanent.ControllerIdPredicate

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.