mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
AbilityUtils: applyTextChangeEffects: some fixes about textChange
now replacement does not try to replace what was already replaced. (in description with a strike) exclude the ChosenColor from Any (replace Blue to Blue doesn't make any sense) for Types does use PluralType, that does help to replace "Forests" with "Plains", but also fixed the Problem with replaceing Creature Types in Keywords which are written as Plural and should stay as such.
This commit is contained in:
@@ -1618,20 +1618,27 @@ public class AbilityUtils {
|
||||
for (final byte c : MagicColor.WUBRG) {
|
||||
final String colorLowerCase = MagicColor.toLongString(c).toLowerCase(),
|
||||
colorCaptCase = StringUtils.capitalize(MagicColor.toLongString(c));
|
||||
// Color should not replace itself.
|
||||
if (e.getValue().equalsIgnoreCase(colorLowerCase)) {
|
||||
continue;
|
||||
}
|
||||
value = getReplacedText(colorLowerCase, e.getValue(), isDescriptive);
|
||||
replaced = replaced.replace(colorLowerCase, value.toLowerCase());
|
||||
replaced = replaced.replaceAll("(?<!>)" + colorLowerCase, value.toLowerCase());
|
||||
value = getReplacedText(colorCaptCase, e.getValue(), isDescriptive);
|
||||
replaced = replaced.replace(colorCaptCase, StringUtils.capitalize(value));
|
||||
replaced = replaced.replaceAll("(?<!>)" + colorCaptCase, StringUtils.capitalize(value));
|
||||
}
|
||||
} else {
|
||||
value = getReplacedText(key, e.getValue(), isDescriptive);
|
||||
replaced = replaced.replace(key, value);
|
||||
replaced = replaced.replaceAll("(?<!>)" + key, value);
|
||||
}
|
||||
}
|
||||
for (final Entry<String, String> e : card.getChangedTextTypeWords().entrySet()) {
|
||||
final String key = e.getKey();
|
||||
final String pkey = CardUtil.getPluralType(key);
|
||||
final String pvalue = getReplacedText(pkey, CardUtil.getPluralType(e.getValue()), isDescriptive);
|
||||
replaced = replaced.replaceAll("(?<!>)" + pkey, pvalue);
|
||||
final String value = getReplacedText(key, e.getValue(), isDescriptive);
|
||||
replaced = replaced.replace(key, value);
|
||||
replaced = replaced.replaceAll("(?<!>)" + key, value);
|
||||
}
|
||||
return replaced;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user