@Override
 public boolean apply(Game game, Ability source, Ability abilityToModify) {
   if (manaCostsToReduce != null) {
     CardUtil.adjustCost((SpellAbility) abilityToModify, manaCostsToReduce, false);
   } else {
     if (upTo) {
       Mana mana = abilityToModify.getManaCostsToPay().getMana();
       int reduceMax = mana.getColorless();
       if (reduceMax > 2) {
         reduceMax = 2;
       }
       if (reduceMax > 0) {
         Player controller = game.getPlayer(abilityToModify.getControllerId());
         if (controller == null) {
           return false;
         }
         ChoiceImpl choice = new ChoiceImpl(true);
         Set<String> set = new LinkedHashSet<>();
         for (int i = 0; i <= reduceMax; i++) {
           set.add(String.valueOf(i));
         }
         choice.setChoices(set);
         choice.setMessage("Reduce cost of " + filter);
         if (controller.choose(Outcome.Benefit, choice, game)) {
           int reduce = Integer.parseInt(choice.getChoice());
           CardUtil.reduceCost(abilityToModify, reduce);
         }
       }
     } else {
       CardUtil.reduceCost(abilityToModify, this.amount);
     }
   }
   return true;
 }
예제 #2
0
 @Override
 public boolean apply(Game game, Ability source) {
   ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
   Player player = game.getPlayer(source.getControllerId());
   if (player != null) {
     int countMax =
         game.getBattlefield()
             .count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game);
     ChoiceImpl choiceCount = new ChoiceImpl(true);
     LinkedHashSet<String> set = new LinkedHashSet<String>();
     for (int i = 0; i <= countMax; i++) {
       set.add(Integer.toString(i));
     }
     choiceCount.setChoices(set);
     choiceCount.setMessage("Choose number of mana");
     player.choose(Outcome.PutManaInPool, choiceCount, game);
     int count = Integer.parseInt(choiceCount.getChoice());
     if (choice.getColor().isBlack()) {
       player.getManaPool().addMana(new Mana(0, 0, 0, 0, count, 0, 0), game, source);
       return true;
     } else if (choice.getColor().isBlue()) {
       player.getManaPool().addMana(new Mana(0, 0, count, 0, 0, 0, 0), game, source);
       return true;
     } else if (choice.getColor().isRed()) {
       player.getManaPool().addMana(new Mana(count, 0, 0, 0, 0, 0, 0), game, source);
       return true;
     } else if (choice.getColor().isGreen()) {
       player.getManaPool().addMana(new Mana(0, count, 0, 0, 0, 0, 0), game, source);
       return true;
     } else if (choice.getColor().isWhite()) {
       player.getManaPool().addMana(new Mana(0, 0, 0, count, 0, 0, 0), game, source);
       return true;
     }
   }
   return false;
 }