mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
fixed issue with default AI playing unplayable spells
This commit is contained in:
parent
47e1a7dd87
commit
17f87daf5a
2 changed files with 16 additions and 8 deletions
|
@ -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,6 +226,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!target.isRequired())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (target instanceof TargetDiscard) {
|
if (target instanceof TargetDiscard) {
|
||||||
|
@ -243,6 +245,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!target.isRequired())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (target instanceof TargetControlledPermanent) {
|
if (target instanceof TargetControlledPermanent) {
|
||||||
|
@ -271,6 +274,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!target.isRequired())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (target instanceof TargetCreatureOrPlayer) {
|
if (target instanceof TargetCreatureOrPlayer) {
|
||||||
|
@ -300,6 +304,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!target.isRequired())
|
||||||
return false;
|
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,11 +489,14 @@ 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)) {
|
||||||
|
SpellAbility ability = card.getSpellAbility();
|
||||||
|
if (ability != null && ability.canActivate(playerId, game)) {
|
||||||
if (card.getCardType().contains(CardType.INSTANT))
|
if (card.getCardType().contains(CardType.INSTANT))
|
||||||
playableInstant.add(card);
|
playableInstant.add(card);
|
||||||
else
|
else
|
||||||
playableNonInstant.add(card);
|
playableNonInstant.add(card);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (!playableInstant.contains(card) && !playableNonInstant.contains(card))
|
if (!playableInstant.contains(card) && !playableNonInstant.contains(card))
|
||||||
unplayable.put(mana.needed(avail), card);
|
unplayable.put(mana.needed(avail), card);
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue