Package mage.filter.predicate.permanent

Examples of mage.filter.predicate.permanent.ControllerIdPredicate


        Permanent target = game.getPermanent(source.getFirstTarget());
        if (target == null) {
            return false;
        }
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(new ControllerIdPredicate(target.getControllerId()));
        filter.add(Predicates.not(new CardIdPredicate(target.getId())));
       
        ContinuousEffect effect = new BlocksIfAbleTargetEffect(Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(target.getId()));
        game.addEffect(effect, source);
View Full Code Here


            for(UUID opponentId : game.getOpponents(ability.getControllerId())) {
                Player opponent = game.getPlayer(opponentId);
                if (opponent != null) {
                    ability.getTargets().clear();
                    FilterPermanent filter = new FilterPermanent(new StringBuilder("noncreature permanent from opponent ").append(opponent.getName()).toString());
                    filter.add(new ControllerIdPredicate(opponentId));
                    filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE)));
                    TargetPermanent target = new TargetPermanent(0,1, filter,false);
                    ability.addTarget(target);
                }
            }
View Full Code Here

    @Override
    public boolean activate(Game game, boolean noMana) {
        UUID defenderId = game.getCombat().getDefenderId(sourceId);
        if (defenderId != null) {
            FilterCreaturePermanent filter = filterTemplate.copy();
            filter.add(new ControllerIdPredicate(defenderId));

            this.getTargets().clear();
            TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
            this.addTarget(target);
            return super.activate(game, noMana);
View Full Code Here

            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

                        int lands = game.getState().getBattlefield().countAll(filter, playerId, game);
                        if (amount >= lands) {
                            permanentsToSacrifice.addAll(game.getState().getBattlefield().getAllActivePermanents(filter, playerId, game));
                        } else {
                            FilterLandPermanent playerFilter = filter.copy();
                            playerFilter.add(new ControllerIdPredicate(playerId));
                            Target target = new TargetLandPermanent(amount, amount, playerFilter, true);
                            player.choose(outcome, target, source.getSourceId(), game);
                            for (UUID landId : target.getTargets()) {
                                Permanent permanent = game.getPermanent(landId);
                                if (permanent != null) {
View Full Code Here

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

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

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

        Player player = game.getPlayer(targetPointer.getFirst(game, source));
        if (player == null) {
            return false;
        }
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(new ControllerIdPredicate(player.getId()));
        int realCount = game.getBattlefield().countAll(filter, player.getId(), game);
        if (realCount > 0) {
            Target target = new TargetControlledPermanent(1, 1, filter, true);
            while (player.isInGame() && !target.isChosen() && target.canChoose(player.getId(), game)) {
                player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
View Full Code Here

    public boolean apply(Game game, Ability source) {
        Permanent permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
        Player targetPlayer = game.getPlayer(permanent.getControllerId());
        if (targetPlayer != null && permanent != null && (permanent.getSupertype().get(0).toString().equals("Legendary"))) {
                FilterPermanent filter = new FilterLandPermanent("land to sacrifice");
                filter.add(new ControllerIdPredicate(targetPlayer.getId()));
                TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false);

                if (target.canChoose(targetPlayer.getId(), game)) {
                    targetPlayer.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
View Full Code Here

                    firstNextPlayer = nextPlayer.getId();
                }
                // if player is in range he chooses an creature to control
                if (currentPlayer != null && controller.getInRange().contains(currentPlayer.getId())) {
                    FilterCreaturePermanent filter = new FilterCreaturePermanent(new StringBuilder("creature controlled by ").append(nextPlayer.getName()).toString());
                    filter.add(new ControllerIdPredicate(nextPlayer.getId()));
                    Target target = new TargetCreaturePermanent(filter);
                    target.setNotTarget(false);
                    if (target.canChoose(source.getSourceId(), currentPlayer.getId(), game)) {
                        if (currentPlayer.chooseTarget(outcome, target, source, game)) {
                            playerCreature.put(currentPlayer.getId(), target.getFirstTarget());
View Full Code Here

            UUID defenderId = game.getState().getCombat().findGroup(this.getSourceId()).getDefenderId();
            if (defenderId != null) {
                this.getTargets().clear();
                FilterPermanent filter = new FilterPermanent("artifact or enchantment defending player controls");
                filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.ENCHANTMENT)));
                filter.add(new ControllerIdPredicate(defenderId));
                Target target = new TargetPermanent(filter);
                this.addTarget(target);
                return true;
            }
        }
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.