コード例 #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 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;
 }
コード例 #3
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;
  }
コード例 #4
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;
  }