Exemplo n.º 1
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;
  }
Exemplo n.º 2
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;
 }
 @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;
 }
Exemplo n.º 4
0
  @java.lang.Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (permanent != null && player != null) {
      List<UUID> imprinted = permanent.getImprinted();
      if (imprinted.size() > 0) {
        Card imprintedCard = game.getCard(imprinted.get(0));
        if (imprintedCard != null) {
          Choice choice = new ChoiceImpl(true);
          choice.setMessage("Pick a mana color");
          ObjectColor color = imprintedCard.getColor(game);
          if (color.isBlack()) {
            choice.getChoices().add("Black");
          }
          if (color.isRed()) {
            choice.getChoices().add("Red");
          }
          if (color.isBlue()) {
            choice.getChoices().add("Blue");
          }
          if (color.isGreen()) {
            choice.getChoices().add("Green");
          }
          if (color.isWhite()) {
            choice.getChoices().add("White");
          }

          if (choice.getChoices().size() > 0) {
            Mana mana = new Mana();
            if (choice.getChoices().size() == 1) {
              choice.setChoice(choice.getChoices().iterator().next());
            } else {
              player.choose(outcome, choice, game);
            }
            if (choice.getChoice().equals("Black")) {
              player.getManaPool().addMana(Mana.BlackMana, game, source);
            } else if (choice.getChoice().equals("Blue")) {
              player.getManaPool().addMana(Mana.BlueMana, game, source);
            } else if (choice.getChoice().equals("Red")) {
              player.getManaPool().addMana(Mana.RedMana, game, source);
            } else if (choice.getChoice().equals("Green")) {
              player.getManaPool().addMana(Mana.GreenMana, game, source);
            } else if (choice.getChoice().equals("White")) {
              player.getManaPool().addMana(Mana.WhiteMana, game, source);
            } else if (choice.getChoice().equals("Colorless")) {
              player.getManaPool().addMana(Mana.ColorlessMana, game, source);
            }
            checkToFirePossibleEvents(mana, game, source);
            player.getManaPool().addMana(mana, game, source);
          }
        }
      }
    }
    return true;
  }
Exemplo n.º 5
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;
 }