Beispiel #1
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player you = game.getPlayer(source.getControllerId());
   if (you != null) {
     Mana mana = new Mana();
     for (Permanent permanent : game.getBattlefield().getAllActivePermanents(you.getId())) {
       if (mana.getBlack() == 0 && permanent.getColor().isBlack()) {
         mana.addBlack();
       }
       if (mana.getBlue() == 0 && permanent.getColor().isBlue()) {
         mana.addBlue();
       }
       if (mana.getRed() == 0 && permanent.getColor().isRed()) {
         mana.addRed();
       }
       if (mana.getGreen() == 0 && permanent.getColor().isGreen()) {
         mana.addGreen();
       }
       if (mana.getWhite() == 0 && permanent.getColor().isWhite()) {
         mana.addWhite();
       }
     }
     you.getManaPool().addMana(mana, game, source);
     return true;
   }
   return false;
 }
Beispiel #2
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
      int x =
          game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);

      Mana mana = new Mana();
      for (int i = 0; i < x; i++) {
        ChoiceColor choiceColor = new ChoiceColor();
        while (!player.choose(Outcome.Benefit, choiceColor, game)) {
          if (!player.isInGame()) {
            return false;
          }
        }

        if (choiceColor.getColor().isBlack()) {
          mana.addBlack();
        } else if (choiceColor.getColor().isBlue()) {
          mana.addBlue();
        } else if (choiceColor.getColor().isRed()) {
          mana.addRed();
        } else if (choiceColor.getColor().isGreen()) {
          mana.addGreen();
        } else if (choiceColor.getColor().isWhite()) {
          mana.addWhite();
        }
      }

      player.getManaPool().addMana(mana, game, source);
      return true;
    }
    return false;
  }
Beispiel #3
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;
 }