Esempio n. 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;
  }
Esempio n. 2
0
 public int size(String matchKeywords, String excludeKeywords) {
   if ("*".equals(matchKeywords) && excludeKeywords == null) return cards.size();
   int size = 0;
   for (MODEL_Card card : cards) {
     if (card.matches(matchKeywords)) {
       if (excludeKeywords == null || !card.matches(excludeKeywords)) {
         size++;
       }
     }
   }
   return size;
 }
Esempio n. 3
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;
  }
Esempio n. 4
0
  public MODEL_Card drawCard(String matchKeywords, String excludeKeywords) {
    MODEL_Card drawnCard = null;

    for (MODEL_Card card : cards) {
      if (card.matches(matchKeywords)) {
        if (excludeKeywords == null || !card.matches(excludeKeywords)) {
          drawnCard = card;
          break;
        }
      }
    }

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

    return drawnCard;
  }
Esempio n. 5
0
  public Integer[] getOverrideState() {
    if (numOverrides <= 0) return null;

    Integer[] overrideState = new Integer[2];
    overrideState[0] = override.getID();
    overrideState[1] = numOverrides;

    return overrideState;
  }
Esempio n. 6
0
  public MODEL_Card drawCardFromBottom(String matchKeywords, String excludeKeywords) {
    MODEL_Card drawnCard = null;

    int i = 0;
    for (i = cards.size() - 1; i >= 0; i--) {
      MODEL_Card card = cards.get(i);
      if (card.matches(matchKeywords)) {
        if (excludeKeywords == null || !card.matches(excludeKeywords)) {
          drawnCard = card;
          break;
        }
      }
    }

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

    return drawnCard;
  }