예제 #1
0
  public MODEL_Card drawMaxCard(String propertyName, String matchKeywords, String excludeKeywords)
      throws XCFException {
    MODEL_Card drawnCard = null;
    int max = -1;

    for (MODEL_Card card : cards) {
      if (card.matches(matchKeywords)) {
        if (excludeKeywords == null || !card.matches(excludeKeywords)) {
          int amount = 0;
          String sCardAttributeValue = card.getProperty(propertyName);
          try {
            amount = Integer.parseInt(sCardAttributeValue);
          } catch (NumberFormatException e) {
            throw new XCFException(propertyName + " not and integer for " + card.getName());
          }

          if (amount > max) {
            drawnCard = card;
            max = amount;
          }
        }
      }
    }

    if (drawnCard == null) return null;
    cards.remove(drawnCard);

    return drawnCard;
  }
예제 #2
0
  public MODEL_Card add(Integer cardId, int limit) throws XCFException {
    MODEL_Card card = cardMgr.getCard(cardId);
    if (card == null) throw new XCFException(cardId + " is not a registed card.");

    if ((cost + card.getCost()) > limit) {
      throw new XCFException(
          "You can't add " + card.getName() + ".  You are out of action points.");
    }

    cost += card.getCost();
    add(card);
    return card;
  }