Ejemplo n.º 1
0
  /**
   * Handles X mana costs and sets manaCostsToPay.
   *
   * @param game
   * @param noMana
   * @param controller
   * @return variableManaCost for posting to log later
   */
  protected VariableManaCost handleManaXCosts(Game game, boolean noMana, Player controller) {
    // 20121001 - 601.2b
    // If the spell has a variable cost that will be paid as it's being cast (such as an {X} in
    // its mana cost; see rule 107.3), the player announces the value of that variable.
    // TODO: Handle announcing other variable costs here like: RemoveVariableCountersSourceCost
    VariableManaCost variableManaCost = null;
    for (ManaCost cost : manaCostsToPay) {
      if (cost instanceof VariableManaCost) {
        variableManaCost = (VariableManaCost) cost;
        break; // only one VariableManCost per spell (or is it possible to have more?)
      }
    }
    if (variableManaCost != null) {
      int xValue;
      if (!variableManaCost.isPaid()) { // should only happen for human players
        if (!noMana) {
          xValue =
              controller.announceXMana(
                  variableManaCost.getMinX(),
                  variableManaCost.getMaxX(),
                  "Announce the value for " + variableManaCost.getText(),
                  game,
                  this);
          int amountMana = xValue * variableManaCost.getMultiplier();
          StringBuilder manaString = threadLocalBuilder.get();
          if (variableManaCost.getFilter() == null || variableManaCost.getFilter().isGeneric()) {
            manaString.append("{").append(amountMana).append("}");
          } else {
            String manaSymbol = null;
            if (variableManaCost.getFilter().isBlack()) {
              manaSymbol = "B";
            } else if (variableManaCost.getFilter().isRed()) {
              manaSymbol = "R";
            } else if (variableManaCost.getFilter().isBlue()) {
              manaSymbol = "U";
            } else if (variableManaCost.getFilter().isGreen()) {
              manaSymbol = "G";
            } else if (variableManaCost.getFilter().isWhite()) {
              manaSymbol = "W";
            }
            if (manaSymbol == null) {
              throw new UnsupportedOperationException(
                  "ManaFilter is not supported: " + this.toString());
            }
            for (int i = 0; i < amountMana; i++) {
              manaString.append("{").append(manaSymbol).append("}");
            }
          }
          manaCostsToPay.add(new ManaCostsImpl(manaString.toString()));
          manaCostsToPay.setX(amountMana);
        }
        variableManaCost.setPaid();
      }
    }

    return variableManaCost;
  }
Ejemplo n.º 2
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player you = game.getPlayer(source.getControllerId());
   ManaCosts cost = new ManaCostsImpl("{X}");
   if (you != null && you.chooseUse(Outcome.Neutral, "Do you want to to pay {X}?", game)) {
     int costX =
         you.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
     cost.add(new GenericManaCost(costX));
     if (cost.pay(source, game, source.getId(), source.getControllerId(), false)) {
       Token token = new GoblinSoldierToken();
       return token.putOntoBattlefield(
           costX, game, source.getSourceId(), source.getControllerId());
     }
   }
   return false;
 }
Ejemplo n.º 3
0
 protected static int playerPaysXGenericMana(Player player, Ability source, Game game) {
   int xValue = 0;
   boolean payed = false;
   while (player.canRespond() && !payed) {
     xValue =
         player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
     if (xValue > 0) {
       Cost cost = new GenericManaCost(xValue);
       payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
     } else {
       payed = true;
     }
   }
   game.informPlayers(
       new StringBuilder(player.getLogName())
           .append(" pays {")
           .append(xValue)
           .append("}.")
           .toString());
   return xValue;
 }