Package mage.filter.predicate.permanent

Examples of mage.filter.predicate.permanent.PermanentIdPredicate


                        FilterControlledPermanent filter = handledEntry.getKey().getKey().getFilter().copy();
                        String message = filter.getMessage();
                        // omitt already from other untap effects selected permanents
                        for (Permanent permanent: selectedToUntap) {
                              filter.add(Predicates.not(new PermanentIdPredicate(permanent.getId())));
                        }
                        // while targets left and there is still allowed to untap
                        while (isInGame() && leftForUntap.size() > 0 && numberToUntap > 0) {
                            // player has to select the permanent he wants to untap for this restriction
                            Ability ability = handledEntry.getKey().getValue().iterator().next();
                            if (ability != null) {
                                StringBuilder sb = new StringBuilder(message).append(" to untap").append(" (").append(Math.min(leftForUntap.size(), numberToUntap)).append(" in total");
                                MageObject effectSource = game.getObject(ability.getSourceId());
                                if (effectSource != null) {
                                    sb.append(" from ").append(effectSource.getName()).toString();
                                }
                                sb.append(")");
                                filter.setMessage(sb.toString());
                                Target target = new TargetPermanent(filter);
                                if (!this.chooseTarget(Outcome.Untap, target, ability, game)) {
                                    // player canceled, go on with the next effect (if no other effect available, this effect will be active again)
                                    playerCanceledSelection = true;
                                    break;
                                }
                                Permanent selectedPermanent = game.getPermanent(target.getFirstTarget());
                                if (leftForUntap.contains(selectedPermanent)) {
                                    selectedToUntap.add(selectedPermanent);
                                    numberToUntap--;
                                    // don't allow to select same permanent twice
                                    filter.add(Predicates.not(new PermanentIdPredicate(selectedPermanent.getId())));
                                    // reduce available untap numbers from other "UntapNotMoreThan" effects if selected permanent applies to their filter too
                                    for (Entry<Entry<RestrictionUntapNotMoreThanEffect, HashSet<Ability>>, Integer> notMoreThanEffect : notMoreThanEffectsUsage.entrySet()) {
                                        if (notMoreThanEffect.getValue() > 0 && notMoreThanEffect.getKey().getKey().getFilter().match(selectedPermanent, game)) {
                                            notMoreThanEffect.setValue(notMoreThanEffect.getValue() - 1);
                                        }
                                    }
                                    // update the left for untap list
                                    leftForUntap = getPermanentsThatCanBeUntapped(game, canBeUntapped, handledEntry.getKey().getKey(), notMoreThanEffectsUsage);
                                    // remove already selected permanents
                                    for (Permanent permanent :selectedToUntap) {
                                        if (leftForUntap.contains(permanent)) {
                                            leftForUntap.remove(permanent);
                                        }
                                    }

                                } else {
                                    // player selected an permanent that is restricted by another effect, disallow it (so AI can select another one)
                                    filter.add(Predicates.not(new PermanentIdPredicate(selectedPermanent.getId())));
                                    if (this.isHuman()) {
                                        game.informPlayer(this, "This permanent can't be untapped because of other restricting effect.");
                                    }
                                }
                            }
View Full Code Here


            do {
                FilterControlledPermanent filter = new FilterControlledPermanent();
                filter.setMessage("permanent you control (" + amount + " left in total)" );
                List<PermanentIdPredicate> uuidPredicates = new ArrayList<>();
                for (UUID uuid :selectedObjects) {
                    uuidPredicates.add(new PermanentIdPredicate(uuid));
                }
                filter.add(Predicates.not(Predicates.or(uuidPredicates)));                   
               
                target = new TargetControlledPermanent(0, 1, filter, true);
                if (target.canChoose(player.getId(), game)
View Full Code Here

        super.init(source, game);
        Permanent permanent = game.getPermanent(this.targetPointer.getFirst(game, source));
        if (permanent != null) {
           
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(Predicates.not(new PermanentIdPredicate(this.targetPointer.getFirst(game, source))));
            filter.add(new AttackingPredicate());
            boolean isChangeling = false;
            for(Ability ability : permanent.getAbilities()){
                if(ability instanceof ChangelingAbility){
                    isChangeling = true;
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Permanent targetCreature = game.getPermanent(source.getFirstTarget());
        if (targetCreature != null) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(new PermanentIdPredicate(targetCreature.getId()));
            game.addEffect(new PreventAllDamageByAllEffect(filter, Duration.EndOfTurn, false), source);
            if (targetCreature.getColor().contains(ObjectColor.BLACK)
                    || targetCreature.getColor().contains(ObjectColor.RED)) {
                return targetCreature.destroy(source.getSourceId(), game, false);
            }
View Full Code Here

            // put card into play
            controller.putOntoBattlefieldWithInfo(cardInGraveyard, game, Zone.GRAVEYARD, source.getSourceId());
            Permanent enchantedCreature = game.getPermanent(cardInGraveyard.getId());
           
            FilterCreaturePermanent filter = new FilterCreaturePermanent("enchant creature put onto the battlefield with Animate Dead");
            filter.add(new PermanentIdPredicate(cardInGraveyard.getId()));
            Target target = new TargetCreaturePermanent(filter);
            //enchantAbility.setTargetName(target.getTargetName());
            if (enchantedCreature != null) {
                target.addTarget(enchantedCreature.getId(), source, game);
                enchantment.getSpellAbility().getTargets().clear();
View Full Code Here

                            this.getEffects().get(0).setTargetPointer(new FirstTargetPointer());
                            targetName = new StringBuilder(targetName).append("equipped by ").append(equipment.getName()).toString();
                            FilterCreaturePermanent filter = new FilterCreaturePermanent(targetName);
                            List<PermanentIdPredicate> uuidPredicates = new ArrayList<>();
                            for (UUID creatureId : possibleTargets) {
                                uuidPredicates.add(new PermanentIdPredicate(creatureId));
                            }
                            filter.add(Predicates.or(uuidPredicates));
                            this.getTargets().add(new TargetCreaturePermanent(filter));
                        }
                        return true;
View Full Code Here

        if (triggeringCreature == null) {
            triggeringCreature = (Permanent) game.getLastKnownInformation(getTargetPointer().getFirst(game, source), Zone.BATTLEFIELD);
        }
        if (triggeringCreature != null) {
            FilterPermanent filter = new FilterPermanent("another permanent you control that shares a card type with " + triggeringCreature.getName());
            filter.add(Predicates.not(new PermanentIdPredicate(triggeringCreature.getId())));
            filter.add(new ControllerPredicate(TargetController.YOU));
            Set<CardTypePredicate> cardTypes = new HashSet<CardTypePredicate>();
            for (CardType cardType :triggeringCreature.getCardType()) {
                cardTypes.add(new CardTypePredicate(cardType));
            }
View Full Code Here

        this.addAbility(new KickerAbility("{X}"));
       
        // Saproling creatures and other Treefolk creatures get +1/+1.
        FilterCreaturePermanent filter = new FilterCreaturePermanent("Saproling creatures and other Treefolk creatures");
        filter.add(Predicates.or(
                Predicates.and(new SubtypePredicate("Treefolk"), Predicates.not(new PermanentIdPredicate(this.getId()))),
                new SubtypePredicate("Saproling"))
                );
        filter.add(Predicates.not(new PermanentIdPredicate(this.getId())));
               
        this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(1,1, Duration.WhileOnBattlefield, filter, false)));
       
        // When Verdeloth the Ancient enters the battlefield, if it was kicked, put X 1/1 green Saproling creature tokens onto the battlefield.
        EntersBattlefieldTriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new SaprolingToken(), new GetKickerXValue()), false);
View Full Code Here

            Permanent enchantedCreature = game.getPermanent(cardInGraveyard.getId());

            if (enchantedCreature != null) {
                enchantedCreature.addAttachment(enchantment.getId(), game);
                FilterCreaturePermanent filter = new FilterCreaturePermanent("enchant creature put onto the battlefield with Necromancy");
                filter.add(new PermanentIdPredicate(cardInGraveyard.getId()));
                Target target = new TargetCreaturePermanent(filter);
                target.addTarget(enchantedCreature.getId(), source, game);
                game.addEffect(new NecromancyChangeAbilityEffect(target), source);
            }
            return true;
View Full Code Here

        // When Godo, Bandit Warlord enters the battlefield, you may search your library for an Equipment card and put it onto the battlefield. If you do, shuffle your library.
        this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), false, true), true));
        // Whenever Godo attacks for the first time each turn, untap it and all Samurai you control. After this phase, there is an additional combat phase.
        FilterControlledCreaturePermanent untapFilter = new FilterControlledCreaturePermanent();
        untapFilter.add(Predicates.or(new PermanentIdPredicate(this.getId()), new SubtypePredicate("Samurai")));
        Ability ability = new GodoBanditWarlordAttacksTriggeredAbility(new UntapAllControllerEffect(untapFilter,"untap it and all Samurai you control"), false);
        ability.addEffect(new AdditionalCombatPhaseEffect());
        this.addAbility(ability);
    }
View Full Code Here

TOP

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

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.