SpellAbilityEffect > tokenizeString add {n: SVar parser

This commit is contained in:
Northmoc
2022-04-15 22:45:34 -04:00
parent c0d9dbff57
commit ebce6349ce

View File

@@ -165,18 +165,23 @@ public abstract class SpellAbilityEffect {
if ("}".equals(t)) { isPlainText = true; continue; }
if (!isPlainText) {
final List<? extends GameObject> objs;
if (t.startsWith("p:")) {
objs = AbilityUtils.getDefinedPlayers(sa.getHostCard(), t.substring(2), sa);
} else if (t.startsWith("s:")) {
objs = AbilityUtils.getDefinedSpellAbilities(sa.getHostCard(), t.substring(2), sa);
} else if (t.startsWith("c:")) {
objs = AbilityUtils.getDefinedCards(sa.getHostCard(), t.substring(2), sa);
if (t.startsWith("n:")) { // {n:<SVar> <noun(opt.)>}
String parts[] = t.substring(2).split(" ", 2);
int n = AbilityUtils.calculateAmount(sa.getHostCard(), parts[0], sa);
sb.append(parts.length == 1 ? Lang.getNumeral(n) : Lang.nounWithNumeral(n, parts[1]));
} else {
objs = AbilityUtils.getDefinedObjects(sa.getHostCard(), t, sa);
final List<? extends GameObject> objs;
if (t.startsWith("p:")) {
objs = AbilityUtils.getDefinedPlayers(sa.getHostCard(), t.substring(2), sa);
} else if (t.startsWith("s:")) {
objs = AbilityUtils.getDefinedSpellAbilities(sa.getHostCard(), t.substring(2), sa);
} else if (t.startsWith("c:")) {
objs = AbilityUtils.getDefinedCards(sa.getHostCard(), t.substring(2), sa);
} else {
objs = AbilityUtils.getDefinedObjects(sa.getHostCard(), t, sa);
}
sb.append(StringUtils.join(objs, ", "));
}
sb.append(StringUtils.join(objs, ", "));
} else {
sb.append(t);
}