mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- Fixed possible NPE caused by hasEnoughManaSourcesToCast.
This commit is contained in:
@@ -511,9 +511,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
// need something AI can cast now
|
||||
CardLists.sortByEvaluateCreature(list);
|
||||
for (Card c : list) {
|
||||
SpellAbility spell = c.getFirstSpellAbility();
|
||||
spell.setActivatingPlayer(ai);
|
||||
if (ComputerUtilMana.hasEnoughManaSourcesToCast(spell, ai))
|
||||
if (ComputerUtilMana.hasEnoughManaSourcesToCast(c.getFirstSpellAbility(), ai))
|
||||
return c;
|
||||
}
|
||||
return null;
|
||||
@@ -1237,9 +1235,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
if (CardLists.filter(hand, Presets.LANDS).isEmpty() && CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Presets.LANDS).size() < 4) {
|
||||
boolean canCastSomething = false;
|
||||
for (Card cardInHand : hand) {
|
||||
final SpellAbility spell = cardInHand.getFirstSpellAbility();
|
||||
spell.setActivatingPlayer(ai);
|
||||
canCastSomething |= ComputerUtilMana.hasEnoughManaSourcesToCast(spell, ai);
|
||||
canCastSomething |= ComputerUtilMana.hasEnoughManaSourcesToCast(cardInHand.getFirstSpellAbility(), ai);
|
||||
}
|
||||
if (!canCastSomething) {
|
||||
System.out.println("Pulling a land as there are none in hand, less than 4 on the board, and nothing in hand is castable.");
|
||||
|
||||
@@ -54,6 +54,7 @@ public class ComputerUtilMana {
|
||||
|
||||
// Does not check if mana sources can be used right now, just checks for potential chance.
|
||||
public static boolean hasEnoughManaSourcesToCast(final SpellAbility sa, final Player ai) {
|
||||
sa.setActivatingPlayer(ai);
|
||||
return payManaCost(sa, ai, true, 0, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user