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,6 +165,11 @@ public abstract class SpellAbilityEffect {
if ("}".equals(t)) { isPlainText = true; continue; } if ("}".equals(t)) { isPlainText = true; continue; }
if (!isPlainText) { if (!isPlainText) {
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 {
final List<? extends GameObject> objs; final List<? extends GameObject> objs;
if (t.startsWith("p:")) { if (t.startsWith("p:")) {
objs = AbilityUtils.getDefinedPlayers(sa.getHostCard(), t.substring(2), sa); objs = AbilityUtils.getDefinedPlayers(sa.getHostCard(), t.substring(2), sa);
@@ -175,8 +180,8 @@ public abstract class SpellAbilityEffect {
} else { } else {
objs = AbilityUtils.getDefinedObjects(sa.getHostCard(), t, sa); objs = AbilityUtils.getDefinedObjects(sa.getHostCard(), t, sa);
} }
sb.append(StringUtils.join(objs, ", ")); sb.append(StringUtils.join(objs, ", "));
}
} else { } else {
sb.append(t); sb.append(t);
} }