mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38: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
|
// need something AI can cast now
|
||||||
CardLists.sortByEvaluateCreature(list);
|
CardLists.sortByEvaluateCreature(list);
|
||||||
for (Card c : list) {
|
for (Card c : list) {
|
||||||
SpellAbility spell = c.getFirstSpellAbility();
|
if (ComputerUtilMana.hasEnoughManaSourcesToCast(c.getFirstSpellAbility(), ai))
|
||||||
spell.setActivatingPlayer(ai);
|
|
||||||
if (ComputerUtilMana.hasEnoughManaSourcesToCast(spell, ai))
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
return null;
|
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) {
|
if (CardLists.filter(hand, Presets.LANDS).isEmpty() && CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Presets.LANDS).size() < 4) {
|
||||||
boolean canCastSomething = false;
|
boolean canCastSomething = false;
|
||||||
for (Card cardInHand : hand) {
|
for (Card cardInHand : hand) {
|
||||||
final SpellAbility spell = cardInHand.getFirstSpellAbility();
|
canCastSomething |= ComputerUtilMana.hasEnoughManaSourcesToCast(cardInHand.getFirstSpellAbility(), ai);
|
||||||
spell.setActivatingPlayer(ai);
|
|
||||||
canCastSomething |= ComputerUtilMana.hasEnoughManaSourcesToCast(spell, ai);
|
|
||||||
}
|
}
|
||||||
if (!canCastSomething) {
|
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.");
|
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.
|
// 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) {
|
public static boolean hasEnoughManaSourcesToCast(final SpellAbility sa, final Player ai) {
|
||||||
|
sa.setActivatingPlayer(ai);
|
||||||
return payManaCost(sa, ai, true, 0, false);
|
return payManaCost(sa, ai, true, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user