Exemplo n.º 1
0
 @Override
 public int compare(MageCard o1, MageCard o2) {
   int val =
       CardUtil.getColorIdentitySortValue(
               o1.getOriginal().getManaCost(),
               o1.getOriginal().getColor(),
               o1.getOriginal().getRules())
           - CardUtil.getColorIdentitySortValue(
               o2.getOriginal().getManaCost(),
               o2.getOriginal().getColor(),
               o2.getOriginal().getRules());
   if (val == 0) {
     return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
   } else {
     return val;
   }
 }
Exemplo n.º 2
0
  public static JXPanel getDescription(CardView card, int width, int height) {
    JXPanel descriptionPanel = new JXPanel();

    // descriptionPanel.setAlpha(.8f);
    descriptionPanel.setBounds(0, 0, width, height);
    descriptionPanel.setVisible(false);
    descriptionPanel.setLayout(null);

    // descriptionPanel.setBorder(BorderFactory.createLineBorder(Color.green));

    JButton j = new JButton("");
    j.setBounds(0, 0, width, height);
    j.setBackground(Color.black);
    j.setLayout(null);

    JLabel name = new JLabel("Wrath of God");
    name.setBounds(5, 5, width - 90, 20);
    name.setForeground(Color.white);
    name.setFont(cardNameFont);
    // name.setBorder(BorderFactory.createLineBorder(Color.green));
    j.add(name);

    JLabel cost = new JLabel("B R G W U");
    cost.setBounds(width - 85, 5, 77, 20);
    cost.setForeground(Color.white);
    cost.setFont(cardNameFont);
    // cost.setBorder(BorderFactory.createLineBorder(Color.green));
    cost.setHorizontalAlignment(SwingConstants.RIGHT);
    j.add(cost);

    JLabel type = new JLabel("Creature - Goblin Shaman");
    type.setBounds(5, 70, width - 8, 20);
    type.setForeground(Color.white);
    type.setFont(cardNameFont);
    // type.setBorder(BorderFactory.createLineBorder(Color.green));
    j.add(type);

    JLabel cardText = new JLabel();
    cardText.setBounds(5, 100, width - 8, 260);
    cardText.setForeground(Color.white);
    cardText.setFont(cardNameFont);
    cardText.setVerticalAlignment(SwingConstants.TOP);
    // cardText.setBorder(new EtchedBorder());
    j.add(cardText);

    name.setText(card.getName());
    cost.setText(card.getManaCost().toString());
    String typeText = "";
    String delimiter = card.getCardTypes().size() > 1 ? " - " : "";
    for (CardType t : card.getCardTypes()) {
      typeText += t;
      typeText += delimiter;
      delimiter = " "; // next delimiters are just spaces
    }
    type.setText(typeText);
    cardText.setText("<html>" + card.getRules() + "</html>");

    if (CardUtil.isCreature(card)) {
      JLabel pt = new JLabel(card.getPower() + "/" + card.getToughness());
      pt.setBounds(width - 50, height - 30, 40, 20);
      pt.setForeground(Color.white);
      pt.setFont(cardNameFont);
      pt.setHorizontalAlignment(JLabel.RIGHT);
      j.add(pt);
    }

    descriptionPanel.add(j);

    return descriptionPanel;
  }
Exemplo n.º 3
0
 @Override
 public void drawCards(SortSetting sortSetting) {
   int maxWidth = this.getParent().getWidth();
   int cardVerticalOffset = GUISizeHelper.editorCardOffsetSize;
   int numColumns = maxWidth / cardDimension.width;
   int curColumn = 0;
   int curRow = 0;
   if (cards.size() > 0) {
     Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
     List<MageCard> sortedCards = new ArrayList<>(cards.values());
     switch (sortSetting.getSortBy()) {
       case NAME:
         Collections.sort(sortedCards, new CardNameComparator());
         break;
       case RARITY:
         Collections.sort(sortedCards, new CardRarityComparator());
         break;
       case COLOR:
         Collections.sort(sortedCards, new CardColorComparator());
         break;
       case COLOR_IDENTITY:
         Collections.sort(sortedCards, new CardColorDetailedIdentity());
         break;
       case CASTING_COST:
         Collections.sort(sortedCards, new CardCostComparator());
         break;
     }
     MageCard lastCard = null;
     for (MageCard cardImg : sortedCards) {
       if (sortSetting.isPilesToggle()) {
         if (lastCard == null) {
           lastCard = cardImg;
         }
         switch (sortSetting.getSortBy()) {
           case NAME:
             if (!cardImg.getOriginal().getName().equals(lastCard.getOriginal().getName())) {
               curColumn++;
               curRow = 0;
             }
             break;
           case RARITY:
             if (!cardImg.getOriginal().getRarity().equals(lastCard.getOriginal().getRarity())) {
               curColumn++;
               curRow = 0;
             }
             break;
           case COLOR:
             if (cardImg.getOriginal().getColor().compareTo(lastCard.getOriginal().getColor())
                 != 0) {
               curColumn++;
               curRow = 0;
             }
             break;
           case COLOR_IDENTITY:
             if (CardUtil.getColorIdentitySortValue(
                     cardImg.getOriginal().getManaCost(),
                     cardImg.getOriginal().getColor(),
                     cardImg.getOriginal().getRules())
                 != CardUtil.getColorIdentitySortValue(
                     lastCard.getOriginal().getManaCost(),
                     lastCard.getOriginal().getColor(),
                     lastCard.getOriginal().getRules())) {
               curColumn++;
               curRow = 0;
             }
             break;
           case CASTING_COST:
             if (cardImg.getOriginal().getConvertedManaCost()
                 != lastCard.getOriginal().getConvertedManaCost()) {
               curColumn++;
               curRow = 0;
             }
             break;
         }
         rectangle.setLocation(curColumn * cardDimension.width, curRow * cardVerticalOffset);
         cardImg.setBounds(rectangle);
         cardImg.setCardBounds(
             rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
         moveToFront(cardImg);
         curRow++;
         lastCard = cardImg;
       } else {
         rectangle.setLocation(curColumn * cardDimension.width, curRow * cardVerticalOffset);
         cardImg.setBounds(rectangle);
         cardImg.setCardBounds(
             rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
         moveToFront(cardImg);
         curColumn++;
         if (curColumn == numColumns) {
           curColumn = 0;
           curRow++;
         }
       }
     }
   }
   resizeArea();
   revalidate();
   repaint();
 }
 @Override
 public int compare(CardView o1, CardView o2) {
   return CardUtil.getColorIdentitySortValue(o1.getManaCost(), o1.getColor(), o1.getRules())
       - CardUtil.getColorIdentitySortValue(o2.getManaCost(), o2.getColor(), o2.getRules());
 }