Esempio n. 1
0
  /**
   * formatCardType.
   *
   * @param card a {@link forge.Card} object.
   * @return a {@link java.lang.String} object.
   */
  public static String formatCardType(Card card) {
    ArrayList<String> list = card.getType();
    StringBuilder sb = new StringBuilder();

    ArrayList<String> superTypes = new ArrayList<String>();
    ArrayList<String> cardTypes = new ArrayList<String>();
    ArrayList<String> subTypes = new ArrayList<String>();
    for (String t : list) {
      if (CardUtil.isASuperType(t)) superTypes.add(t);
      if (CardUtil.isACardType(t)) cardTypes.add(t);
      if (CardUtil.isASubType(t)) subTypes.add(t);
    }

    for (String type : superTypes) {
      sb.append(type).append(" ");
    }
    for (String type : cardTypes) {
      sb.append(type).append(" ");
    }
    if (!subTypes.isEmpty()) sb.append("- ");
    for (String type : subTypes) {
      sb.append(type).append(" ");
    }

    return sb.toString();
  }
Esempio n. 2
0
  /**
   * devProcessCardsForZone.
   *
   * @param data an array of {@link java.lang.String} objects.
   * @param player a {@link forge.Player} object.
   * @return a {@link forge.CardList} object.
   */
  public static CardList devProcessCardsForZone(String[] data, Player player) {
    CardList cl = new CardList();
    for (int i = 0; i < data.length; i++) {
      String cardinfo[] = data[i].trim().split("\\|");

      Card c = AllZone.getCardFactory().getCard(cardinfo[0], player);

      if (cardinfo.length != 2) c.setCurSetCode(c.getMostRecentSet());
      else c.setCurSetCode(cardinfo[1]);

      c.setImageFilename(CardUtil.buildFilename(c));
      for (Trigger trig : c.getTriggers()) {
        AllZone.getTriggerHandler().registerTrigger(trig);
      }
      cl.add(c);
    }
    return cl;
  }
Esempio n. 3
0
  /**
   * getBorder.
   *
   * @param card a {@link forge.Card} object.
   * @return a {@link javax.swing.border.Border} object.
   */
  public static Border getBorder(Card card) {
    // color info
    if (card == null) return BorderFactory.createEmptyBorder(2, 2, 2, 2);
    java.awt.Color color;
    ArrayList<String> list = CardUtil.getColors(card);

    if (card.isFaceDown()) color = Color.gray;
    else if (list.size() > 1) color = Color.orange;
    else if (list.get(0).equals(Constant.Color.Black)) color = Color.black;
    else if (list.get(0).equals(Constant.Color.Green)) color = new Color(0, 220, 39);
    else if (list.get(0).equals(Constant.Color.White)) color = Color.white;
    else if (list.get(0).equals(Constant.Color.Red)) color = Color.red;
    else if (list.get(0).equals(Constant.Color.Blue)) color = Color.blue;
    else if (list.get(0).equals(Constant.Color.Colorless)) color = Color.gray;
    else color = new Color(200, 0, 230); // If your card has a violet border, something is wrong

    if (color != Color.gray) {

      int r = color.getRed();
      int g = color.getGreen();
      int b = color.getBlue();

      int shade = 10;

      r -= shade;
      g -= shade;
      b -= shade;

      r = Math.max(0, r);
      g = Math.max(0, g);
      b = Math.max(0, b);

      color = new Color(r, g, b);

      return BorderFactory.createLineBorder(color, 2);
    } else return BorderFactory.createLineBorder(Color.gray, 2);
  }