mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
UI: added draft rating column to deck editor
This commit is contained in:
parent
0c8fdfcaf2
commit
0697cbe24c
3 changed files with 22 additions and 9 deletions
|
@ -26,10 +26,12 @@
|
||||||
*/
|
*/
|
||||||
package mage.client.deckeditor.table;
|
package mage.client.deckeditor.table;
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
|
import mage.game.draft.RateCard;
|
||||||
import mage.view.CardView;
|
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
|
* {@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> {
|
public class MageCardComparator implements Comparator<CardView> {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(MageCardComparator.class);
|
||||||
|
|
||||||
private final int column;
|
private final int column;
|
||||||
private final boolean ascending;
|
private final boolean ascending;
|
||||||
|
|
||||||
|
@ -49,14 +53,12 @@ public class MageCardComparator implements Comparator<CardView> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(CardView a, CardView b) {
|
public int compare(CardView a, CardView b) {
|
||||||
Comparable aCom = null;
|
Comparable aCom = 1;
|
||||||
Comparable bCom = null;
|
Comparable bCom = 1;
|
||||||
|
|
||||||
switch (column) {
|
switch (column) {
|
||||||
// #skip
|
// #skip
|
||||||
case 0:
|
case 0:
|
||||||
aCom = 1;
|
|
||||||
bCom = 1;
|
|
||||||
break;
|
break;
|
||||||
// Name
|
// Name
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -107,6 +109,10 @@ public class MageCardComparator implements Comparator<CardView> {
|
||||||
aCom = Integer.parseInt(a.getCardNumber().replaceAll("[\\D]", ""));
|
aCom = Integer.parseInt(a.getCardNumber().replaceAll("[\\D]", ""));
|
||||||
bCom = Integer.parseInt(b.getCardNumber().replaceAll("[\\D]", ""));
|
bCom = Integer.parseInt(b.getCardNumber().replaceAll("[\\D]", ""));
|
||||||
break;
|
break;
|
||||||
|
case 9:
|
||||||
|
aCom = RateCard.rateCard(a.getOriginalCard(), null);
|
||||||
|
bCom = RateCard.rateCard(b.getOriginalCard(), null);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.client.deckeditor.table;
|
package mage.client.deckeditor.table;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
@ -13,6 +12,7 @@ import mage.client.util.Event;
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.Listener;
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
import mage.constants.EnlargeMode;
|
import mage.constants.EnlargeMode;
|
||||||
|
import mage.game.draft.RateCard;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import mage.view.CardsView;
|
import mage.view.CardsView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
@ -25,8 +25,8 @@ import javax.swing.table.TableColumnModel;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.*;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,8 +51,9 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
||||||
private boolean displayNoCopies = false;
|
private boolean displayNoCopies = false;
|
||||||
private UpdateCountsCallback updateCountsCallback;
|
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_COST = 2;
|
||||||
|
public final int COLUMN_INDEX_RATING = 9;
|
||||||
|
|
||||||
private SortSetting sortSetting;
|
private SortSetting sortSetting;
|
||||||
private int recentSortedColumn;
|
private int recentSortedColumn;
|
||||||
|
@ -239,6 +240,8 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
||||||
return c.getExpansionSetCode();
|
return c.getExpansionSetCode();
|
||||||
case 8:
|
case 8:
|
||||||
return c.getCardNumber();
|
return c.getCardNumber();
|
||||||
|
case 9:
|
||||||
|
return RateCard.rateCard(c.getOriginalCard(), null);
|
||||||
default:
|
default:
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,10 @@ public final class RateCard {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int rateCard(Card card, List<ColoredManaSymbol> allowedColors, boolean useCache) {
|
public static int rateCard(Card card, List<ColoredManaSymbol> allowedColors, boolean useCache) {
|
||||||
|
if (card == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (useCache && allowedColors == null && rated.containsKey(card.getName())) {
|
if (useCache && allowedColors == null && rated.containsKey(card.getName())) {
|
||||||
int rate = rated.get(card.getName());
|
int rate = rated.get(card.getName());
|
||||||
return rate;
|
return rate;
|
||||||
|
|
Loading…
Reference in a new issue