UI: added draft rating column to deck editor

This commit is contained in:
Oleg Agafonov 2019-02-01 18:57:24 +04:00
parent 0c8fdfcaf2
commit 0697cbe24c
3 changed files with 22 additions and 9 deletions

View file

@ -26,10 +26,12 @@
*/
package mage.client.deckeditor.table;
import java.util.Comparator;
import mage.cards.MageCard;
import mage.game.draft.RateCard;
import mage.view.CardView;
import org.apache.log4j.Logger;
import java.util.Comparator;
/**
* {@link MageCard} comparator. Used to sort cards in Deck Editor Table View
@ -39,6 +41,8 @@ import mage.view.CardView;
*/
public class MageCardComparator implements Comparator<CardView> {
private static final Logger logger = Logger.getLogger(MageCardComparator.class);
private final int column;
private final boolean ascending;
@ -49,14 +53,12 @@ public class MageCardComparator implements Comparator<CardView> {
@Override
public int compare(CardView a, CardView b) {
Comparable aCom = null;
Comparable bCom = null;
Comparable aCom = 1;
Comparable bCom = 1;
switch (column) {
// #skip
case 0:
aCom = 1;
bCom = 1;
break;
// Name
case 1:
@ -107,6 +109,10 @@ public class MageCardComparator implements Comparator<CardView> {
aCom = Integer.parseInt(a.getCardNumber().replaceAll("[\\D]", ""));
bCom = Integer.parseInt(b.getCardNumber().replaceAll("[\\D]", ""));
break;
case 9:
aCom = RateCard.rateCard(a.getOriginalCard(), null);
bCom = RateCard.rateCard(b.getOriginalCard(), null);
break;
default:
break;
}

View file

@ -1,4 +1,3 @@
package mage.client.deckeditor.table;
import mage.client.MageFrame;
@ -13,6 +12,7 @@ import mage.client.util.Event;
import mage.client.util.Listener;
import mage.client.util.gui.GuiDisplayUtil;
import mage.constants.EnlargeMode;
import mage.game.draft.RateCard;
import mage.view.CardView;
import mage.view.CardsView;
import org.apache.log4j.Logger;
@ -25,8 +25,8 @@ import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.util.*;
import java.util.List;
import java.util.*;
import java.util.Map.Entry;
/**
@ -51,8 +51,9 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
private boolean displayNoCopies = false;
private UpdateCountsCallback updateCountsCallback;
private final String column[] = {"Qty", "Name", "Cost", "Color", "Type", "Stats", "Rarity", "Set", "#"};
private final String[] column = {"Qty", "Name", "Cost", "Color", "Type", "Stats", "Rarity", "Set", "Card number", "Draft Rating"};
public final int COLUMN_INDEX_COST = 2;
public final int COLUMN_INDEX_RATING = 9;
private SortSetting sortSetting;
private int recentSortedColumn;
@ -239,6 +240,8 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
return c.getExpansionSetCode();
case 8:
return c.getCardNumber();
case 9:
return RateCard.rateCard(c.getOriginalCard(), null);
default:
return "error";
}

View file

@ -78,6 +78,10 @@ public final class RateCard {
}
public static int rateCard(Card card, List<ColoredManaSymbol> allowedColors, boolean useCache) {
if (card == null) {
return 0;
}
if (useCache && allowedColors == null && rated.containsKey(card.getName())) {
int rate = rated.get(card.getName());
return rate;