Package mage.choices

Examples of mage.choices.Choice


  }

  @Override
  public boolean apply(Game game, Ability source) {
    Set<String> cardNames = Sets.getCardNames();
    Choice cardChoice = new ChoiceImpl();
    cardChoice.setChoices(Sets.getCardNames());
    for (Player player: game.getPlayers().values()) {
      cardChoice.clearChoice();
      player.choose(Outcome.DrawCard, cardChoice, game);
      Card card = player.getLibrary().removeFromTop(game);
      Cards cards  = new CardsImpl();
      cards.add(card);
      player.revealCards(cards, game);
      if (card.getName().equals(cardChoice.getChoice())) {
        card.moveToZone(Zone.HAND, source.getId(), game, true);
      }
      else {
        card.moveToZone(Zone.LIBRARY, source.getId(), game, false);
      }
View Full Code Here


                        if (permanent.getCounters().size() == 1) {
                            for (Counter counter : permanent.getCounters().values()) {
                                permanent.addCounters(counter.getName(), 1, game);
                            }
                        } else {
                            Choice choice = new ChoiceImpl(true);
                            Set<String> choices = new HashSet<>();
                            for (Counter counter : permanent.getCounters().values()) {
                                choices.add(counter.getName());
                            }
                            choice.setChoices(choices);
                            choice.setMessage("Choose a counter to proliferate (" + permanent.getName() + ")");
                            controller.choose(Outcome.Benefit, choice, game);
                            for (Counter counter : permanent.getCounters().values()) {
                                if (counter.getName().equals(choice.getChoice())) {
                                    permanent.addCounters(counter.getName(), 1, game);
                                    break;
                                }
                            }
                        }
                    }
                } else {
                    Player player = game.getPlayer(chosen);
                    if (player != null) {
                        if (player.getCounters().size() > 0) {
                            if (player.getCounters().size() == 1) {
                                for (Counter counter : player.getCounters().values()) {
                                    Counter newCounter = new Counter(counter.getName());
                                    player.addCounters(newCounter, game);
                                }
                            } else {
                                Choice choice = new ChoiceImpl(true);
                                Set<String> choices = new HashSet<>();
                                for (Counter counter : player.getCounters().values()) {
                                    choices.add(counter.getName());
                                }
                                choice.setChoices(choices);
                                choice.setMessage("Choose a counter to proliferate (" + player.getName() + ")");
                                controller.choose(Outcome.Benefit, choice, game);
                                for (Counter counter : player.getCounters().values()) {
                                    if (counter.getName().equals(choice.getChoice())) {
                                        Counter newCounter = new Counter(counter.getName());
                                        player.addCounters(newCounter, game);
                                        break;
                                    }
                                }
View Full Code Here

        super.init(source, game);
        // choose land type
        if (chooseLandType) {
            Player controller = game.getPlayer(source.getControllerId());
            if (controller != null) {
                Choice choice = new ChoiceBasicLandType();
                controller.choose(outcome, choice, game);
                landTypes.add(choice.getChoice());
            } else {
                this.discard();
            }
        }
    }
View Full Code Here

    public boolean apply(Game game, Ability source) {
        List<Card> chosen = new ArrayList<>();
        Player you = game.getPlayer(source.getControllerId());
        Permanent sourceCreature = game.getPermanent(source.getSourceId());
        if (you != null && sourceCreature != null) {
            Choice choiceImpl = new ChoiceImpl();
            choiceImpl.setChoices(choice);
            while (you.isInGame() && !you.choose(Outcome.Neutral, choiceImpl, game)) {}
            CardType type = null;
            String choosenType = choiceImpl.getChoice();

            if (choosenType.equals(CardType.ARTIFACT.toString())) {
                type = CardType.ARTIFACT;
            } else if (choosenType.equals(CardType.LAND.toString())) {
                type = CardType.LAND;
View Full Code Here

                        continue;
                    }
                    if (!perm.isTapped() && perm.tap(game)) {
                        ManaCosts<ManaCost> manaCostsToReduce = new ManaCostsImpl<>();
                        int costBefore = ability.getManaCostsToPay().convertedManaCost();
                        Choice chooseManaType = buildChoice(perm.getColor(), ability.getManaCostsToPay());
                        if (chooseManaType.getChoices().size() > 0) {
                            if (chooseManaType.getChoices().size() > 1) {
                                chooseManaType.getChoices().add("Colorless");
                                chooseManaType.setMessage("Choose mana color to reduce from " + perm.getName());
                                while (!chooseManaType.isChosen()) {
                                    player.choose(Outcome.Benefit, chooseManaType, game);
                                }
                            } else {
                                chooseManaType.setChoice(chooseManaType.getChoices().iterator().next());
                            }
                            if (chooseManaType.getChoice().equals("Black")) {
                                manaCostsToReduce.load("{B}");
                            }
                            if (chooseManaType.getChoice().equals("Blue")) {
                                manaCostsToReduce.load("{U}");
                            }
                            if (chooseManaType.getChoice().equals("Green")) {
                                manaCostsToReduce.load("{G}");
                            }
                            if (chooseManaType.getChoice().equals("White")) {
                                manaCostsToReduce.load("{W}");
                            }
                            if (chooseManaType.getChoice().equals("Red")) {
                                manaCostsToReduce.load("{R}");
                            }
                            if (chooseManaType.getChoice().equals("Colorless")) {
                                manaCostsToReduce.load("{1}");
                            }
                            CardUtil.reduceCost((SpellAbility)ability, manaCostsToReduce);
                        } else {
                            manaCostsToReduce.load("{1}");
View Full Code Here

            }
        }
    }

    private Choice buildChoice(ObjectColor creatureColor, ManaCosts manaCostsSpell) {
       Choice choice = new ChoiceImpl();
       String spellCosts = manaCostsSpell.getText();
       if (creatureColor.isBlack() && spellCosts.contains("B")) {
           choice.getChoices().add("Black");
       }
       if (creatureColor.isBlue() && spellCosts.contains("U")) {
           choice.getChoices().add("Blue");
       }
       if (creatureColor.isGreen() && spellCosts.contains("G")) {
           choice.getChoices().add("Green");
       }
       if (creatureColor.isRed() && spellCosts.contains("R")) {
           choice.getChoices().add("Red");
       }
       if (creatureColor.isWhite() && spellCosts.contains("W")) {
           choice.getChoices().add("White");
       }
       return choice;
    }
View Full Code Here

            Abilities<ManaAbility> mana = permanent.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
            Mana types = new Mana();
            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.getColorless() > 0) {
                choice.getChoices().add("Colorless");
            }
            if (choice.getChoices().size() > 0) {
                Player player = game.getPlayer(permanent.getControllerId());
                if (choice.getChoices().size() == 1) {
                    choice.setChoice(choice.getChoices().iterator().next());
                } else {
                    player.choose(outcome, choice, game);
                }
                if (choice.getChoice() == null) {
                    return false;
                }
                switch (choice.getChoice()) {
                    case "Black":
                        player.getManaPool().addMana(Mana.BlackMana, game, source);
                        return true;
                    case "Blue":
                        player.getManaPool().addMana(Mana.BlueMana, game, source);
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        MageObject sourceObject = game.getObject(source.getSourceId());
        if (controller != null && sourceObject != null) {
            Choice cardChoice = new ChoiceImpl();
            switch(typeOfName) {
                case ALL:
                    cardChoice.setChoices(CardRepository.instance.getNames());
                    cardChoice.setMessage("Name a card");
                    break;
                case NON_LAND_AND_NON_CREATURE_NAME:
                    cardChoice.setChoices(CardRepository.instance.getNonLandAndNonCreatureNames());
                    cardChoice.setMessage("Name a non land and non creature card");
                    break;                   
                case NON_LAND_NAME:
                    cardChoice.setChoices(CardRepository.instance.getNonLandNames());
                    cardChoice.setMessage("Name a non land card");
                    break;                   
            }           
            cardChoice.clearChoice();
            while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
                if (!controller.isInGame()) {
                    return false;
                }
            }
            String cardName = cardChoice.getChoice();
            game.informPlayers(sourceObject.getLogName() + ", named card: [" + cardName + "]");
            game.getState().setValue(source.getSourceId().toString() + INFO_KEY, cardName);
            if (sourceObject instanceof Permanent) {
                ((Permanent)sourceObject).addInfo(INFO_KEY, CardUtil.addToolTipMarkTags("Named card: " + cardName));
            }
View Full Code Here

                            if (counterTypeToRemove != null) {
                                counterName = counterTypeToRemove.getName();
                            } else {
                                if (permanent.getCounters().size() > 1 && counterTypeToRemove == null) {
                                    Choice choice = new ChoiceImpl(true);
                                    Set<String> choices = new HashSet<>();
                                    for (Counter counter : permanent.getCounters().values()) {
                                        if (permanent.getCounters().getCount(counter.getName()) > 0) {
                                            choices.add(counter.getName());
                                        }
                                    }
                                    choice.setChoices(choices);
                                    choice.setMessage("Choose a counter to remove from " + permanent.getLogName());
                                    controller.choose(Outcome.UnboostCreature, choice, game);
                                    counterName = choice.getChoice();
                                } else {
                                    for (Counter counter : permanent.getCounters().values()) {
                                        if (counter.getCount() > 0) {
                                            counterName = counter.getName();
                                        }
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        Permanent permanent = game.getPermanent(source.getSourceId());
        if (controller != null && permanent != null) {
            Choice typeChoice = new ChoiceImpl(true);
            typeChoice.setMessage("Choose creature type");
            typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
            while (!controller.choose(outcome, typeChoice, game)) {
                if (!controller.isInGame()) {
                    return false;
                }
            }
            game.informPlayers(permanent.getName() + ": " + controller.getName() + " has chosen " + typeChoice.getChoice());
            game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice());
            permanent.addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()));
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of mage.choices.Choice

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.