@Override
 public boolean apply(Game game, Ability source) {
   Mana types = getManaTypes(game, source);
   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() != null) {
       Mana mana = new Mana();
       switch (choice.getChoice()) {
         case "Black":
           mana.setBlack(1);
           break;
         case "Blue":
           mana.setBlue(1);
           break;
         case "Red":
           mana.setRed(1);
           break;
         case "Green":
           mana.setGreen(1);
           break;
         case "White":
           mana.setWhite(1);
           break;
       }
       checkToFirePossibleEvents(mana, game, source);
       player.getManaPool().addMana(mana, game, source);
     }
   }
   return true;
 }
예제 #2
0
 public Mana computeMana(boolean netMana, Game game, Ability source) {
   this.computedMana.clear();
   int count = amount.calculate(game, source, this);
   if (mana.getBlack() > 0) {
     computedMana.setBlack(count);
   } else if (mana.getBlue() > 0) {
     computedMana.setBlue(count);
   } else if (mana.getGreen() > 0) {
     computedMana.setGreen(count);
   } else if (mana.getRed() > 0) {
     computedMana.setRed(count);
   } else if (mana.getWhite() > 0) {
     computedMana.setWhite(count);
   } else if (mana.getAny() > 0) {
     if (netMana) {
       computedMana.setAny(count);
     } else {
       Player controller = game.getPlayer(source.getControllerId());
       if (controller != null) {
         for (int i = 0; i < count; i++) {
           ChoiceColor choiceColor = new ChoiceColor();
           while (!controller.choose(Outcome.Benefit, choiceColor, game)) {
             if (!controller.isInGame()) {
               return computedMana;
             }
           }
           if (choiceColor.getColor().isBlack()) {
             computedMana.addBlack();
           } else if (choiceColor.getColor().isBlue()) {
             computedMana.addBlue();
           } else if (choiceColor.getColor().isRed()) {
             computedMana.addRed();
           } else if (choiceColor.getColor().isGreen()) {
             computedMana.addGreen();
           } else if (choiceColor.getColor().isWhite()) {
             computedMana.addWhite();
           }
         }
       }
     }
   } else {
     computedMana.setColorless(count);
   }
   return computedMana;
 }