ManaEffect > getStackDescription() try to dodge NPE

This commit is contained in:
Northmoc
2022-05-03 14:41:45 -04:00
parent c2bd4c1a4e
commit 17d41ef165

View File

@@ -270,9 +270,14 @@ public class ManaEffect extends SpellAbilityEffect {
? GameActionUtil.generatedMana(sa) : "mana";
sb.append("Add ").append(toManaString(mana)).append(".");
if (sa.hasParam("RestrictValid")) {
String desc = sa.getDescription();
int i = desc.indexOf("Spend this");
sb.append(" ").append(desc, i, desc.indexOf(".", i) + 1);
sb.append(" ");
final String desc = sa.getDescription();
if (desc.contains("Spend this") && desc.contains(".")) {
int i = desc.indexOf("Spend this");
sb.append(desc, i, desc.indexOf(".", i) + 1);
} else {
sb.append("[failed to add RestrictValid to StackDesc]");
}
}
return sb.toString();
}