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 ("}".equals(t)) { isPlainText = true; continue; }
if (!isPlainText) { if (!isPlainText) {
final List<? extends GameObject> objs; if (t.startsWith("n:")) { // {n:<SVar> <noun(opt.)>}
if (t.startsWith("p:")) { String parts[] = t.substring(2).split(" ", 2);
objs = AbilityUtils.getDefinedPlayers(sa.getHostCard(), t.substring(2), sa); int n = AbilityUtils.calculateAmount(sa.getHostCard(), parts[0], sa);
} else if (t.startsWith("s:")) { sb.append(parts.length == 1 ? Lang.getNumeral(n) : Lang.nounWithNumeral(n, parts[1]));
objs = AbilityUtils.getDefinedSpellAbilities(sa.getHostCard(), t.substring(2), sa);
} else if (t.startsWith("c:")) {
objs = AbilityUtils.getDefinedCards(sa.getHostCard(), t.substring(2), sa);
} else { } 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 { } else {
sb.append(t); sb.append(t);
} }