Package mage.target.common

Examples of mage.target.common.TargetControlledPermanent.canChoose()


            player.loseLife(2, game);
            game.informPlayers(player.getName() + " pays 2 life. He will not return a permanent he or she controls.");
            return true;
        } else {
            Target target = new TargetControlledPermanent();
            if (target.canChoose(source.getSourceId(), player.getId(), game) && player.chooseTarget(outcome, target, source, game)) {
                Permanent permanent = game.getPermanent(target.getFirstTarget());
                if (permanent != null) {
                    game.informPlayers(player.getName() + " returns " + permanent.getName() + " to hand.");
                    return permanent.moveToZone(Zone.HAND, source.getSourceId(), game, false);
                }
View Full Code Here


    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());
        if (player != null) {
            TargetControlledPermanent target = new TargetControlledPermanent(filter);
            if (target.canChoose(source.getControllerId(), game)) {
                if (player.choose(Outcome.Neutral, target, source.getSourceId(), game)) {
                    Permanent permanent = game.getPermanent(target.getFirstTarget());
                    if (permanent != null) {
                        permanent.addCounters(new Counter("phylactery"), game);
                    }
View Full Code Here

    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());
        if (player != null) {
            Target target = new TargetControlledPermanent();

            if (target.canChoose(player.getId(), game) && player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) {
                Permanent permanent = game.getPermanent(target.getFirstTarget());
                if (permanent != null) {
                    return permanent.sacrifice(source.getSourceId(), game);
                }
            }
View Full Code Here

                for (UUID opponentId : game.getOpponents(controller.getId())) {
                    Player opponent = game.getPlayer(opponentId);
                    if (opponent != null) {
                        for (int i = 0; i < sacrificeNumber; i++) {
                            Target target = new TargetControlledPermanent(new FilterControlledCreaturePermanent());
                            if (target.canChoose(opponentId, game)) {
                                if (opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) {
                                    Permanent permanent = game.getPermanent(target.getFirstTarget());
                                    if (permanent != null) {
                                        permanent.sacrifice(source.getSourceId(), game);
                                    }
View Full Code Here

    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        Permanent creature = game.getPermanent(event.getTargetId());
        Player controller = game.getPlayer(source.getControllerId());
        if (creature != null && controller != null) {
            Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterPermanent(), true);
            if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
                return false;
            }
            controller.chooseTarget(Outcome.Detriment, target, source, game);
            if (target.getTargets().size() > 0) {
                int sacrificedCreatures = target.getTargets().size();
View Full Code Here

        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);

                    Permanent land = game.getPermanent(target.getFirstTarget());
                    if (land != null) {
                        return land.sacrifice(source.getSourceId(), game);
View Full Code Here

        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)) {
            player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);

            Permanent permanent = game.getPermanent(target.getFirstTarget());
            if ( permanent != null ) {
                controller.gainLife(permanent.getToughness().getValue(), game);
View Full Code Here

        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);
            }
            Permanent permanent = game.getPermanent(target.getFirstTarget());
            if (permanent != null) {
                int gainLife = permanent.getToughness().getValue();
View Full Code Here

        Target target = new TargetControlledPermanent(amount, amount, 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 (amount > 0 && target.canChoose(source.getSourceId(), player.getId(), game)) {
            boolean abilityApplied = false;
            while (player.isInGame() && !target.isChosen() && target.canChoose(player.getId(), game)) {
                player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
            }
View Full Code Here

        //A spell or ability could have removed the only legal target this player
        //had, if thats the case this ability should fizzle.
        if (amount > 0 && target.canChoose(source.getSourceId(), player.getId(), game)) {
            boolean abilityApplied = false;
            while (player.isInGame() && !target.isChosen() && target.canChoose(player.getId(), game)) {
                player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
            }

            for ( int idx = 0; idx < target.getTargets().size(); idx++) {
                Permanent permanent = game.getPermanent((UUID)target.getTargets().get(idx));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.