mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Fix NPE when trying to build Charm description
This commit is contained in:
@@ -26,7 +26,7 @@ public class CharmAi extends SpellAbilityAi {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean checkApiLogic(Player ai, SpellAbility sa) {
|
protected boolean checkApiLogic(Player ai, SpellAbility sa) {
|
||||||
final Card source = sa.getHostCard();
|
final Card source = sa.getHostCard();
|
||||||
List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa);
|
List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa, false);
|
||||||
|
|
||||||
final int num;
|
final int num;
|
||||||
final int min;
|
final int min;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import forge.util.collect.FCollection;
|
|||||||
|
|
||||||
public class CharmEffect extends SpellAbilityEffect {
|
public class CharmEffect extends SpellAbilityEffect {
|
||||||
|
|
||||||
public static List<AbilitySub> makePossibleOptions(final SpellAbility sa) {
|
public static List<AbilitySub> makePossibleOptions(final SpellAbility sa, boolean forDesc) {
|
||||||
final Card source = sa.getHostCard();
|
final Card source = sa.getHostCard();
|
||||||
List<String> restriction = null;
|
List<String> restriction = null;
|
||||||
|
|
||||||
@@ -29,16 +29,19 @@ public class CharmEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<AbilitySub> choices = Lists.newArrayList(sa.getAdditionalAbilityList("Choices"));
|
List<AbilitySub> choices = Lists.newArrayList(sa.getAdditionalAbilityList("Choices"));
|
||||||
List<AbilitySub> toRemove = Lists.newArrayList();
|
|
||||||
for (AbilitySub ch : choices) {
|
if (!forDesc) {
|
||||||
// 603.3c If one of the modes would be illegal, that mode can't be chosen.
|
List<AbilitySub> toRemove = Lists.newArrayList();
|
||||||
if ((ch.usesTargeting() && ch.isTrigger() && ch.getMinTargets() > 0 &&
|
for (AbilitySub ch : choices) {
|
||||||
ch.getTargetRestrictions().getNumCandidates(ch, true) == 0) ||
|
// 603.3c If one of the modes would be illegal, that mode can't be chosen.
|
||||||
(restriction != null && restriction.contains(ch.getDescription()))) {
|
if ((ch.usesTargeting() && ch.isTrigger() && ch.getMinTargets() > 0 &&
|
||||||
toRemove.add(ch);
|
ch.getTargetRestrictions().getNumCandidates(ch, true) == 0) ||
|
||||||
|
(restriction != null && restriction.contains(ch.getDescription()))) {
|
||||||
|
toRemove.add(ch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
choices.removeAll(toRemove);
|
||||||
}
|
}
|
||||||
choices.removeAll(toRemove);
|
|
||||||
|
|
||||||
int indx = 0;
|
int indx = 0;
|
||||||
// set CharmOrder
|
// set CharmOrder
|
||||||
@@ -52,7 +55,7 @@ public class CharmEffect extends SpellAbilityEffect {
|
|||||||
public static String makeFormatedDescription(SpellAbility sa) {
|
public static String makeFormatedDescription(SpellAbility sa) {
|
||||||
Card source = sa.getHostCard();
|
Card source = sa.getHostCard();
|
||||||
|
|
||||||
List<AbilitySub> list = CharmEffect.makePossibleOptions(sa);
|
List<AbilitySub> list = CharmEffect.makePossibleOptions(sa, true);
|
||||||
final int num;
|
final int num;
|
||||||
boolean additionalDesc = sa.hasParam("AdditionalDescription");
|
boolean additionalDesc = sa.hasParam("AdditionalDescription");
|
||||||
boolean optional = sa.hasParam("Optional");
|
boolean optional = sa.hasParam("Optional");
|
||||||
@@ -166,7 +169,7 @@ public class CharmEffect extends SpellAbilityEffect {
|
|||||||
//this resets all previous choices
|
//this resets all previous choices
|
||||||
sa.setSubAbility(null);
|
sa.setSubAbility(null);
|
||||||
|
|
||||||
List<AbilitySub> choices = makePossibleOptions(sa);
|
List<AbilitySub> choices = makePossibleOptions(sa, false);
|
||||||
|
|
||||||
// Entwine does use all Choices
|
// Entwine does use all Choices
|
||||||
if (sa.isEntwine()) {
|
if (sa.isEntwine()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user