mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
Deck editor - renamed sort type "Color Detailed" to "Color Identity" and compare for the sort also with mana symbols in casting cost and rules.
This commit is contained in:
parent
e94163a4c3
commit
322eae2ec6
6 changed files with 233 additions and 187 deletions
|
|
@ -31,7 +31,6 @@
|
||||||
*
|
*
|
||||||
* Created on 30-Mar-2010, 9:25:40 PM
|
* Created on 30-Mar-2010, 9:25:40 PM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
|
@ -54,6 +53,7 @@ import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.Listener;
|
||||||
|
import mage.utils.CardUtil;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import mage.view.CardsView;
|
import mage.view.CardsView;
|
||||||
import org.mage.card.arcane.CardPanel;
|
import org.mage.card.arcane.CardPanel;
|
||||||
|
|
@ -144,7 +144,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
|
||||||
int curRow = 0;
|
int curRow = 0;
|
||||||
if (cards.size() > 0) {
|
if (cards.size() > 0) {
|
||||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||||
List<MageCard> sortedCards = new ArrayList<MageCard>(cards.values());
|
List<MageCard> sortedCards = new ArrayList<>(cards.values());
|
||||||
switch (sortSetting.getSortBy()) {
|
switch (sortSetting.getSortBy()) {
|
||||||
case NAME:
|
case NAME:
|
||||||
Collections.sort(sortedCards, new CardNameComparator());
|
Collections.sort(sortedCards, new CardNameComparator());
|
||||||
|
|
@ -155,12 +155,13 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
|
||||||
case COLOR:
|
case COLOR:
|
||||||
Collections.sort(sortedCards, new CardColorComparator());
|
Collections.sort(sortedCards, new CardColorComparator());
|
||||||
break;
|
break;
|
||||||
case COLOR_DETAILED:
|
case COLOR_IDENTITY:
|
||||||
Collections.sort(sortedCards, new CardColorDetailedComparator());
|
Collections.sort(sortedCards, new CardColorDetailedIdentity());
|
||||||
break;
|
break;
|
||||||
case CASTING_COST:
|
case CASTING_COST:
|
||||||
Collections.sort(sortedCards, new CardCostComparator());
|
Collections.sort(sortedCards, new CardCostComparator());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
MageCard lastCard = null;
|
MageCard lastCard = null;
|
||||||
for (MageCard cardImg : sortedCards) {
|
for (MageCard cardImg : sortedCards) {
|
||||||
|
|
@ -187,8 +188,9 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
|
||||||
curRow = 0;
|
curRow = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COLOR_DETAILED:
|
case COLOR_IDENTITY:
|
||||||
if (cardImg.getOriginal().getColor().hashCode() != lastCard.getOriginal().getColor().hashCode()) {
|
if (CardUtil.getColorIdentitySortValue(cardImg.getOriginal().getManaCost(), cardImg.getOriginal().getColor(), cardImg.getOriginal().getRules())
|
||||||
|
!= CardUtil.getColorIdentitySortValue(lastCard.getOriginal().getManaCost(), lastCard.getOriginal().getColor(), lastCard.getOriginal().getRules())) {
|
||||||
curColumn++;
|
curColumn++;
|
||||||
curRow = 0;
|
curRow = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -206,8 +208,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
|
||||||
moveToFront(cardImg);
|
moveToFront(cardImg);
|
||||||
curRow++;
|
curRow++;
|
||||||
lastCard = cardImg;
|
lastCard = cardImg;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||||
cardImg.setBounds(rectangle);
|
cardImg.setBounds(rectangle);
|
||||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||||
|
|
@ -275,10 +276,10 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
|
||||||
cardEventSource.clearListeners();
|
cardEventSource.clearListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/**
|
||||||
* initialize the form.
|
* This method is called from within the constructor to initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
* always regenerated by the Form Editor.
|
* regenerated by the Form Editor.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
|
@ -296,10 +297,8 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
|
||||||
);
|
);
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if (e.getClickCount() == 2 && !e.isConsumed()) {
|
if (e.getClickCount() == 2 && !e.isConsumed()) {
|
||||||
|
|
@ -322,16 +321,20 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {}
|
public void mousePressed(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e) {}
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {}
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {}
|
public void mouseExited(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
private void resizeArea() {
|
private void resizeArea() {
|
||||||
Dimension area = new Dimension(0, 0);
|
Dimension area = new Dimension(0, 0);
|
||||||
|
|
@ -379,8 +382,7 @@ class CardRarityComparator implements Comparator<MageCard> {
|
||||||
int val = o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity());
|
int val = o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity());
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -394,8 +396,7 @@ class CardCostComparator implements Comparator<MageCard> {
|
||||||
int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(Integer.valueOf(o2.getOriginal().getConvertedManaCost()));
|
int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(Integer.valueOf(o2.getOriginal().getConvertedManaCost()));
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -409,23 +410,22 @@ class CardColorComparator implements Comparator<MageCard> {
|
||||||
int val = o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor());
|
int val = o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor());
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CardColorDetailedComparator implements Comparator<MageCard> {
|
class CardColorDetailedIdentity implements Comparator<MageCard> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(MageCard o1, MageCard o2) {
|
public int compare(MageCard o1, MageCard o2) {
|
||||||
int val = o1.getOriginal().getColor().hashCode() - o2.getOriginal().getColor().hashCode();
|
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) {
|
if (val == 0) {
|
||||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
*
|
*
|
||||||
* Created on Dec 18, 2009, 10:40:12 AM
|
* Created on Dec 18, 2009, 10:40:12 AM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
@ -59,7 +58,7 @@ import mage.client.constants.Constants.DeckEditorMode;
|
||||||
import mage.client.constants.Constants.SortBy;
|
import mage.client.constants.Constants.SortBy;
|
||||||
import static mage.client.constants.Constants.SortBy.CASTING_COST;
|
import static mage.client.constants.Constants.SortBy.CASTING_COST;
|
||||||
import static mage.client.constants.Constants.SortBy.COLOR;
|
import static mage.client.constants.Constants.SortBy.COLOR;
|
||||||
import static mage.client.constants.Constants.SortBy.COLOR_DETAILED;
|
import static mage.client.constants.Constants.SortBy.COLOR_IDENTITY;
|
||||||
import static mage.client.constants.Constants.SortBy.RARITY;
|
import static mage.client.constants.Constants.SortBy.RARITY;
|
||||||
import mage.client.deckeditor.SortSetting;
|
import mage.client.deckeditor.SortSetting;
|
||||||
import mage.client.deckeditor.table.TableModel;
|
import mage.client.deckeditor.table.TableModel;
|
||||||
|
|
@ -67,7 +66,7 @@ import mage.client.deckeditor.table.UpdateCountsCallback;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.CardViewColorComparator;
|
import mage.client.util.CardViewColorComparator;
|
||||||
import mage.client.util.CardViewColorDetailedComparator;
|
import mage.client.util.CardViewColorIdentityComparator;
|
||||||
import mage.client.util.CardViewCostComparator;
|
import mage.client.util.CardViewCostComparator;
|
||||||
import mage.client.util.CardViewNameComparator;
|
import mage.client.util.CardViewNameComparator;
|
||||||
import mage.client.util.CardViewRarityComparator;
|
import mage.client.util.CardViewRarityComparator;
|
||||||
|
|
@ -99,7 +98,9 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
private JTable mainTable;
|
private JTable mainTable;
|
||||||
private ICardGrid currentView;
|
private ICardGrid currentView;
|
||||||
|
|
||||||
/** Creates new form Cards */
|
/**
|
||||||
|
* Creates new form Cards
|
||||||
|
*/
|
||||||
public CardsList() {
|
public CardsList() {
|
||||||
initComponents();
|
initComponents();
|
||||||
makeTransparent();
|
makeTransparent();
|
||||||
|
|
@ -256,7 +257,6 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
|
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
|
||||||
int selectedRow = -1;
|
int selectedRow = -1;
|
||||||
if (currentView.equals(mainModel)) {
|
if (currentView.equals(mainModel)) {
|
||||||
|
|
@ -301,8 +301,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
if (oldMageCards.containsKey(uuid)) {
|
if (oldMageCards.containsKey(uuid)) {
|
||||||
mageCards.put(uuid, oldMageCards.get(uuid));
|
mageCards.put(uuid, oldMageCards.get(uuid));
|
||||||
oldMageCards.remove(uuid);
|
oldMageCards.remove(uuid);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
mageCards.put(uuid, addCard(cards.get(uuid), bigCard, gameId));
|
mageCards.put(uuid, addCard(cards.get(uuid), bigCard, gameId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -324,8 +323,8 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
case COLOR:
|
case COLOR:
|
||||||
comparator = new CardViewColorComparator();
|
comparator = new CardViewColorComparator();
|
||||||
break;
|
break;
|
||||||
case COLOR_DETAILED:
|
case COLOR_IDENTITY:
|
||||||
comparator = new CardViewColorDetailedComparator();
|
comparator = new CardViewColorIdentityComparator();
|
||||||
break;
|
break;
|
||||||
case CASTING_COST:
|
case CASTING_COST:
|
||||||
comparator = new CardViewCostComparator();
|
comparator = new CardViewCostComparator();
|
||||||
|
|
@ -419,7 +418,6 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
return cardImg;
|
return cardImg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setCardBounds(MageCard card, Rectangle rectangle) {
|
private void setCardBounds(MageCard card, Rectangle rectangle) {
|
||||||
card.setBounds(rectangle);
|
card.setBounds(rectangle);
|
||||||
card.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
card.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||||
|
|
@ -456,10 +454,10 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
mainModel.clearCardEventListeners();
|
mainModel.clearCardEventListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/**
|
||||||
* initialize the form.
|
* This method is called from within the constructor to initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
* always regenerated by the Form Editor.
|
* regenerated by the Form Editor.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
|
@ -732,15 +730,13 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
||||||
if (obj instanceof Card) {
|
if (obj instanceof Card) {
|
||||||
if (e.isAltDown()) {
|
if (e.isAltDown()) {
|
||||||
cardEventSource.altDoubleClick(((Card) obj).getOriginal(), "alt-double-click");
|
cardEventSource.altDoubleClick(((Card) obj).getOriginal(), "alt-double-click");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cardEventSource.doubleClick(((Card) obj).getOriginal(), "double-click");
|
cardEventSource.doubleClick(((Card) obj).getOriginal(), "double-click");
|
||||||
}
|
}
|
||||||
} else if (obj instanceof MageCard) {
|
} else if (obj instanceof MageCard) {
|
||||||
if (e.isAltDown()) {
|
if (e.isAltDown()) {
|
||||||
cardEventSource.altDoubleClick(((MageCard) obj).getOriginal(), "alt-double-click");
|
cardEventSource.altDoubleClick(((MageCard) obj).getOriginal(), "alt-double-click");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cardEventSource.doubleClick(((MageCard) obj).getOriginal(), "double-click");
|
cardEventSource.doubleClick(((MageCard) obj).getOriginal(), "double-click");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.constants;
|
package mage.client.constants;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -37,6 +36,7 @@ import javax.swing.border.Border;
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public final class Constants {
|
public final class Constants {
|
||||||
|
|
||||||
private Constants() {
|
private Constants() {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
@ -83,21 +83,24 @@ public final class Constants {
|
||||||
public static final String BASE_MUSICS_PATH = "music" + File.separator;
|
public static final String BASE_MUSICS_PATH = "music" + File.separator;
|
||||||
|
|
||||||
public interface IO {
|
public interface IO {
|
||||||
|
|
||||||
String imageBaseDir = "plugins" + File.separator + "images" + File.separator;
|
String imageBaseDir = "plugins" + File.separator + "images" + File.separator;
|
||||||
String IMAGE_PROPERTIES_FILE = "image.url.properties";
|
String IMAGE_PROPERTIES_FILE = "image.url.properties";
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DeckEditorMode {
|
public enum DeckEditorMode {
|
||||||
|
|
||||||
FREE_BUILDING,
|
FREE_BUILDING,
|
||||||
LIMITED_BUILDING,
|
LIMITED_BUILDING,
|
||||||
SIDEBOARDING
|
SIDEBOARDING
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SortBy {
|
public enum SortBy {
|
||||||
|
|
||||||
CASTING_COST("Casting Cost"),
|
CASTING_COST("Casting Cost"),
|
||||||
RARITY("Rarity"),
|
RARITY("Rarity"),
|
||||||
COLOR("Color"),
|
COLOR("Color"),
|
||||||
COLOR_DETAILED ("Color Detailed"),
|
COLOR_IDENTITY("Color Identity"),
|
||||||
NAME("Name"),
|
NAME("Name"),
|
||||||
UNSORTED("Unsorted");
|
UNSORTED("Unsorted");
|
||||||
|
|
||||||
|
|
@ -120,8 +123,8 @@ public final class Constants {
|
||||||
return RARITY;
|
return RARITY;
|
||||||
case "Color":
|
case "Color":
|
||||||
return COLOR;
|
return COLOR;
|
||||||
case "Color Detailed":
|
case "Color Identity":
|
||||||
return COLOR_DETAILED;
|
return COLOR_IDENTITY;
|
||||||
case "Name":
|
case "Name":
|
||||||
return NAME;
|
return NAME;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -25,21 +25,31 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.util;
|
package mage.client.util;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import mage.ObjectColor;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class CardViewColorDetailedComparator implements Comparator<CardView> {
|
public class CardViewColorIdentityComparator implements Comparator<CardView> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(CardView o1, CardView o2) {
|
public int compare(CardView o1, CardView o2) {
|
||||||
return o1.getColor().hashCode() - o2.getColor().hashCode();
|
return sortValue(o1.getManaCost(), o1.getColor()) - sortValue(o2.getManaCost(), o2.getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public int sortValue(List<String> manaCost, ObjectColor color) {
|
||||||
|
int hash = 3;
|
||||||
|
hash = 23 * hash + (color.isWhite() || manaCost.contains("{W}") ? 1 : 0);
|
||||||
|
hash = 23 * hash + (color.isBlue() || manaCost.contains("{U}") ? 1 : 0);
|
||||||
|
hash = 23 * hash + (color.isBlack() || manaCost.contains("{B}") ? 1 : 0);
|
||||||
|
hash = 23 * hash + (color.isRed() || manaCost.contains("{R}") ? 1 : 0);
|
||||||
|
hash = 23 * hash + (color.isGreen() || manaCost.contains("{G}") ? 1 : 0);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.util;
|
package mage.client.util;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
@ -39,7 +38,7 @@ public class CardViewCostComparator implements Comparator<CardView> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(CardView o1, CardView o2) {
|
public int compare(CardView o1, CardView o2) {
|
||||||
return Integer.valueOf(o1.getConvertedManaCost()).compareTo(Integer.valueOf(o2.getConvertedManaCost()));
|
return Integer.valueOf(o1.getConvertedManaCost()).compareTo(o2.getConvertedManaCost());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package mage.utils;
|
package mage.utils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import mage.ObjectColor;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
|
@ -13,6 +15,12 @@ import mage.view.CardView;
|
||||||
*/
|
*/
|
||||||
public class CardUtil {
|
public class CardUtil {
|
||||||
|
|
||||||
|
private static final String regexBlack = ".*\\x7b.{0,2}B.{0,2}\\x7d.*";
|
||||||
|
private static final String regexBlue = ".*\\x7b.{0,2}U.{0,2}\\x7d.*";
|
||||||
|
private static final String regexRed = ".*\\x7b.{0,2}R.{0,2}\\x7d.*";
|
||||||
|
private static final String regexGreen = ".*\\x7b.{0,2}G.{0,2}\\x7d.*";
|
||||||
|
private static final String regexWhite = ".*\\x7b.{0,2}W.{0,2}\\x7d.*";
|
||||||
|
|
||||||
public static boolean isCreature(CardView card) {
|
public static boolean isCreature(CardView card) {
|
||||||
return is(card, CardType.CREATURE);
|
return is(card, CardType.CREATURE);
|
||||||
}
|
}
|
||||||
|
|
@ -48,4 +56,34 @@ public class CardUtil {
|
||||||
public static boolean isLand(Card card) {
|
public static boolean isLand(Card card) {
|
||||||
return card.getCardType().contains(CardType.LAND);
|
return card.getCardType().contains(CardType.LAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getColorIdentitySortValue(List<String> manaCost, ObjectColor originalColor, List<String> rules) {
|
||||||
|
ObjectColor color = new ObjectColor(originalColor);
|
||||||
|
for (String rule : rules) {
|
||||||
|
rule = rule.replaceAll("(?i)<i.*?</i>", ""); // Ignoring reminder text in italic
|
||||||
|
if (rule.matches(regexBlack)) {
|
||||||
|
color.setBlack(true);
|
||||||
|
}
|
||||||
|
if (rule.matches(regexBlue)) {
|
||||||
|
color.setBlue(true);
|
||||||
|
}
|
||||||
|
if (rule.matches(regexGreen)) {
|
||||||
|
color.setGreen(true);
|
||||||
|
}
|
||||||
|
if (rule.matches(regexRed)) {
|
||||||
|
color.setRed(true);
|
||||||
|
}
|
||||||
|
if (rule.matches(regexWhite)) {
|
||||||
|
color.setWhite(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int hash = 3;
|
||||||
|
hash = 23 * hash + (color.isWhite() || manaCost.contains("{W}") ? 1 : 0);
|
||||||
|
hash = 23 * hash + (color.isBlue() || manaCost.contains("{U}") ? 1 : 0);
|
||||||
|
hash = 23 * hash + (color.isBlack() || manaCost.contains("{B}") ? 1 : 0);
|
||||||
|
hash = 23 * hash + (color.isRed() || manaCost.contains("{R}") ? 1 : 0);
|
||||||
|
hash = 23 * hash + (color.isGreen() || manaCost.contains("{G}") ? 1 : 0);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue