diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java b/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java index a75c12fe634..353acd6de0f 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java @@ -1203,7 +1203,7 @@ public class ModernCardRenderer extends CardRenderer { protected static Paint getTextboxPaint(ObjectColor colors, Collection types, int width) { if (colors.isMulticolored()) { if (colors.getColorCount() == 2) { - List twoColors = colors.getColors(); + List twoColors = colors.getTwoColorsInOrder(); Color[] translatedColors; if (types.contains(CardType.LAND)) { translatedColors = new Color[]{ diff --git a/Mage/src/main/java/mage/ObjectColor.java b/Mage/src/main/java/mage/ObjectColor.java index 8bb44e9d7e0..39e657f65cb 100644 --- a/Mage/src/main/java/mage/ObjectColor.java +++ b/Mage/src/main/java/mage/ObjectColor.java @@ -175,6 +175,83 @@ public class ObjectColor implements Serializable, Copyable, Compara } return colors; } + + private int getColorIndex(int current, int potentialNext, boolean wantMinimum) { + if (current == -1) { + return potentialNext; + } + if ((current < potentialNext) && wantMinimum) { + return current; + } + if ((current < potentialNext) && !wantMinimum) { + return potentialNext; + } + return current; + } + + public List getTwoColorsInOrder() { + List colors = new ArrayList<>(); + int firstColor = -1; + int secondColor = -1; + if (this.isWhite()) { + firstColor = getColorIndex(firstColor, 1, true); + secondColor = getColorIndex(secondColor, 1, false); + } + if (this.isBlue()) { + firstColor = getColorIndex(firstColor, 2, true); + secondColor = getColorIndex(secondColor, 2, false); + } + if (this.isBlack()) { + firstColor = getColorIndex(firstColor, 3, true); + secondColor = getColorIndex(secondColor, 3, false); + } + if (this.isRed()) { + firstColor = getColorIndex(firstColor, 4, true); + secondColor = getColorIndex(secondColor, 4, false); + } + if (this.isGreen()) { + firstColor = getColorIndex(firstColor, 5, true); + secondColor = getColorIndex(secondColor, 5, false); + } + if (secondColor - firstColor <= 2) { + if (this.isWhite()) { + colors.add(ObjectColor.WHITE); + } + if (this.isBlue()) { + colors.add(ObjectColor.BLUE); + } + if (this.isBlack()) { + colors.add(ObjectColor.BLACK); + } + if (this.isRed()) { + colors.add(ObjectColor.RED); + } + if (this.isGreen()) { + colors.add(ObjectColor.GREEN); + } + } else if (secondColor - firstColor >= 3) { + if (this.isGreen()) { + colors.add(ObjectColor.GREEN); + } + if (this.isRed()) { + colors.add(ObjectColor.RED); + } + if (this.isBlack()) { + colors.add(ObjectColor.BLACK); + } + if (this.isBlue()) { + colors.add(ObjectColor.BLUE); + } + if (this.isWhite()) { + colors.add(ObjectColor.WHITE); + } + } + + if (this.isGold()) { + colors.add(ObjectColor.GOLD); + } + return colors; + } public void setColor(ObjectColor color) { this.setBlack(color.isBlack());