mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Fix NPE for ChangeZone Attach
This commit is contained in:
@@ -699,9 +699,9 @@ public class AiAttackController {
|
||||
|
||||
final boolean bAssault = doAssault(ai);
|
||||
// TODO: detect Lightmine Field by presence of a card with a specific trigger
|
||||
final boolean lightmineField = ComputerUtilCard.isPresentOnBattlefield(ai.getGame(), "Lightmine Field");
|
||||
final boolean lightmineField = ai.getGame().isCardInPlay("Lightmine Field");
|
||||
// TODO: detect Season of the Witch by presence of a card with a specific trigger
|
||||
final boolean seasonOfTheWitch = ComputerUtilCard.isPresentOnBattlefield(ai.getGame(), "Season of the Witch");
|
||||
final boolean seasonOfTheWitch = ai.getGame().isCardInPlay("Season of the Witch");
|
||||
|
||||
// Determine who will be attacked
|
||||
GameEntity defender = chooseDefender(combat, bAssault);
|
||||
|
||||
@@ -1834,10 +1834,6 @@ public class ComputerUtilCard {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPresentOnBattlefield(final Game game, final String cardName) {
|
||||
return Iterables.any(game.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals(cardName));
|
||||
}
|
||||
|
||||
public static int getMaxSAEnergyCostOnBattlefield(final Player ai) {
|
||||
// returns the maximum energy cost of an ability that permanents on the battlefield under AI's control have
|
||||
CardCollectionView otb = ai.getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
@@ -459,8 +459,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
* the mandatory
|
||||
* @return the player
|
||||
*/
|
||||
private static Player attachToPlayerAIPreferences(final Player aiPlayer, final SpellAbility sa,
|
||||
final boolean mandatory) {
|
||||
public static Player attachToPlayerAIPreferences(final Player aiPlayer, final SpellAbility sa, final boolean mandatory) {
|
||||
List<Player> targetable = new ArrayList<>();
|
||||
for (final Player player : aiPlayer.getGame().getPlayers()) {
|
||||
if (sa.canTarget(player)) {
|
||||
|
||||
@@ -54,7 +54,6 @@ import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.staticability.StaticAbilityMustTarget;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class ChangeZoneAi extends SpellAbilityAi {
|
||||
@@ -1733,7 +1732,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
@Override
|
||||
public Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> options, Map<String, Object> params) {
|
||||
// Called when attaching Aura to player
|
||||
return Aggregates.random(options);
|
||||
return AttachAi.attachToPlayerAIPreferences(ai, sa, true);
|
||||
}
|
||||
|
||||
private boolean doSacAndReturnFromGraveLogic(final Player ai, final SpellAbility sa) {
|
||||
|
||||
@@ -90,12 +90,12 @@ public class CharmAi extends SpellAbilityAi {
|
||||
if (AiPlayDecision.WillPlay == aic.canPlaySa(sub)) {
|
||||
chosenList.add(sub);
|
||||
if (chosenList.size() == num) {
|
||||
return chosenList; // maximum choices reached
|
||||
return chosenList; // maximum choices reached
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isTrigger && chosenList.size() < min) {
|
||||
// Second pass using doTrigger(false) to fulfil minimum choice
|
||||
// Second pass using doTrigger(false) to fulfill minimum choice
|
||||
choices.removeAll(chosenList);
|
||||
for (AbilitySub sub : choices) {
|
||||
sub.setActivatingPlayer(ai);
|
||||
|
||||
Reference in New Issue
Block a user