GUI: added mana and other symbols support in choose spell dialog (closes #12155)

This commit is contained in:
Oleg Agafonov 2024-07-27 10:17:22 +04:00
parent 521a0f6e32
commit 2bf6e3e3a2
7 changed files with 26 additions and 36 deletions

View file

@ -6,6 +6,7 @@ import mage.abilities.effects.Effect;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.util.CardUtil;
import java.util.Locale;
@ -53,7 +54,7 @@ public class ReflexiveTriggeredAbility extends DelayedTriggeredAbility {
if (text == null) {
return super.getRule();
}
return text.substring(0, 1).toUpperCase(Locale.ENGLISH) + text.substring(1) + '.';
return CardUtil.getTextWithFirstCharUpperCase(text) + '.';
}
@Override

View file

@ -15,6 +15,7 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.players.Player;
import mage.util.CardUtil;
/**
* @author LevelX2
@ -47,7 +48,7 @@ public class EnterBattlefieldPayCostOrPutGraveyardEffect extends ReplacementEffe
boolean replace = true;
if (cost.canPay(source, source, player.getId(), game)) {
if (player.chooseUse(outcome,
cost.getText().substring(0, 1).toUpperCase(Locale.ENGLISH) + cost.getText().substring(1)
CardUtil.getTextWithFirstCharUpperCase(cost.getText())
+ "? (otherwise " + sourceObject.getLogName() + " is put into graveyard)", source, game)) {
cost.clearPaid();
replace = !cost.pay(source, game, source, source.getControllerId(), false, null);

View file

@ -62,7 +62,7 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
message += "Pay " + costValueMessage;
logMessage += "pay " + costValueMessage;
} else if (costValueMessage.length() > 1) {
message += costValueMessage.substring(0, 1).toUpperCase() + costValueMessage.substring(1);
message += CardUtil.getTextWithFirstCharUpperCase(costValueMessage);
logMessage += costValueMessage;
}
message += '?';

View file

@ -65,7 +65,7 @@ public class AddCounterChoiceSourceEffect extends OneShotEffect {
counterChoice.setChoices(
this.counterTypes
.stream()
.map(counterType -> AddCounterChoiceSourceEffect.capitalize(counterType.getName()))
.map(counterType -> CardUtil.getTextWithFirstCharUpperCase(counterType.getName()))
.collect(Collectors.toSet())
);
@ -82,10 +82,6 @@ public class AddCounterChoiceSourceEffect extends OneShotEffect {
return permanent.addCounters(counter, source.getControllerId(), source, game);
}
private static String capitalize(String string) {
return string != null ? string.substring(0, 1).toUpperCase(Locale.ENGLISH) + string.substring(1) : null;
}
@Override
public AddCounterChoiceSourceEffect copy() {
return new AddCounterChoiceSourceEffect(this);

View file

@ -983,7 +983,7 @@ public final class CardUtil {
}
public static String getTextWithFirstCharUpperCase(String text) {
if (text != null && text.length() >= 1) {
if (text != null && !text.isEmpty()) {
return Character.toUpperCase(text.charAt(0)) + text.substring(1);
} else {
return text;
@ -991,7 +991,7 @@ public final class CardUtil {
}
public static String getTextWithFirstCharLowerCase(String text) {
if (text != null && text.length() >= 1) {
if (text != null && !text.isEmpty()) {
return Character.toLowerCase(text.charAt(0)) + text.substring(1);
} else {
return text;