Exemplo n.º 1
0
 public List<Mana> getNetMana(Game game, Ability source) {
   List<Mana> netManas = new ArrayList<>();
   Mana types = getManaTypes(game, source);
   if (types.getAny() > 0) {
     netManas.add(new Mana(0, 0, 0, 0, 0, 0, 1, 0));
     return netManas;
   }
   if (types.getBlack() > 0) {
     netManas.add(new Mana(ColoredManaSymbol.B));
   }
   if (types.getRed() > 0) {
     netManas.add(new Mana(ColoredManaSymbol.R));
   }
   if (types.getBlue() > 0) {
     netManas.add(new Mana(ColoredManaSymbol.U));
   }
   if (types.getGreen() > 0) {
     netManas.add(new Mana(ColoredManaSymbol.G));
   }
   if (types.getWhite() > 0) {
     netManas.add(new Mana(ColoredManaSymbol.W));
   }
   if (types.getColorless() > 0) {
     netManas.add(Mana.ColorlessMana(1));
   }
   return netManas;
 }
Exemplo n.º 2
0
 @Override
 public boolean apply(Game game, Ability source, Ability abilityToModify) {
   SpellAbility spellAbility = (SpellAbility) abilityToModify;
   Mana mana = spellAbility.getManaCostsToPay().getMana();
   if (mana.getColorless() > 0) {
     int count = new DevotionCount(ColoredManaSymbol.B).calculate(game, source);
     int newCount = mana.getColorless() - count;
     if (newCount < 0) {
       newCount = 0;
     }
     mana.setColorless(newCount);
     spellAbility.getManaCostsToPay().load(mana.toString());
     return true;
   }
   return false;
 }
 @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;
 }
Exemplo n.º 4
0
 @Override
 public boolean apply(Game game, Ability source) {
   Mana types = getManaTypes(game, source);
   Choice choice = new ChoiceImpl(false);
   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 (types.getAny() > 0) {
     choice.getChoices().add("Black");
     choice.getChoices().add("Red");
     choice.getChoices().add("Blue");
     choice.getChoices().add("Green");
     choice.getChoices().add("White");
     choice.getChoices().add("Colorless");
   }
   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;
         case "Colorless":
           mana.setColorless(1);
           break;
       }
       checkToFirePossibleEvents(mana, game, source);
       player.getManaPool().addMana(mana, game, source);
       return true;
     }
     return false;
   }
   return true;
 }