diff --git a/Mage/src/main/java/mage/abilities/costs/AlternativeCostImpl.java b/Mage/src/main/java/mage/abilities/costs/AlternativeCostImpl.java index bfbb86d893b..577083d2aec 100644 --- a/Mage/src/main/java/mage/abilities/costs/AlternativeCostImpl.java +++ b/Mage/src/main/java/mage/abilities/costs/AlternativeCostImpl.java @@ -12,7 +12,7 @@ import mage.game.Game; public class AlternativeCostImpl> extends CostsImpl implements AlternativeCost { protected String name; - protected String reminderText; + protected final String reminderText; protected boolean isMana; protected boolean activated; @@ -21,9 +21,7 @@ public class AlternativeCostImpl> extends Costs this.activated = false; this.name = name; this.isMana = cost instanceof ManaCost; - if (reminderText != null) { - this.reminderText = "(" + reminderText + ")"; - } + this.reminderText = reminderText; this.add(cost); } @@ -63,11 +61,10 @@ public class AlternativeCostImpl> extends Costs */ @Override public String getReminderText() { - String replace = ""; if (reminderText != null && !reminderText.isEmpty()) { - replace = reminderText.replace("{cost}", this.getText(true)); + return "(" + reminderText.replace("{cost}", this.getText(true)) + ")"; } - return replace; + return ""; } /** diff --git a/Mage/src/main/java/mage/abilities/costs/AlternativeCostSourceAbility.java b/Mage/src/main/java/mage/abilities/costs/AlternativeCostSourceAbility.java index c76f40b12ae..ad40cf39052 100644 --- a/Mage/src/main/java/mage/abilities/costs/AlternativeCostSourceAbility.java +++ b/Mage/src/main/java/mage/abilities/costs/AlternativeCostSourceAbility.java @@ -16,6 +16,7 @@ import mage.util.CardUtil; import java.util.Iterator; import java.util.UUID; +import java.util.stream.Collectors; /** * @author LevelX2 @@ -250,23 +251,13 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter } int numberCosts = 0; String remarkText = ""; - for (AlternativeCost alternativeCost : alternateCosts) { - if (numberCosts == 0) { - if (alternativeCost.getCost() instanceof ManaCost) { - sb.append("pay "); - } - sb.append(alternativeCost.getText(false)); - remarkText = alternativeCost.getReminderText(); - } else { - sb.append(" and "); - if (alternativeCost.getCost() instanceof ManaCost) { - sb.append("pay "); - } - String text = alternativeCost.getText(true); - sb.append(Character.toLowerCase(text.charAt(0))).append(text.substring(1)); - } - ++numberCosts; - } + sb.append(CardUtil.concatWithAnd(alternateCosts + .stream() + .map(cost -> cost.getCost() instanceof ManaCost + ? "pay " + cost.getText(true) + : cost.getText(true)) + .map(CardUtil::getTextWithFirstCharLowerCase) + .collect(Collectors.toList()))); if (condition == null || alternateCosts.size() == 1) { sb.append(" rather than pay this spell's mana cost"); } else if (alternateCosts.isEmpty()) {