ColorSet: add combine function (#8960)

This commit is contained in:
Hans Mackowiak
2025-10-20 09:45:57 +02:00
committed by GitHub
parent a8d494d2d8
commit 5efd7e6e7c
16 changed files with 49 additions and 39 deletions

View File

@@ -235,7 +235,7 @@ public final class CardRules implements ICardCharacteristics {
public ColorSet getColor() {
switch (splitType.getAggregationMethod()) {
case COMBINE:
return ColorSet.fromMask(mainPart.getColor().getColor() | otherPart.getColor().getColor());
return ColorSet.combine(mainPart.getColor(), otherPart.getColor());
default:
return mainPart.getColor();
}

View File

@@ -123,6 +123,14 @@ public enum ColorSet implements Iterable<Color>, Serializable {
return fromMask(mana.getColorProfile());
}
public static ColorSet combine(final ColorSet... colors) {
byte mask = 0;
for (ColorSet c : colors) {
mask |= c.getColor();
}
return fromMask(mask);
}
/**
* Checks for any color.
*