Merge pull request #238 from Northmoc/npe

ManaEffect > getStackDescription() try to dodge NPE
This commit is contained in:
Anthony Calosa
2022-05-04 03:03:02 +08:00
committed by GitHub

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();
}