Cost: moved "You can't sacrifice creatures to cast spells or activate abilities." into Card.canBeSacrificedBy.

also add Property for that.
This commit is contained in:
Hanmac
2016-08-03 10:50:34 +00:00
parent 22c741c7d0
commit 2458a8f73c
5 changed files with 26 additions and 25 deletions

View File

@@ -424,11 +424,6 @@ public class AiCostDecision extends CostDecisionMakerBase {
return PaymentDecision.card(source);
}
if (cost.getAmount().equals("All")) {
/*CardCollectionView typeList = new CardCollection(activator.getCardsIn(ZoneType.Battlefield));
typeList = CardLists.getValidCards(typeList, cost.getType().split(";"), activator, source);
if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
typeList = CardLists.getNotType(typeList, "Creature");
}*/
// Does the AI want to use Sacrifice All?
return null;
}
@@ -441,7 +436,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
c = AbilityUtils.calculateAmount(source, cost.getAmount(), ability);
}
CardCollectionView list = ComputerUtil.chooseSacrificeType(player, cost.getType(), source, ability.getTargetCard(), c);
CardCollectionView list = ComputerUtil.chooseSacrificeType(player, cost.getType(), ability, ability.getTargetCard(), c);
return PaymentDecision.card(list);
}

View File

@@ -372,11 +372,11 @@ public class ComputerUtil {
return null;
}
public static CardCollection chooseSacrificeType(final Player ai, final String type, final Card source, final Card target, final int amount) {
public static CardCollection chooseSacrificeType(final Player ai, final String type, final SpellAbility ability, final Card target, final int amount) {
final Card source = ability.getHostCard();
CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), source.getController(), source, null);
if (ai.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
typeList = CardLists.getNotType(typeList, "Creature");
}
typeList = CardLists.filter(typeList, CardPredicates.canBeSacrificedBy(ability));
if ((target != null) && target.getController() == ai && typeList.contains(target)) {
typeList.remove(target); // don't sacrifice the card we're pumping