mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 11:02:00 -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
|
|
@ -1,5 +1,7 @@
|
|||
package mage.utils;
|
||||
|
||||
import java.util.List;
|
||||
import mage.ObjectColor;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.MagePermanent;
|
||||
import mage.constants.CardType;
|
||||
|
|
@ -13,6 +15,12 @@ import mage.view.CardView;
|
|||
*/
|
||||
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) {
|
||||
return is(card, CardType.CREATURE);
|
||||
}
|
||||
|
|
@ -48,4 +56,34 @@ public class CardUtil {
|
|||
public static boolean isLand(Card card) {
|
||||
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