forked from External/mage
more refactoring of ConditionalInterveningIfTriggeredAbility
This commit is contained in:
parent
a35b6efb87
commit
c24627f175
29 changed files with 188 additions and 296 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.condition;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -7,16 +6,22 @@ import mage.game.Game;
|
|||
/**
|
||||
* A simple {@link Condition} to invert a decorated conditions
|
||||
* {@link Condition#apply(mage.game.Game, mage.abilities.Ability) apply(mage.game.Game, mage.abilities.Ability)}
|
||||
* method invocation.
|
||||
*
|
||||
* method invocation.
|
||||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
public class InvertCondition implements Condition {
|
||||
|
||||
private final Condition condition;
|
||||
private final String message;
|
||||
|
||||
public InvertCondition ( Condition condition ) {
|
||||
public InvertCondition(Condition condition) {
|
||||
this(condition, null);
|
||||
}
|
||||
|
||||
public InvertCondition(Condition condition, String message) {
|
||||
this.condition = condition;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -29,7 +34,10 @@ public class InvertCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (message != null && !message.isEmpty()) {
|
||||
return message;
|
||||
}
|
||||
return condition.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ public enum AdamantCondition implements Condition {
|
|||
private final boolean colorless;
|
||||
|
||||
|
||||
private AdamantCondition(ColoredManaSymbol coloredManaSymbol) {
|
||||
AdamantCondition(ColoredManaSymbol coloredManaSymbol) {
|
||||
this(coloredManaSymbol, false);
|
||||
}
|
||||
|
||||
private AdamantCondition(ColoredManaSymbol coloredManaSymbol, boolean colorless) {
|
||||
AdamantCondition(ColoredManaSymbol coloredManaSymbol, boolean colorless) {
|
||||
this.coloredManaSymbol = coloredManaSymbol;
|
||||
this.colorless = colorless;
|
||||
}
|
||||
|
|
@ -44,9 +44,9 @@ public enum AdamantCondition implements Condition {
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
|
@ -63,9 +63,9 @@ public enum AdamantCondition implements Condition {
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
|
@ -74,4 +74,17 @@ public enum AdamantCondition implements Condition {
|
|||
public boolean caresAboutManaColor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("at least three ");
|
||||
if (coloredManaSymbol == null && !colorless) {
|
||||
sb.append("mana of the same color");
|
||||
} else {
|
||||
sb.append(coloredManaSymbol != null ? coloredManaSymbol.getColorName() : "colorless");
|
||||
sb.append(" mana");
|
||||
}
|
||||
sb.append(" was spent to cast it");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,6 @@ public class YouGainedLifeCondition extends IntCompareCondition {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "if you gained " + (value == 0 ? "" : (value + 1) + " or more ") + "life this turn";
|
||||
return "you gained " + (value == 0 ? "" : (value + 1) + " or more ") + "life this turn";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue