- When the AI decides to play a shockland untapped, consider having a viable target for a targered sorcery spell with one mode only.

This commit is contained in:
Agetian
2015-10-03 12:14:49 +00:00
parent a159c1e76c
commit a469efac9f

View File

@@ -7,12 +7,15 @@ import forge.game.ability.AbilityUtils;
import forge.game.card.Card;
import forge.game.card.CardCollection;
import forge.game.card.CardLists;
import forge.game.card.CardPredicates;
import forge.game.card.CounterType;
import forge.game.combat.Combat;
import forge.game.cost.*;
import forge.game.player.Player;
import forge.game.spellability.Spell;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetChoices;
import forge.game.spellability.TargetRestrictions;
import forge.game.zone.ZoneType;
import forge.util.collect.FCollectionView;
import forge.util.MyRandom;
@@ -426,7 +429,17 @@ public class ComputerUtilCost {
// try to determine that there is a valid target for a spell (very basic, consider expanding)
boolean requirementsMet = true;
if (c.isAura()) {
// for auras, make sure that a good enough target exists
requirementsMet = ComputerUtil.hasGoodTargetForAura(payer, c);
} else if (c.isSorcery()) {
// for sorceries with one mode that has a target, consider actually having a target that makes the AI decide to play the spell ability
if (c.getAllSpellAbilities().size() == 1) {
SpellAbility ability = c.getFirstSpellAbility();
if (ability != null && ability.usesTargeting()) {
AiPlayDecision decision = ((PlayerControllerAi)payer.getController()).getAi().canPlaySa(ability);
requirementsMet = decision == AiPlayDecision.WillPlay || decision == AiPlayDecision.WaitForMain2;
}
}
}
if (landsize == cmc && canPay && requirementsMet) {
return true;