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:
LevelX2 2015-09-21 08:11:58 +02:00
parent d0a6ae09b4
commit 9ab323a89c
2 changed files with 4 additions and 14 deletions

View file

@ -28,8 +28,7 @@
package mage.client.util;
import java.util.Comparator;
import java.util.List;
import mage.ObjectColor;
import mage.utils.CardUtil;
import mage.view.CardView;
/**
@ -40,16 +39,7 @@ public class CardViewColorIdentityComparator implements Comparator<CardView> {
@Override
public int compare(CardView o1, CardView o2) {
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;
return CardUtil.getColorIdentitySortValue(o1.getManaCost(), o1.getColor(), o1.getRules())
- CardUtil.getColorIdentitySortValue(o2.getManaCost(), o2.getColor(), o2.getRules());
}
}

View file

@ -63,7 +63,7 @@ public enum CardRepository {
// raise this if db structure was changed
private static final long CARD_DB_VERSION = 41;
// raise this if new cards were added to the server
private static final long CARD_CONTENT_VERSION = 37;
private static final long CARD_CONTENT_VERSION = 38;
private final Random random = new Random();
private Dao<CardInfo, Object> cardDao;