[CMM] Implement Desecrate Reality (#10684)

This commit is contained in:
Susucre 2023-07-29 01:33:08 +02:00 committed by GitHub
parent d205981516
commit a8bba53adf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 155 additions and 6 deletions

View file

@ -19,22 +19,33 @@ public enum AdamantCondition implements Condition {
BLACK(ColoredManaSymbol.B),
RED(ColoredManaSymbol.R),
GREEN(ColoredManaSymbol.G),
COLORLESS(null, true),
ANY(null);
private final ColoredManaSymbol coloredManaSymbol;
private final boolean colorless;
private AdamantCondition(ColoredManaSymbol coloredManaSymbol) {
this(coloredManaSymbol, false);
}
private AdamantCondition(ColoredManaSymbol coloredManaSymbol, boolean colorless) {
this.coloredManaSymbol = coloredManaSymbol;
this.colorless = colorless;
}
@Override
public boolean apply(Game game, Ability source) {
if (source.getAbilityType() == AbilityType.SPELL) {
if (colorless) {
return source.getManaCostsToPay().getUsedManaToPay().getColorless() > 2;
}
if (coloredManaSymbol == null) {
return Arrays
.stream(ColoredManaSymbol.values())
.map(source.getManaCostsToPay().getUsedManaToPay()::getColor)
.anyMatch(i -> i > 2);
.stream(ColoredManaSymbol.values())
.map(source.getManaCostsToPay().getUsedManaToPay()::getColor)
.anyMatch(i -> i > 2);
}
return source.getManaCostsToPay().getUsedManaToPay().getColor(coloredManaSymbol) > 2;
}
@ -46,11 +57,14 @@ public enum AdamantCondition implements Condition {
if (payment == null) {
return false;
}
if (colorless) {
return payment.getColorless() > 2;
}
if (coloredManaSymbol == null) {
return Arrays
.stream(ColoredManaSymbol.values())
.map(payment::getColor)
.anyMatch(i -> i > 2);
.stream(ColoredManaSymbol.values())
.map(payment::getColor)
.anyMatch(i -> i > 2);
}
return payment.getColor(coloredManaSymbol) > 2;
}