mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
CardUtil.getColor(card) returns colorSet instead of strings collection
This commit is contained in:
@@ -43,6 +43,8 @@ import forge.CardPredicates.Presets;
|
|||||||
import forge.card.CardCharacteristics;
|
import forge.card.CardCharacteristics;
|
||||||
import forge.card.CardRarity;
|
import forge.card.CardRarity;
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
|
import forge.card.ColorSet;
|
||||||
|
import forge.card.MagicColor;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
@@ -5211,59 +5213,34 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
// ... Card colors
|
// ... Card colors
|
||||||
else if (property.contains("White") || property.contains("Blue") || property.contains("Black")
|
else if (property.contains("White") || property.contains("Blue") || property.contains("Black")
|
||||||
|| property.contains("Red") || property.contains("Green") || property.contains("Colorless")) {
|
|| property.contains("Red") || property.contains("Green") ) {
|
||||||
if (property.startsWith("non")) {
|
boolean mustHave = !property.startsWith("non");
|
||||||
if (CardUtil.getColors(this).contains(property.substring(3).toLowerCase())) {
|
int desiredColor = MagicColor.fromName(mustHave ? property : property.substring(3));
|
||||||
return false;
|
boolean hasColor = CardUtil.getColors(this).hasAnyColor(desiredColor);
|
||||||
}
|
if( mustHave != hasColor )
|
||||||
} else if (!CardUtil.getColors(this).contains(property.toLowerCase())) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
} else if (property.contains("MultiColor")) // ... Card is multicolored
|
} else if (property.contains("Colorless")) { // ... Card is colorless
|
||||||
{
|
if( property.startsWith("non") == CardUtil.getColors(this).isColorless() ) return false;
|
||||||
if (property.startsWith("non") && (CardUtil.getColors(this).size() > 1)) {
|
|
||||||
return false;
|
} else if (property.contains("MultiColor")) { // ... Card is multicolored
|
||||||
}
|
if( property.startsWith("non") == CardUtil.getColors(this).isMulticolor() ) return false;
|
||||||
if (!property.startsWith("non") && (CardUtil.getColors(this).size() <= 1)) {
|
|
||||||
return false;
|
} else if (property.contains("MonoColor")) { // ... Card is monocolored
|
||||||
}
|
if( property.startsWith("non") == CardUtil.getColors(this).isMonoColor() ) return false;
|
||||||
} else if (property.contains("MonoColor")) {
|
|
||||||
// ... Card is monocolored
|
|
||||||
if (property.startsWith("non") && ((CardUtil.getColors(this).size() == 1) && !this.isColorless())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!property.startsWith("non") && ((CardUtil.getColors(this).size() > 1) || this.isColorless())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (property.equals("ChosenColor")) {
|
} else if (property.equals("ChosenColor")) {
|
||||||
if (source.getChosenColor().size() == 0) {
|
if (source.getChosenColor().isEmpty() || !CardUtil.getColors(this).hasAnyColor(MagicColor.fromName(source.getChosenColor().get(0))))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
if (!CardUtil.getColors(this).contains(source.getChosenColor().get(0))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (property.equals("AllChosenColors")) {
|
} else if (property.equals("AllChosenColors")) {
|
||||||
if (source.getChosenColor().size() == 0) {
|
if ( source.getChosenColor().isEmpty() || !CardUtil.getColors(this).hasAllColors(ColorSet.fromNames(source.getChosenColor()).getColor()) )
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
for (String col : source.getChosenColor()) {
|
|
||||||
if (!CardUtil.getColors(this).contains(col)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (property.equals("AnyChosenColor")) {
|
} else if (property.equals("AnyChosenColor")) {
|
||||||
if (source.getChosenColor().size() == 0) {
|
if ( source.getChosenColor().isEmpty() || !CardUtil.getColors(this).hasAnyColor(ColorSet.fromNames(source.getChosenColor()).getColor()) )
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
int matched = 0;
|
|
||||||
for (String col : source.getChosenColor()) {
|
|
||||||
if (CardUtil.getColors(this).contains(col)) {
|
|
||||||
matched++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (matched == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (property.equals("DoubleFaced")) {
|
} else if (property.equals("DoubleFaced")) {
|
||||||
if (!this.isDoubleFaced()) {
|
if (!this.isDoubleFaced()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -5670,12 +5647,9 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (restriction.equals("MostProminentColor")) {
|
} else if (restriction.equals("MostProminentColor")) {
|
||||||
for (final String color : CardUtil.getColors(this)) {
|
byte mask = CardFactoryUtil.getMostProminentColors(getGame().getCardsIn(ZoneType.Battlefield));
|
||||||
if (CardFactoryUtil.isMostProminentColor(getGame().getCardsIn(ZoneType.Battlefield), color)) {
|
if( !CardUtil.getColors(this).hasAnyColor(mask))
|
||||||
return true;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else {
|
} else {
|
||||||
for (final Card card : sourceController.getCardsIn(ZoneType.Battlefield)) {
|
for (final Card card : sourceController.getCardsIn(ZoneType.Battlefield)) {
|
||||||
if (card.isValid(restriction, sourceController, source) && this.sharesColorWith(card)) {
|
if (card.isValid(restriction, sourceController, source) && this.sharesColorWith(card)) {
|
||||||
@@ -5695,7 +5669,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
String color = props[1];
|
String color = props[1];
|
||||||
|
|
||||||
return CardFactoryUtil.isMostProminentColor(getGame().getCardsIn(ZoneType.Battlefield), color);
|
byte mostProm = CardFactoryUtil.getMostProminentColors(getGame().getCardsIn(ZoneType.Battlefield));
|
||||||
|
return ColorSet.fromMask(mostProm).hasAnyColor(MagicColor.fromName(color));
|
||||||
} else if (property.startsWith("notSharesColorWith")) {
|
} else if (property.startsWith("notSharesColorWith")) {
|
||||||
if (property.equals("notSharesColorWith")) {
|
if (property.equals("notSharesColorWith")) {
|
||||||
if (this.sharesColorWith(source)) {
|
if (this.sharesColorWith(source)) {
|
||||||
@@ -6524,84 +6499,13 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
* part of the Card class, so calling out is not necessary
|
* part of the Card class, so calling out is not necessary
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
public final boolean isOfColor(final String col) { return CardUtil.getColors(this).hasAnyColor(MagicColor.fromName(col)); }
|
||||||
* <p>
|
public final boolean isBlack() { return CardUtil.getColors(this).hasBlack(); }
|
||||||
* isColor.
|
public final boolean isBlue() { return CardUtil.getColors(this).hasBlue(); }
|
||||||
* </p>
|
public final boolean isRed() { return CardUtil.getColors(this).hasRed(); }
|
||||||
*
|
public final boolean isGreen() { return CardUtil.getColors(this).hasGreen(); }
|
||||||
* @param col
|
public final boolean isWhite() { return CardUtil.getColors(this).hasWhite(); }
|
||||||
* a {@link java.lang.String} object.
|
public final boolean isColorless() { return CardUtil.getColors(this).isColorless(); }
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
public final boolean isColor(final String col) {
|
|
||||||
return CardUtil.getColors(this).contains(col);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* isBlack.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
public final boolean isBlack() {
|
|
||||||
return CardUtil.getColors(this).contains(Constant.Color.BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* isBlue.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
public final boolean isBlue() {
|
|
||||||
return CardUtil.getColors(this).contains(Constant.Color.BLUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* isRed.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
public final boolean isRed() {
|
|
||||||
return CardUtil.getColors(this).contains(Constant.Color.RED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* isGreen.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
public final boolean isGreen() {
|
|
||||||
return CardUtil.getColors(this).contains(Constant.Color.GREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* isWhite.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
public final boolean isWhite() {
|
|
||||||
return CardUtil.getColors(this).contains(Constant.Color.WHITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* isColorless.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
public final boolean isColorless() {
|
|
||||||
return CardUtil.getColors(this).contains(Constant.Color.COLORLESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import java.util.EnumSet;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import forge.card.ColorSet;
|
||||||
import forge.card.mana.ManaCostBeingPaid;
|
import forge.card.mana.ManaCostBeingPaid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -207,6 +208,14 @@ public class CardColor implements Iterable<Color> {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final ColorSet toColorSet() {
|
||||||
|
int mask = 0;
|
||||||
|
for (final Color c : this.col) {
|
||||||
|
mask |= c.getMagicColor();
|
||||||
|
}
|
||||||
|
return ColorSet.fromMask(mask);
|
||||||
|
}
|
||||||
|
|
||||||
public final List<String> toStringList() {
|
public final List<String> toStringList() {
|
||||||
final List<String> list = new ArrayList<String>(this.col.size());
|
final List<String> list = new ArrayList<String>(this.col.size());
|
||||||
|
|||||||
@@ -144,28 +144,6 @@ public class CardLists {
|
|||||||
} // sortAttack()
|
} // sortAttack()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getColor.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param list
|
|
||||||
* a {@link forge.CardList} object.
|
|
||||||
* @param color
|
|
||||||
* a {@link java.lang.String} object.
|
|
||||||
* @return a {@link forge.CardList} object.
|
|
||||||
*/
|
|
||||||
public static List<Card> getColor(final List<Card> list, final String color) {
|
|
||||||
return CardLists.filter(list, new Predicate<Card>() {
|
|
||||||
@Override
|
|
||||||
public boolean apply(final Card c) {
|
|
||||||
return CardUtil.getColors(c).contains(color);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} // getColor()
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Given a List<Card> c, return a List<Card> that contains a random amount of cards from c.
|
* Given a List<Card> c, return a List<Card> that contains a random amount of cards from c.
|
||||||
|
|||||||
@@ -153,7 +153,16 @@ public final class CardPredicates {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static final Predicate<Card> isColor(final byte color) {
|
||||||
|
return new Predicate<Card>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(final Card c) {
|
||||||
|
return CardUtil.getColors(c).hasAnyColor(color);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // getColor()
|
||||||
|
|
||||||
|
|
||||||
public static class Presets {
|
public static class Presets {
|
||||||
|
|
||||||
@@ -285,53 +294,6 @@ public final class CardPredicates {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* a Predicate<Card> to get all cards that are black.
|
|
||||||
*/
|
|
||||||
public static final Predicate<Card> BLACK = new Predicate<Card>() {
|
|
||||||
@Override
|
|
||||||
public boolean apply(Card c) {
|
|
||||||
return c.isBlack();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* a Predicate<Card> to get all cards that are blue.
|
|
||||||
*/
|
|
||||||
public static final Predicate<Card> BLUE = new Predicate<Card>() {
|
|
||||||
@Override
|
|
||||||
public boolean apply(Card c) {
|
|
||||||
return c.isBlue();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* a Predicate<Card> to get all cards that are green.
|
|
||||||
*/
|
|
||||||
public static final Predicate<Card> GREEN = new Predicate<Card>() {
|
|
||||||
@Override
|
|
||||||
public boolean apply(Card c) {
|
|
||||||
return c.isGreen();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* a Predicate<Card> to get all cards that are red.
|
|
||||||
*/
|
|
||||||
public static final Predicate<Card> RED = new Predicate<Card>() {
|
|
||||||
@Override
|
|
||||||
public boolean apply(Card c) {
|
|
||||||
return c.isRed();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* a Predicate<Card> to get all cards that are white.
|
|
||||||
*/
|
|
||||||
public static final Predicate<Card> WHITE = new Predicate<Card>() {
|
|
||||||
@Override
|
|
||||||
public boolean apply(Card c) {
|
|
||||||
return c.isWhite();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
public static final Predicate<Card> hasFirstStrike = new Predicate<Card>() {
|
public static final Predicate<Card> hasFirstStrike = new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Card c) {
|
public boolean apply(Card c) {
|
||||||
|
|||||||
@@ -18,12 +18,11 @@
|
|||||||
package forge;
|
package forge;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import forge.card.CardCharacteristics;
|
import forge.card.CardCharacteristics;
|
||||||
|
import forge.card.ColorSet;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
@@ -39,28 +38,8 @@ public final class CardUtil {
|
|||||||
// disable instantiation
|
// disable instantiation
|
||||||
private CardUtil() { }
|
private CardUtil() { }
|
||||||
|
|
||||||
static final Map<String, String> colorMap;
|
public static ColorSet getColors(final Card c) {
|
||||||
static {
|
return c.determineColor().toColorSet();
|
||||||
colorMap = new HashMap<String, String>();
|
|
||||||
colorMap.put(Constant.Color.BLACK.toString(), "B");
|
|
||||||
colorMap.put(Constant.Color.BLUE.toString(), "U");
|
|
||||||
colorMap.put(Constant.Color.GREEN.toString(), "G");
|
|
||||||
colorMap.put(Constant.Color.RED.toString(), "R");
|
|
||||||
colorMap.put(Constant.Color.WHITE.toString(), "W");
|
|
||||||
colorMap.put(Constant.Color.COLORLESS.toString(), "C");
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns "G", longColor is Constant.Color.Green and the like
|
|
||||||
public static String getShortColor(final String longColor) {
|
|
||||||
String color = longColor.toLowerCase();
|
|
||||||
if (!colorMap.containsKey(color)) {
|
|
||||||
throw new RuntimeException("CardUtil : getShortColor() invalid argument - " + longColor);
|
|
||||||
}
|
|
||||||
return colorMap.get(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getColors(final Card c) {
|
|
||||||
return c.determineColor().toStringList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isStackingKeyword(final String keyword) {
|
public static boolean isStackingKeyword(final String keyword) {
|
||||||
@@ -75,7 +54,7 @@ public final class CardUtil {
|
|||||||
public static String getShortColorsString(final Iterable<String> colors) {
|
public static String getShortColorsString(final Iterable<String> colors) {
|
||||||
StringBuilder colorDesc = new StringBuilder();
|
StringBuilder colorDesc = new StringBuilder();
|
||||||
for (final String col : colors) {
|
for (final String col : colors) {
|
||||||
colorDesc.append(getShortColor(col) + " ");
|
colorDesc.append(MagicColor.toShortString(col) + " ");
|
||||||
}
|
}
|
||||||
return colorDesc.toString();
|
return colorDesc.toString();
|
||||||
}
|
}
|
||||||
@@ -269,7 +248,7 @@ public final class CardUtil {
|
|||||||
for (final Card card1 : cards) {
|
for (final Card card1 : cards) {
|
||||||
// For each card, go through all the colors and if the card is that color, add
|
// For each card, go through all the colors and if the card is that color, add
|
||||||
for (final String col : Constant.Color.ONLY_COLORS) {
|
for (final String col : Constant.Color.ONLY_COLORS) {
|
||||||
if (card1.isColor(col)) {
|
if (card1.isOfColor(col)) {
|
||||||
colors.add(col);
|
colors.add(col);
|
||||||
if (colors.size() == maxChoices) {
|
if (colors.size() == maxChoices) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -36,35 +36,25 @@ import forge.card.mana.ManaCostBeingPaid;
|
|||||||
public enum Color {
|
public enum Color {
|
||||||
|
|
||||||
/** The Colorless. */
|
/** The Colorless. */
|
||||||
Colorless(0),
|
Colorless((byte)0),
|
||||||
/** The White. */
|
/** The White. */
|
||||||
White(1),
|
White(MagicColor.WHITE),
|
||||||
/** The Green. */
|
/** The Green. */
|
||||||
Green(2),
|
Green(MagicColor.GREEN),
|
||||||
/** The Red. */
|
/** The Red. */
|
||||||
Red(4),
|
Red(MagicColor.RED),
|
||||||
/** The Black. */
|
/** The Black. */
|
||||||
Black(8),
|
Black(MagicColor.BLACK),
|
||||||
/** The Blue. */
|
/** The Blue. */
|
||||||
Blue(16);
|
Blue(MagicColor.BLUE);
|
||||||
|
|
||||||
public static final ImmutableList<Color> WUBRG = ImmutableList.of( White, Blue, Black, Red, Green );
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
private final byte magicColor;
|
||||||
private int flag = 0;
|
private Color(final byte c) {
|
||||||
|
this.magicColor = c;
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Constructor for Color.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param c
|
|
||||||
* a int.
|
|
||||||
*/
|
|
||||||
Color(final int c) {
|
|
||||||
this.flag = c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final ImmutableList<Color> WUBRG = ImmutableList.of( White, Blue, Black, Red, Green );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Colorless.
|
* Colorless.
|
||||||
@@ -77,6 +67,10 @@ public enum Color {
|
|||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte getMagicColor() {
|
||||||
|
return magicColor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* ConvertStringsToColor.
|
* ConvertStringsToColor.
|
||||||
|
|||||||
@@ -74,6 +74,14 @@ public final class ColorSet implements Comparable<ColorSet> {
|
|||||||
return fromMask(mask);
|
return fromMask(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ColorSet fromNames(Iterable<String> colors) {
|
||||||
|
byte mask = 0;
|
||||||
|
for (String s : colors) {
|
||||||
|
mask |= MagicColor.fromName(s);
|
||||||
|
}
|
||||||
|
return fromMask(mask);
|
||||||
|
}
|
||||||
|
|
||||||
public static ColorSet fromManaCost(final ManaCost mana) {
|
public static ColorSet fromManaCost(final ManaCost mana) {
|
||||||
return fromMask(mana.getColorProfile());
|
return fromMask(mana.getColorProfile());
|
||||||
}
|
}
|
||||||
@@ -224,51 +232,6 @@ public final class ColorSet implements Comparable<ColorSet> {
|
|||||||
return this.hasAnyColor(MagicColor.GREEN);
|
return this.hasAnyColor(MagicColor.GREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if is white.
|
|
||||||
*
|
|
||||||
* @return true, if is white
|
|
||||||
*/
|
|
||||||
public boolean isWhite() {
|
|
||||||
return this.isEqual(MagicColor.WHITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if is blue.
|
|
||||||
*
|
|
||||||
* @return true, if is blue
|
|
||||||
*/
|
|
||||||
public boolean isBlue() {
|
|
||||||
return this.isEqual(MagicColor.BLUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if is black.
|
|
||||||
*
|
|
||||||
* @return true, if is black
|
|
||||||
*/
|
|
||||||
public boolean isBlack() {
|
|
||||||
return this.isEqual(MagicColor.BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if is red.
|
|
||||||
*
|
|
||||||
* @return true, if is red
|
|
||||||
*/
|
|
||||||
public boolean isRed() {
|
|
||||||
return this.isEqual(MagicColor.RED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if is green.
|
|
||||||
*
|
|
||||||
* @return true, if is green
|
|
||||||
*/
|
|
||||||
public boolean isGreen() {
|
|
||||||
return this.isEqual(MagicColor.GREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ColorSet inverse() {
|
public ColorSet inverse() {
|
||||||
byte mask = this.myColor;
|
byte mask = this.myColor;
|
||||||
mask ^= (MagicColor.WHITE | MagicColor.BLUE | MagicColor.BLACK | MagicColor.GREEN | MagicColor.RED);
|
mask ^= (MagicColor.WHITE | MagicColor.BLUE | MagicColor.BLACK | MagicColor.GREEN | MagicColor.RED);
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import forge.Card;
|
|||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
|
import forge.card.ColorSet;
|
||||||
|
import forge.card.MagicColor;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.SpellAbilityEffect;
|
import forge.card.ability.SpellAbilityEffect;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
@@ -63,8 +65,10 @@ public class ProtectAllEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
} else if (sa.getParam("Gains").equals("TargetedCardColor")) {
|
} else if (sa.getParam("Gains").equals("TargetedCardColor")) {
|
||||||
for (final Card c : sa.getSATargetingCard().getTarget().getTargetCards()) {
|
for (final Card c : sa.getSATargetingCard().getTarget().getTargetCards()) {
|
||||||
for(final String color : CardUtil.getColors(c)) {
|
ColorSet cs = CardUtil.getColors(c);
|
||||||
gains.add(color.toLowerCase());
|
for(byte col : MagicColor.WUBRG) {
|
||||||
|
if (cs.hasAnyColor(col))
|
||||||
|
gains.add(MagicColor.toLongString(col).toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@@ -41,6 +40,8 @@ import forge.Constant;
|
|||||||
import forge.CounterType;
|
import forge.CounterType;
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
|
import forge.card.ColorSet;
|
||||||
|
import forge.card.MagicColor;
|
||||||
import forge.card.ability.AbilityFactory;
|
import forge.card.ability.AbilityFactory;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
@@ -1427,7 +1428,7 @@ public class CardFactoryUtil {
|
|||||||
return Aggregates.sum(filteredCards, CardPredicates.Accessors.fnGetCmc);
|
return Aggregates.sum(filteredCards, CardPredicates.Accessors.fnGetCmc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sq[0].contains("CardNumColors")) return doXMath(CardUtil.getColors(c).size(), m, c);
|
if (sq[0].contains("CardNumColors")) return doXMath(CardUtil.getColors(c).countColors(), m, c);
|
||||||
if (sq[0].contains("ChosenNumber")) return doXMath(c.getChosenNumber(), m, c);
|
if (sq[0].contains("ChosenNumber")) return doXMath(c.getChosenNumber(), m, c);
|
||||||
if (sq[0].contains("CardCounters")) {
|
if (sq[0].contains("CardCounters")) {
|
||||||
// CardCounters.ALL to be used for Kinsbaile Borderguard and anything that cares about all counters
|
// CardCounters.ALL to be used for Kinsbaile Borderguard and anything that cares about all counters
|
||||||
@@ -1559,19 +1560,17 @@ public class CardFactoryUtil {
|
|||||||
|
|
||||||
// Count$ColoredCreatures *a DOMAIN for creatures*
|
// Count$ColoredCreatures *a DOMAIN for creatures*
|
||||||
if (sq[0].contains("ColoredCreatures")) {
|
if (sq[0].contains("ColoredCreatures")) {
|
||||||
int n = 0;
|
int mask = 0;
|
||||||
List<Card> someCards = CardLists.filter(cc.getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
List<Card> someCards = CardLists.filter(cc.getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
||||||
for (final String color : Constant.Color.ONLY_COLORS) {
|
for (final Card crd : someCards) {
|
||||||
if (!CardLists.getColor(someCards, color).isEmpty()) {
|
mask |= CardUtil.getColors(crd).getColor();
|
||||||
n++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return doXMath(n, m, c);
|
return doXMath(ColorSet.fromMask(mask).countColors(), m, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count$CardMulticolor.<numMC>.<numNotMC>
|
// Count$CardMulticolor.<numMC>.<numNotMC>
|
||||||
if (sq[0].contains("CardMulticolor")) {
|
if (sq[0].contains("CardMulticolor")) {
|
||||||
final boolean isMulti = CardUtil.getColors(c).size() > 1;
|
final boolean isMulti = CardUtil.getColors(c).isMulticolor();
|
||||||
return doXMath(Integer.parseInt(sq[isMulti ? 1 : 2]), m, c);
|
return doXMath(Integer.parseInt(sq[isMulti ? 1 : 2]), m, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1769,31 +1768,17 @@ public class CardFactoryUtil {
|
|||||||
// someCards = someCards.filter(CardListFilter.WHITE);
|
// someCards = someCards.filter(CardListFilter.WHITE);
|
||||||
// }
|
// }
|
||||||
// "White Creatures" - Count$WhiteTypeYouCtrl.Creature
|
// "White Creatures" - Count$WhiteTypeYouCtrl.Creature
|
||||||
if (sq[0].contains("White")) {
|
if (sq[0].contains("White")) someCards = CardLists.filter(someCards, CardPredicates.isColor(MagicColor.WHITE));
|
||||||
someCards = CardLists.filter(someCards, Presets.WHITE);
|
if (sq[0].contains("Blue")) someCards = CardLists.filter(someCards, CardPredicates.isColor(MagicColor.BLUE));
|
||||||
}
|
if (sq[0].contains("Black")) someCards = CardLists.filter(someCards, CardPredicates.isColor(MagicColor.BLACK));
|
||||||
|
if (sq[0].contains("Red")) someCards = CardLists.filter(someCards, CardPredicates.isColor(MagicColor.RED));
|
||||||
if (sq[0].contains("Blue")) {
|
if (sq[0].contains("Green")) someCards = CardLists.filter(someCards, CardPredicates.isColor(MagicColor.GREEN));
|
||||||
someCards = CardLists.filter(someCards, Presets.BLUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sq[0].contains("Black")) {
|
|
||||||
someCards = CardLists.filter(someCards, Presets.BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sq[0].contains("Red")) {
|
|
||||||
someCards = CardLists.filter(someCards, Presets.RED);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sq[0].contains("Green")) {
|
|
||||||
someCards = CardLists.filter(someCards, Presets.GREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sq[0].contains("Multicolor")) {
|
if (sq[0].contains("Multicolor")) {
|
||||||
someCards = CardLists.filter(someCards, new Predicate<Card>() {
|
someCards = CardLists.filter(someCards, new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(final Card c) {
|
public boolean apply(final Card c) {
|
||||||
return CardUtil.getColors(c).size() > 1;
|
return CardUtil.getColors(c).isMulticolor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1802,7 +1787,7 @@ public class CardFactoryUtil {
|
|||||||
someCards = CardLists.filter(someCards, new Predicate<Card>() {
|
someCards = CardLists.filter(someCards, new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(final Card c) {
|
public boolean apply(final Card c) {
|
||||||
return (CardUtil.getColors(c).size() == 1);
|
return CardUtil.getColors(c).isMonoColor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1929,36 +1914,30 @@ public class CardFactoryUtil {
|
|||||||
* a {@link forge.CardList} object.
|
* a {@link forge.CardList} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public static boolean isMostProminentColor(final List<Card> list, final String color) {
|
public static byte getMostProminentColors(final List<Card> list) {
|
||||||
|
int cntColors = MagicColor.WUBRG.length;
|
||||||
|
final Integer[] map = new Integer[cntColors];
|
||||||
|
|
||||||
final Map<String, Integer> map = new HashMap<String, Integer>();
|
for (final Card crd : list) {
|
||||||
|
ColorSet color = CardUtil.getColors(crd);
|
||||||
for (final Card c : list) {
|
for(int i = 0; i < cntColors; i++) {
|
||||||
for (final String color2 : CardUtil.getColors(c)) {
|
if( color.hasAnyColor(MagicColor.WUBRG[i]))
|
||||||
if (color2.equals("colorless")) {
|
map[i]++;
|
||||||
// nothing to do
|
|
||||||
} else if (!map.containsKey(color2)) {
|
|
||||||
map.put(color2, 1);
|
|
||||||
} else {
|
|
||||||
map.put(color2, map.get(color2) + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // for
|
} // for
|
||||||
|
|
||||||
if (map.isEmpty() || !map.containsKey(color)) {
|
byte mask = 0;
|
||||||
return false;
|
int nMax = -1;
|
||||||
|
for(int i = 0; i < cntColors; i++) {
|
||||||
|
if ( map[i] > nMax )
|
||||||
|
mask = MagicColor.WUBRG[i];
|
||||||
|
else if ( map[i] == nMax )
|
||||||
|
mask |= MagicColor.WUBRG[i];
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
nMax = map[i];
|
||||||
}
|
}
|
||||||
|
return mask;
|
||||||
int num = map.get(color);
|
|
||||||
|
|
||||||
for (final Entry<String, Integer> entry : map.entrySet()) {
|
|
||||||
|
|
||||||
if (num < entry.getValue()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ public abstract class GenerateColoredDeckBase {
|
|||||||
// start with all cards
|
// start with all cards
|
||||||
// remove cards that generated decks don't like
|
// remove cards that generated decks don't like
|
||||||
Predicate<CardRules> canPlay = pt == PlayerType.HUMAN ? GenerateDeckUtil.HUMAN_CAN_PLAY : GenerateDeckUtil.AI_CAN_PLAY;
|
Predicate<CardRules> canPlay = pt == PlayerType.HUMAN ? GenerateDeckUtil.HUMAN_CAN_PLAY : GenerateDeckUtil.AI_CAN_PLAY;
|
||||||
Predicate<CardRules> hasColor = new GenerateDeckUtil.CanBePaidWithColors(colors);
|
Predicate<CardRules> hasColor = new GenerateDeckUtil.MatchColorIdentity(colors);
|
||||||
|
|
||||||
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.DECKGEN_ARTIFACTS)) {
|
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.DECKGEN_ARTIFACTS)) {
|
||||||
hasColor = Predicates.or(hasColor, GenerateDeckUtil.COLORLESS_CARDS);
|
hasColor = Predicates.or(hasColor, GenerateDeckUtil.COLORLESS_CARDS);
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ public class GenerateDeckUtil {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static class CanBePaidWithColors implements Predicate<CardRules> {
|
public static class MatchColorIdentity implements Predicate<CardRules> {
|
||||||
private final ColorSet allowedColor;
|
private final ColorSet allowedColor;
|
||||||
|
|
||||||
public CanBePaidWithColors(ColorSet color) {
|
public MatchColorIdentity(ColorSet color) {
|
||||||
allowedColor = color;
|
allowedColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import com.esotericsoftware.minlog.Log;
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
@@ -18,9 +17,10 @@ import com.google.common.collect.Iterables;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardPredicates;
|
import forge.CardPredicates;
|
||||||
import forge.CardUtil;
|
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
|
import forge.card.MagicColor;
|
||||||
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.deck.CardPool;
|
import forge.deck.CardPool;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
@@ -814,35 +814,12 @@ public class ComputerUtilCard {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public static String getMostProminentColor(final List<Card> list) {
|
public static String getMostProminentColor(final List<Card> list) {
|
||||||
|
byte colors = CardFactoryUtil.getMostProminentColors(list);
|
||||||
final Map<String, Integer> map = new HashMap<String, Integer>();
|
for(byte c : MagicColor.WUBRG) {
|
||||||
|
if ( (colors & c) != 0 )
|
||||||
for (final Card c : list) {
|
return MagicColor.toLongString(c);
|
||||||
for (final String color : CardUtil.getColors(c)) {
|
|
||||||
if (color.equals("colorless")) {
|
|
||||||
// nothing to do
|
|
||||||
} else if (!map.containsKey(color)) {
|
|
||||||
map.put(color, 1);
|
|
||||||
} else {
|
|
||||||
map.put(color, map.get(color) + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // for
|
|
||||||
|
|
||||||
int max = 0;
|
|
||||||
String maxColor = "";
|
|
||||||
|
|
||||||
for (final Entry<String, Integer> entry : map.entrySet()) {
|
|
||||||
final String color = entry.getKey();
|
|
||||||
Log.debug(color + " - " + entry.getValue());
|
|
||||||
|
|
||||||
if (max < entry.getValue()) {
|
|
||||||
max = entry.getValue();
|
|
||||||
maxColor = color;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return Constant.Color.WHITE; // no difference, there was no prominent color
|
||||||
return maxColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getColorByProminence(final List<Card> list) {
|
public static List<String> getColorByProminence(final List<Card> list) {
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public class LimitedDeckBuilder {
|
|||||||
*/
|
*/
|
||||||
public Deck buildDeck() {
|
public Deck buildDeck() {
|
||||||
// 1. Prepare
|
// 1. Prepare
|
||||||
hasColor = Predicates.or(new GenerateDeckUtil.CanBePaidWithColors(colors), GenerateDeckUtil.COLORLESS_CARDS);
|
hasColor = Predicates.or(new GenerateDeckUtil.MatchColorIdentity(colors), GenerateDeckUtil.COLORLESS_CARDS);
|
||||||
colorList = Iterables.filter(aiPlayables, Predicates.compose(hasColor, CardPrinted.FN_GET_RULES));
|
colorList = Iterables.filter(aiPlayables, Predicates.compose(hasColor, CardPrinted.FN_GET_RULES));
|
||||||
onColorCreatures = Iterables.filter(colorList,
|
onColorCreatures = Iterables.filter(colorList,
|
||||||
Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, CardPrinted.FN_GET_RULES));
|
Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, CardPrinted.FN_GET_RULES));
|
||||||
@@ -431,13 +431,13 @@ public class LimitedDeckBuilder {
|
|||||||
for (Pair<Double, CardPrinted> bean : ranked) {
|
for (Pair<Double, CardPrinted> bean : ranked) {
|
||||||
// Want a card that has just one "off" color.
|
// Want a card that has just one "off" color.
|
||||||
ColorSet off = colors.getOffColors(bean.getValue().getRules().getColor());
|
ColorSet off = colors.getOffColors(bean.getValue().getRules().getColor());
|
||||||
if (off.isWhite() || off.isBlue() || off.isBlack() || off.isRed() || off.isGreen()) {
|
if (off.isMonoColor()) {
|
||||||
colors = ColorSet.fromMask(colors.getColor() | off.getColor());
|
colors = ColorSet.fromMask(colors.getColor() | off.getColor());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hasColor = Predicates.or(new GenerateDeckUtil.CanBePaidWithColors(colors),
|
hasColor = Predicates.or(new GenerateDeckUtil.MatchColorIdentity(colors),
|
||||||
GenerateDeckUtil.COLORLESS_CARDS);
|
GenerateDeckUtil.COLORLESS_CARDS);
|
||||||
Iterable<CardPrinted> threeColorList = Iterables.filter(aiPlayables,
|
Iterable<CardPrinted> threeColorList = Iterables.filter(aiPlayables,
|
||||||
Predicates.compose(hasColor, CardPrinted.FN_GET_RULES));
|
Predicates.compose(hasColor, CardPrinted.FN_GET_RULES));
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
|
|
||||||
import com.esotericsoftware.minlog.Log;
|
import com.esotericsoftware.minlog.Log;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
@@ -36,6 +37,7 @@ import forge.Constant;
|
|||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
|
import forge.card.MagicColor;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
@@ -941,10 +943,8 @@ public class CombatUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (keyword.equals("CARDNAME can't attack unless defending player controls a blue permanent.")) {
|
} else if (keyword.equals("CARDNAME can't attack unless defending player controls a blue permanent.")) {
|
||||||
temp = CardLists.getColor(list, Constant.Color.BLUE);
|
if (!Iterables.any(list, CardPredicates.isColor(MagicColor.BLUE)))
|
||||||
if (temp.isEmpty()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,12 +36,12 @@ import forge.Card;
|
|||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardPredicates;
|
import forge.CardPredicates;
|
||||||
import forge.CardPredicates.Presets;
|
import forge.CardPredicates.Presets;
|
||||||
import forge.CardUtil;
|
|
||||||
import forge.Constant.Preferences;
|
import forge.Constant.Preferences;
|
||||||
import forge.CounterType;
|
import forge.CounterType;
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
|
import forge.card.MagicColor;
|
||||||
import forge.card.ability.AbilityFactory;
|
import forge.card.ability.AbilityFactory;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
@@ -2800,12 +2800,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Card> getColoredCardsInPlay(final String color) {
|
public List<Card> getColoredCardsInPlay(final String color) {
|
||||||
return CardLists.filter(getCardsIn(ZoneType.Battlefield), new Predicate<Card>() {
|
return CardLists.filter(getCardsIn(ZoneType.Battlefield), CardPredicates.isColor(MagicColor.fromName(color)));
|
||||||
@Override
|
|
||||||
public boolean apply(final Card c) {
|
|
||||||
return CardUtil.getColors(c).contains(color);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCounterDoublersMagnitude(final CounterType type) {
|
public int getCounterDoublersMagnitude(final CounterType type) {
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ import forge.CardCharacteristicName;
|
|||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardPredicates;
|
import forge.CardPredicates;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.Constant;
|
|
||||||
import forge.CounterType;
|
import forge.CounterType;
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
|
import forge.card.ColorSet;
|
||||||
import forge.card.spellability.AbilityManaPart;
|
import forge.card.spellability.AbilityManaPart;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.card.trigger.TriggerType;
|
import forge.card.trigger.TriggerType;
|
||||||
@@ -71,23 +71,23 @@ public final class GuiDisplayUtil {
|
|||||||
return BorderFactory.createEmptyBorder(2, 2, 2, 2);
|
return BorderFactory.createEmptyBorder(2, 2, 2, 2);
|
||||||
}
|
}
|
||||||
java.awt.Color color;
|
java.awt.Color color;
|
||||||
final List<String> list = CardUtil.getColors(card);
|
final ColorSet list = CardUtil.getColors(card);
|
||||||
|
|
||||||
if (card.isFaceDown()) {
|
if (card.isFaceDown()) {
|
||||||
color = Color.gray;
|
color = Color.gray;
|
||||||
} else if (list.size() > 1) {
|
} else if (list.isMulticolor()) {
|
||||||
color = Color.orange;
|
color = Color.orange;
|
||||||
} else if (list.get(0).equals(Constant.Color.BLACK)) {
|
} else if (list.hasBlack()) {
|
||||||
color = Color.black;
|
color = Color.black;
|
||||||
} else if (list.get(0).equals(Constant.Color.GREEN)) {
|
} else if (list.hasGreen()) {
|
||||||
color = new Color(0, 220, 39);
|
color = new Color(0, 220, 39);
|
||||||
} else if (list.get(0).equals(Constant.Color.WHITE)) {
|
} else if (list.hasWhite()) {
|
||||||
color = Color.white;
|
color = Color.white;
|
||||||
} else if (list.get(0).equals(Constant.Color.RED)) {
|
} else if (list.hasRed()) {
|
||||||
color = Color.red;
|
color = Color.red;
|
||||||
} else if (list.get(0).equals(Constant.Color.BLUE)) {
|
} else if (list.hasBlue()) {
|
||||||
color = Color.blue;
|
color = Color.blue;
|
||||||
} else if (list.get(0).equals(Constant.Color.COLORLESS)) {
|
} else if (list.isColorless()) {
|
||||||
color = Color.gray;
|
color = Color.gray;
|
||||||
} else {
|
} else {
|
||||||
color = new Color(200, 0, 230); // If your card has a violet border,
|
color = new Color(200, 0, 230); // If your card has a violet border,
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ public enum VStack implements IVDoc<CStack> {
|
|||||||
private Color[] getSpellColor(SpellAbilityStackInstance s0) {
|
private Color[] getSpellColor(SpellAbilityStackInstance s0) {
|
||||||
if (s0.getStackDescription().startsWith("Morph "))
|
if (s0.getStackDescription().startsWith("Morph "))
|
||||||
return new Color[] { new Color(0, 0, 0, 0), FSkin.getColor(FSkin.Colors.CLR_TEXT) };
|
return new Color[] { new Color(0, 0, 0, 0), FSkin.getColor(FSkin.Colors.CLR_TEXT) };
|
||||||
if (CardUtil.getColors(s0.getSourceCard()).size() > 1)
|
if (CardUtil.getColors(s0.getSourceCard()).isMulticolor())
|
||||||
return new Color[] { new Color(253, 175, 63), Color.black };
|
return new Color[] { new Color(253, 175, 63), Color.black };
|
||||||
|
|
||||||
if (s0.getSourceCard().isBlack()) return new Color[] { Color.black, Color.white };
|
if (s0.getSourceCard().isBlack()) return new Color[] { Color.black, Color.white };
|
||||||
|
|||||||
Reference in New Issue
Block a user