コード例 #1
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;
 }
コード例 #2
0
ファイル: DynamicManaEffect.java プロジェクト: joshhazel/mage
 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;
 }
コード例 #3
0
ファイル: ReflectingPool.java プロジェクト: nigelzor/mage
 @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;
 }