diff --git a/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java b/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java index 4115b9c9f5..418b3e0eaa 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java @@ -13,8 +13,6 @@ import mage.game.Game; import mage.players.Player; import mage.util.CardUtil; -import java.util.Locale; - public class DoIfCostPaid extends OneShotEffect { protected Effects executingEffects = new Effects(); @@ -164,16 +162,7 @@ public class DoIfCostPaid extends OneShotEffect { protected String getCostText() { StringBuilder sb = new StringBuilder(); String costText = cost.getText(); - if (costText != null - && !costText.toLowerCase(Locale.ENGLISH).startsWith("put") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("return") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("exile") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("discard") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("sacrifice") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("remove") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("tap") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("reveal") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("pay")) { + if (!CardUtil.checkCostWords(costText)) { sb.append("pay "); } return sb.append(costText).toString(); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DoWhenCostPaid.java b/Mage/src/main/java/mage/abilities/effects/common/DoWhenCostPaid.java index d5bec143b6..b07db7a53c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoWhenCostPaid.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoWhenCostPaid.java @@ -11,8 +11,6 @@ import mage.game.Game; import mage.players.Player; import mage.util.CardUtil; -import java.util.Locale; - public class DoWhenCostPaid extends OneShotEffect { private final ReflexiveTriggeredAbility ability; @@ -80,16 +78,7 @@ public class DoWhenCostPaid extends OneShotEffect { private String getCostText() { StringBuilder sb = new StringBuilder(); String costText = cost.getText(); - if (costText != null - && !costText.toLowerCase(Locale.ENGLISH).startsWith("put") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("return") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("exile") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("discard") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("sacrifice") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("remove") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("tap") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("reveal") - && !costText.toLowerCase(Locale.ENGLISH).startsWith("pay")) { + if (!CardUtil.checkCostWords(costText)) { sb.append("pay "); } return sb.append(costText).toString(); diff --git a/Mage/src/main/java/mage/abilities/effects/common/SacrificeSourceUnlessPaysEffect.java b/Mage/src/main/java/mage/abilities/effects/common/SacrificeSourceUnlessPaysEffect.java index fe679cd2c8..1ac7974e8a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/SacrificeSourceUnlessPaysEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/SacrificeSourceUnlessPaysEffect.java @@ -11,6 +11,7 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; +import mage.util.CardUtil; import mage.util.ManaUtil; import java.util.Locale; @@ -96,12 +97,7 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect { StringBuilder sb = new StringBuilder("sacrifice {this} unless you "); String costText = cost != null ? cost.getText() : "{X}"; - if (costText.toLowerCase(Locale.ENGLISH).startsWith("discard") - || costText.toLowerCase(Locale.ENGLISH).startsWith("remove") - || costText.toLowerCase(Locale.ENGLISH).startsWith("return") - || costText.toLowerCase(Locale.ENGLISH).startsWith("put") - || costText.toLowerCase(Locale.ENGLISH).startsWith("exile") - || costText.toLowerCase(Locale.ENGLISH).startsWith("sacrifice")) { + if (CardUtil.checkCostWords(costText)) { sb.append(costText.substring(0, 1).toLowerCase(Locale.ENGLISH)); sb.append(costText.substring(1)); } else { diff --git a/Mage/src/main/java/mage/util/CardUtil.java b/Mage/src/main/java/mage/util/CardUtil.java index 6325dbce46..539b224134 100644 --- a/Mage/src/main/java/mage/util/CardUtil.java +++ b/Mage/src/main/java/mage/util/CardUtil.java @@ -60,6 +60,10 @@ public final class CardUtil { public static final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS"); + private static final List costWords = Arrays.asList( + "put", "return", "exile", "discard", "sacrifice", "remove", "tap", "reveal", "pay" + ); + /** * Increase spell or ability cost to be paid. * @@ -1169,4 +1173,8 @@ public final class CardUtil { } return zcc; } + + public static boolean checkCostWords(String text) { + return text != null && costWords.stream().anyMatch(text.toLowerCase(Locale.ENGLISH)::startsWith); + } }