Package mage.filter.common

Examples of mage.filter.common.FilterControlledPermanent


    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getTargets().getFirstTarget());
        Player controller = game.getPlayer(source.getControllerId());

        FilterControlledPermanent filter = new FilterControlledPermanent("creature");
        filter.add(new CardTypePredicate(CardType.CREATURE));
        filter.add(new ControllerPredicate(TargetController.YOU));
        TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);

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


        //Choose one - Target creature gets +3/+3 until end of turn
        this.getSpellAbility().addEffect(new BoostTargetEffect(3, 3, Duration.EndOfTurn));
        this.getSpellAbility().addTarget(new TargetCreaturePermanent());
        //permanents you control gain hexproof until end of turn
        Mode mode = new Mode();
        mode.getEffects().add(new GainAbilityAllEffect(HexproofAbility.getInstance(), Duration.EndOfTurn, new FilterControlledPermanent()));
        this.getSpellAbility().addMode(mode);
        //return target creature to its owner's hand.
        Mode mode2 = new Mode();
        mode2.getEffects().add(new ReturnToHandTargetEffect());
        mode2.getTargets().add(new TargetCreaturePermanent());
View Full Code Here

                        targetPlayer.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
                    }
                }

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

            int minPermanent = Integer.MAX_VALUE, minCard = Integer.MAX_VALUE;
            // count minimal permanets
            for(UUID playerId : controller.getInRange()){
                Player player = game.getPlayer(playerId);
                if(player != null){
                    int count = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source.getSourceId(), game).size();
                    if(count < minPermanent){
                        minPermanent = count;
                    }
                }
            }
            // sacrifice permanents over the minimum
            for(UUID playerId : controller.getInRange()){
                Player player = game.getPlayer(playerId);
                if(player != null){
                    TargetControlledPermanent target = new TargetControlledPermanent(minPermanent, minPermanent, new FilterControlledPermanent(), true);
                    if(target.choose(Outcome.Benefit, player.getId(), source.getSourceId(), game)){
                        for(Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source.getSourceId(), game)){
                            if(permanent != null && !target.getTargets().contains(permanent.getId())){
                                permanent.sacrifice(source.getSourceId(), game);
                            }
                        }
                    }
View Full Code Here

    private int chroma;

    @Override
    public int calculate(Game game, Ability sourceAbility, Effect effect) {
        chroma = 0;
        for (Card card : game.getBattlefield().getAllActivePermanents(new FilterControlledPermanent(), sourceAbility.getControllerId(), game)) {
            chroma += card.getManaCost().getMana().getGreen();
        }
        return chroma;
    }
View Full Code Here

        Permanent descrationDemon = game.getPermanent(source.getSourceId());
        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))
                        {
                            opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
View Full Code Here

        FilterControlledCreaturePermanent filterCreature = new FilterControlledCreaturePermanent("a creature");
        Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ShattergangBrothersEffect(filterCreature), new ManaCostsImpl("{2}{B}"));
        ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(1,1, filterCreature, true)));
        this.addAbility(ability);
        // {2}{R}, Sacrifice an artifact: Each other player sacrifices an artifact.
        FilterControlledPermanent filter = new FilterControlledArtifactPermanent("an artifact");
        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

        this.color.setBlue(true);
        this.power = new MageInt(4);
        this.toughness = new MageInt(4);
       
        //At the beginning of your upkeep, return a permanent you control to its owner's hand.
        this.addAbility(new BeginningOfUpkeepTriggeredAbility(new ReturnToHandChosenControlledPermanentEffect(new FilterControlledPermanent()), TargetController.YOU, false));
    }
View Full Code Here

        this.color.setBlue(true);

        // If Leyline of Singularity is in your opening hand, you may begin the game with it on the battlefield.
        this.addAbility(LeylineAbility.getInstance());
        // All nonland permanents are legendary.
        this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SetSupertypeAllEffect(Duration.WhileOnBattlefield, new FilterControlledPermanent())));
       
    }
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.
        if (target.canChoose(player.getId(), game)) {
View Full Code Here

TOP

Related Classes of mage.filter.common.FilterControlledPermanent

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.