Fix M15 colors for GW (was WG), GU (was UG), RW (was WR)

This commit is contained in:
spjspj 2018-01-19 20:30:12 +11:00
parent 990f75ac9d
commit af48b17451
2 changed files with 78 additions and 1 deletions

View file

@ -1203,7 +1203,7 @@ public class ModernCardRenderer extends CardRenderer {
protected static Paint getTextboxPaint(ObjectColor colors, Collection<CardType> types, int width) {
if (colors.isMulticolored()) {
if (colors.getColorCount() == 2) {
List<ObjectColor> twoColors = colors.getColors();
List<ObjectColor> twoColors = colors.getTwoColorsInOrder();
Color[] translatedColors;
if (types.contains(CardType.LAND)) {
translatedColors = new Color[]{

View file

@ -175,6 +175,83 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, 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<ObjectColor> getTwoColorsInOrder() {
List<ObjectColor> 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());