fixed issue with default AI playing unplayable spells

This commit is contained in:
BetaSteward 2011-02-22 21:40:25 -05:00
parent 47e1a7dd87
commit 17f87daf5a
2 changed files with 16 additions and 8 deletions

View file

@ -44,6 +44,7 @@ import mage.MageObject;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.ActivatedAbility; import mage.abilities.ActivatedAbility;
import mage.abilities.SpellAbility;
import mage.abilities.TriggeredAbilities; import mage.abilities.TriggeredAbilities;
import mage.abilities.TriggeredAbility; import mage.abilities.TriggeredAbility;
import mage.abilities.costs.mana.ColoredManaCost; import mage.abilities.costs.mana.ColoredManaCost;
@ -225,7 +226,8 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
return true; return true;
} }
} }
return false; if (!target.isRequired())
return false;
} }
if (target instanceof TargetDiscard) { if (target instanceof TargetDiscard) {
findPlayables(game); findPlayables(game);
@ -243,7 +245,8 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
return true; return true;
} }
} }
return false; if (!target.isRequired())
return false;
} }
if (target instanceof TargetControlledPermanent) { if (target instanceof TargetControlledPermanent) {
List<Permanent> targets; List<Permanent> targets;
@ -271,7 +274,8 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
return true; return true;
} }
} }
return false; if (!target.isRequired())
return false;
} }
if (target instanceof TargetCreatureOrPlayer) { if (target instanceof TargetCreatureOrPlayer) {
List<Permanent> targets; List<Permanent> targets;
@ -300,7 +304,8 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
return true; return true;
} }
} }
return false; if (!target.isRequired())
return false;
} }
throw new IllegalStateException("Target wasn't handled. class:" + target.getClass().toString()); throw new IllegalStateException("Target wasn't handled. class:" + target.getClass().toString());
} }
@ -484,10 +489,13 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
for (Mana mana: options) { for (Mana mana: options) {
for (Mana avail: available) { for (Mana avail: available) {
if (mana.enough(avail)) { if (mana.enough(avail)) {
if (card.getCardType().contains(CardType.INSTANT)) SpellAbility ability = card.getSpellAbility();
playableInstant.add(card); if (ability != null && ability.canActivate(playerId, game)) {
else if (card.getCardType().contains(CardType.INSTANT))
playableNonInstant.add(card); playableInstant.add(card);
else
playableNonInstant.add(card);
}
} }
else { else {
if (!playableInstant.contains(card) && !playableNonInstant.contains(card)) if (!playableInstant.contains(card) && !playableNonInstant.contains(card))