Package mage.target

Examples of mage.target.Target.canChoose()


        Target target = new TargetControlledPermanent(amount, amount, filter, false);
        target.setNotTarget(true);

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

    @Override
    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            Target target = new TargetCardInHand(filter);
            if (target.canChoose(source.getSourceId(), controller.getId(), game) &&
              controller.chooseUse(outcome, "Cast a nonland card from your hand without paying its mana cost?", game)) {
                Card cardToCast = null;
                boolean cancel = false;
                while (controller.isInGame() && !cancel) {
                    if (controller.chooseTarget(outcome, target, source, game)) {
View Full Code Here

            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

    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

            Player player = game.getPlayer(permanent.getOwnerId());
            if (player != null) {
                FilterCreatureCard filter = new FilterCreatureCard(new StringBuilder("a creature card from ").append(player.getName()).append("'s graveyard").toString());
                filter.add(new OwnerIdPredicate(player.getId()));
                Target targetCreature = new TargetCardInGraveyard(filter);
                if (targetCreature.canChoose(source.getSourceId(), controller.getId(), game)
                    && controller.chooseTarget(outcome, targetCreature, source, game)) {
                    Card card = game.getCard(targetCreature.getFirstTarget());
                    if (card != null && game.getState().getZone(card.getId()).equals(Zone.GRAVEYARD)) {
                        return card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), player.getId());
                    }
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 (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

        Player player = game.getPlayer(source.getControllerId());
        Permanent sourcePermanent = game.getPermanent(source.getSourceId());
        if (player != null && sourcePermanent != null) {
            Target target = new TargetPermanent(new FilterCreaturePermanent());
            target.setNotTarget(true);
            if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
                player.choose(Outcome.Copy, target, source.getSourceId(), game);
                Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget());
                if (copyFromPermanent != null) {
                    game.copyPermanent(copyFromPermanent, sourcePermanent, source, new ApplyToPermanent() {
                        @Override
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.