Package mage.choices

Examples of mage.choices.ChoiceImpl


    @Override
    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            Choice lifeChoice = new ChoiceImpl(true);
            Set<String> choices = new HashSet<String>();
            for (UUID playerId : controller.getInRange()) {
                Player player = game.getPlayer(playerId);
                if (player != null) {
                    choices.add(new StringBuilder(Integer.toString(player.getLife())).append(" life of ").append(player.getName()).toString());
                }
            }
            lifeChoice.setChoices(choices);
            for (UUID playersId : controller.getInRange()) {
                Player player = game.getPlayer(playersId);
                if (player != null) {
                    String selectedChoice;
                    if (choices.size() > 1) {
                        lifeChoice.setMessage("Which players life should get player " + player.getName());
                        controller.choose(Outcome.Detriment, lifeChoice, game);
                        selectedChoice = lifeChoice.getChoice();
                    } else {
                        selectedChoice = choices.iterator().next();
                    }
                    int index = selectedChoice.indexOf(" ");
                    if (index > 0) {
View Full Code Here


    @Override
    public boolean apply(Game game, Ability source) {
        Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
        Player playerControls = game.getPlayer(source.getControllerId());
        if (permanent != null && playerControls != null) {
            Choice abilityChoice = new ChoiceImpl();
            abilityChoice.setMessage("Choose an ability to add");

            Set<String> abilities = new HashSet<>();
            abilities.add(FlyingAbility.getInstance().getRule());
            abilities.add(TrampleAbility.getInstance().getRule());
            abilities.add(HasteAbility.getInstance().getRule());
            abilityChoice.setChoices(abilities);
            playerControls.choose(Outcome.AddAbility, abilityChoice, game);

            String chosen = abilityChoice.getChoice();
            Ability ability = null;
            if (FlyingAbility.getInstance().getRule().equals(chosen)) {
                ability = FlyingAbility.getInstance();
            } else if (TrampleAbility.getInstance().getRule().equals(chosen)) {
                ability = TrampleAbility.getInstance();
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(targetPointer.getFirst(game, source));
        Player playerControls = game.getPlayer(source.getControllerId());
        if (player != null && playerControls != null) {
            Choice cardChoice = new ChoiceImpl();
            cardChoice.setChoices(CardRepository.instance.getNonLandNames());
            cardChoice.clearChoice();
            Choice numberChoice = new ChoiceImpl();
            numberChoice.setMessage("Choose a number greater than 0");
            HashSet<String> numbers = new HashSet<String>();
            for (int i = 1; i <= 4; i++) {
                numbers.add(Integer.toString(i));
            }
            numberChoice.setChoices(numbers);

            while (!playerControls.choose(Outcome.Neutral, cardChoice, game)) {
                if (!playerControls.isInGame()) {
                    return false;
                }
            }

            while (!playerControls.choose(Outcome.Neutral, numberChoice, game)) {
                if (!playerControls.isInGame()) {
                    return false;
                }
            }

            game.informPlayers("Mindblaze, named card: [" + cardChoice.getChoice() + "]");
            game.informPlayers("Mindblaze, chosen number: [" + numberChoice.getChoice() + "]");

            Cards cards = new CardsImpl();
            cards.addAll(player.getLibrary().getCards(game));
            playerControls.revealCards("Library", cards, game);
            FilterCard filter = new FilterCard();
            filter.add(new NamePredicate(cardChoice.getChoice()));
            int count = Integer.parseInt(numberChoice.getChoice());
            if (player.getLibrary().count(filter, game) == count) {
                player.damage(8, source.getSourceId(), game.copy(), false, true);
            }
            player.shuffleLibrary(game);
        }
View Full Code Here

            Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
            for (ManaAbility ability : mana) {
                types.add(ability.getNetMana(game));
            }
        }
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Pick a mana color");
        if (types.getBlack() > 0) {
            choice.getChoices().add("Black");
        }
        if (types.getRed() > 0) {
            choice.getChoices().add("Red");
        }
        if (types.getBlue() > 0) {
            choice.getChoices().add("Blue");
        }
        if (types.getGreen() > 0) {
            choice.getChoices().add("Green");
        }
        if (types.getWhite() > 0) {
            choice.getChoices().add("White");
        }
        if (types.getAny() > 0) {
            choice.getChoices().add("Black");
            choice.getChoices().add("Red");
            choice.getChoices().add("Blue");
            choice.getChoices().add("Green");
            choice.getChoices().add("White");
        }
        if (choice.getChoices().size() > 0) {
            Player player = game.getPlayer(source.getControllerId());
            if (choice.getChoices().size() == 1) {
                choice.setChoice(choice.getChoices().iterator().next());
            } else {
                player.choose(outcome, choice, game);
            }
            if (choice.getChoice().equals("Black")) {
                player.getManaPool().addMana(Mana.BlackMana, game, source);
            } else if (choice.getChoice().equals("Blue")) {
                player.getManaPool().addMana(Mana.BlueMana, game, source);
            } else if (choice.getChoice().equals("Red")) {
                player.getManaPool().addMana(Mana.RedMana, game, source);
            } else if (choice.getChoice().equals("Green")) {
                player.getManaPool().addMana(Mana.GreenMana, game, source);
            } else if (choice.getChoice().equals("White")) {
                player.getManaPool().addMana(Mana.WhiteMana, game, source);
            }
        }
        return true;
    }
View Full Code Here

            Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
            for (ManaAbility ability : mana) {
                types.add(ability.getNetMana(game));
            }
        }
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Pick a mana color");
        if (types.getBlack() > 0) {
            choice.getChoices().add("Black");
        }
        if (types.getRed() > 0) {
            choice.getChoices().add("Red");
        }
        if (types.getBlue() > 0) {
            choice.getChoices().add("Blue");
        }
        if (types.getGreen() > 0) {
            choice.getChoices().add("Green");
        }
        if (types.getWhite() > 0) {
            choice.getChoices().add("White");
        }
        if (types.getAny() > 0) {
            choice.getChoices().add("Black");
            choice.getChoices().add("Red");
            choice.getChoices().add("Blue");
            choice.getChoices().add("Green");
            choice.getChoices().add("White");
        }
        if (choice.getChoices().size() > 0) {
            Player player = game.getPlayer(source.getControllerId());
            if (choice.getChoices().size() == 1) {
                choice.setChoice(choice.getChoices().iterator().next());
            } else {
                player.choose(outcome, choice, game);
            }
            if (choice.getChoice().equals("Black")) {
                player.getManaPool().addMana(Mana.BlackMana, game, source);
            } else if (choice.getChoice().equals("Blue")) {
                player.getManaPool().addMana(Mana.BlueMana, game, source);
            } else if (choice.getChoice().equals("Red")) {
                player.getManaPool().addMana(Mana.RedMana, game, source);
            } else if (choice.getChoice().equals("Green")) {
                player.getManaPool().addMana(Mana.GreenMana, game, source);
            } else if (choice.getChoice().equals("White")) {
                player.getManaPool().addMana(Mana.WhiteMana, game, source);
            }
        }
        return true;
    }
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());
        if (player != null){
            int x = game.getBattlefield().count(new FilterControlledCreaturePermanent(), source.getSourceId(), source.getControllerId(), game);
            Choice manaChoice = new ChoiceImpl();
            Set<String> choices = new LinkedHashSet<>();
            choices.add("Red");
            choices.add("Green");
            manaChoice.setChoices(choices);
            manaChoice.setMessage("Select color of mana to add");

            for (int i = 0; i < x; i++){
                Mana mana = new Mana();
                while (!player.choose(Outcome.Benefit, manaChoice, game)) {
                    if (!player.isInGame()) {
                        return false;
                    }
                }
                if (manaChoice.getChoice() == null) {  // can happen if player leaves game
                    return false;
                }
                switch (manaChoice.getChoice()) {
                    case "Green":
                        mana.addGreen();
                        break;
                    case "Red":
                        mana.addRed();
View Full Code Here

        super(effect);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        Choice cardChoice = new ChoiceImpl();
        cardChoice.setChoices(CardRepository.instance.getNames());
        for (Player player: game.getPlayers().values()) {
            if(player.getLibrary().size() > 0){
                cardChoice.clearChoice();
                while (!player.choose(Outcome.DrawCard, cardChoice, game&& player.isInGame()) {
                    if (!player.isInGame()) {
                        return false;
                    }
                }
                String cardName = cardChoice.getChoice();
                game.informPlayers("Conundrum Sphinx, player: " + player.getName() + ", named card: [" + cardName + "]");
                Card card = player.getLibrary().removeFromTop(game);
                Cards cards  = new CardsImpl();
                cards.add(card);
                player.revealCards("Conundrum Sphinx", cards, game);
View Full Code Here

                    if (gameCard.getOwnerId().equals(targetPlayer.getId())) {
                        choices.add(gameCard.getName());
                    }
                }

                Choice cardChoice = new ChoiceImpl();
                cardChoice.setChoices(choices);
                cardChoice.clearChoice();
                while (!targetPlayer.choose(Outcome.Benefit, cardChoice, game)) {
                    if (!targetPlayer.isInGame()) {
                        return false;
                    }
                }
                String cardName = cardChoice.getChoice();

                game.informPlayers(new StringBuilder(sourcePermanent.getName()).append(", named card: [").append(cardName).append("]").toString());
                if (!card.getName().equals(cardName) && card.getCardType().contains(CardType.CREATURE)) {
                    if (player.chooseUse(outcome, new StringBuilder("Put ").append(card.getName()).append(" onto the battlefield?").toString(), game)) {
                        player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());
        if (player != null) {
            // Name a card.
            Choice choice = new ChoiceImpl();
            choice.setChoices(CardRepository.instance.getNames());
            while (!player.choose(Outcome.Benefit, choice, game)) {
                if (!player.isInGame()) {
                    return false;
                }
            }
            String name = choice.getChoice();
            game.informPlayers("Card named: " + name);
           
            // Exile the top six cards of your library,
            int num = Math.min(6, player.getLibrary().size());
            for (int i = 0; i < num; i++) {
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());
        if (player != null) {
            ChoiceImpl choices = new ChoiceImpl(true);
            Set choicesSet = choices.getChoices();
            choicesSet.add("Forest");
            choicesSet.add("Plains");
            choicesSet.add("Mountain");
            choicesSet.add("Island");
            choicesSet.add("Swamp");
            if (player.choose(Outcome.Neutral, choices, game)) {
                game.getState().setValue(source.getSourceId().toString() + "_ConvincingMirage", choices.getChoice());
                return true;
            }
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of mage.choices.ChoiceImpl

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.