Package mage.filter.predicate.mageobject

Examples of mage.filter.predicate.mageobject.CardTypePredicate


        if (event.getType() == GameEvent.EventType.CREATURE_BLOCKED && event.getTargetId().equals(this.getSourceId())) {
            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


        }
        //Set the mana cost one higher to 'emulate' a less than or equal to comparison.
        int xValue = source.getManaCostsToPay().getX() + 1;
        FilterCard filter = new FilterCard("green creature card with converted mana cost " + xValue + " or less");
        filter.add(new ColorPredicate(ObjectColor.GREEN));
        filter.add(new CardTypePredicate(CardType.CREATURE));
       
        filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, xValue));
        TargetCardInLibrary target = new TargetCardInLibrary(filter);
        if (player.searchLibrary(target, game)) {
            if (target.getTargets().size() > 0) {
View Full Code Here

    public boolean checkTrigger(GameEvent event, Game game) {
        if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE) {
            Player player = game.getPlayer(event.getPlayerId());
            if (player != null) {
                FilterCreaturePermanent filter = new FilterCreaturePermanent("nonartifact creature you control");
                filter.add(Predicates.not(new CardTypePredicate(CardType.ARTIFACT)));
                filter.add(new ControllerIdPredicate(player.getId()));
                Target target = new TargetCreaturePermanent(filter);
                if (target.canChoose(this.getSourceId(), this.getControllerId(), game) && player.chooseTarget(Outcome.DestroyPermanent, target, this, game)) {
                    for (Effect effect: this.getEffects()) {
                        if (effect instanceof DestroyTargetEffect) {
View Full Code Here

                    }
                }

                // then repeats this process for an artifact,
                FilterControlledPermanent filter = new FilterControlledPermanent("artifact you control");
                filter.add(new CardTypePredicate(CardType.ARTIFACT));
                target = new TargetControlledPermanent(filter);
                target.setNotTarget(true);
                if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
                    Permanent permanent = game.getPermanent(target.getFirstTarget());
                    if (permanent != null) {
                        targetPlayer.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
                    }
                }
               
                // an enchantment,
                filter = new FilterControlledPermanent("enchantment you control");
                filter.add(new CardTypePredicate(CardType.ENCHANTMENT));
                target = new TargetControlledPermanent(filter);
                target.setNotTarget(true);
                if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
                    Permanent permanent = game.getPermanent(target.getFirstTarget());
                    if (permanent != null) {
                        targetPlayer.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
                    }
                }
               
                // and a land.
                filter = new FilterControlledPermanent("land you control");
                filter.add(new CardTypePredicate(CardType.LAND));
                target = new TargetControlledPermanent(filter);
                target.setNotTarget(true);
                if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
                    Permanent permanent = game.getPermanent(target.getFirstTarget());
                    if (permanent != null) {
View Full Code Here

        Cards cardsInLibrary = new CardsImpl(Zone.LIBRARY);
        cardsInLibrary.addAll(player.getLibrary().getCards(game));

        for (int cmc=3; cmc > 0; cmc--) {
            FilterCard filter = new FilterCard("instant card with converted mana cost " + cmc);
            filter.add(new CardTypePredicate(CardType.INSTANT));
            filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, cmc));


            cardsCount = cardsInLibrary.count(filter, game);
            if (cardsCount > 0) {
View Full Code Here

            choiceImpl = new ChoiceImpl();
            choiceImpl.setChoices(choice2);
            while(!player.choose(outcome.Neutral, choiceImpl, game));
           
            FilterPermanent filter = new FilterPermanent();
            filter.add(new CardTypePredicate(type));
           
           
            if(choiceImpl.getChoice().equals("Untap")){
                filter.add(new TappedPredicate());
                for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
View Full Code Here

        if (controller != null && descrationDemon != null) {
            for (UUID opponentId: game.getOpponents(controller.getId())) {
                Player opponent = game.getPlayer(opponentId);
                if (opponent != null) {
                    FilterControlledPermanent filter = new FilterControlledPermanent("creature to sacrifice");
                    filter.add(new CardTypePredicate(CardType.CREATURE));
                    filter.add(new ControllerPredicate(TargetController.YOU));
                    TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false);
                    if (target.canChoose(opponent.getId(), game)) {
                        if (opponent.chooseUse(Outcome.AIDontUseIt, new StringBuilder("Sacrifice a creature to tap ").append(descrationDemon.getName()).append("and put a +1/+1 counter on it?").toString(), game))
                        {
View Full Code Here

        ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ShattergangBrothersEffect(filter), new ManaCostsImpl("{2}{R}"));
        ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(1,1, filter, true)));
        this.addAbility(ability);
        // {2}{G}, Sacrifice an enchantment: Each other player sacrifices an enchantment.
        filter = new FilterControlledPermanent("an enchantment");
        filter.add(new CardTypePredicate(CardType.ENCHANTMENT));
        ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ShattergangBrothersEffect(filter), new ManaCostsImpl("{2}{G}"));
        ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(1,1, filter, true)));
        this.addAbility(ability);
    }
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(getTargetPointer().getFirst(game, source));

        FilterControlledPermanent filter = new FilterControlledPermanent("creature");
        filter.add(new CardTypePredicate(CardType.CREATURE));
        filter.add(new ControllerIdPredicate(player.getId()));
        TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false);

        //A spell or ability could have removed the only legal target this player
        //had, if thats the case this ability should fizzle.
View Full Code Here

TOP

Related Classes of mage.filter.predicate.mageobject.CardTypePredicate

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.