- Make Knollspine Invocation AI playable.

This commit is contained in:
Agetian
2019-05-28 18:31:20 +03:00
parent 4c111d550d
commit 6810f6f68e
3 changed files with 16 additions and 3 deletions

View File

@@ -1042,9 +1042,10 @@ public class AiController {
}
public CardCollection getCardsToDiscard(final int numDiscard, final String[] uTypes, final SpellAbility sa, final CardCollectionView exclude) {
boolean noFiltering = "DiscardCMCX".equals(sa.getParam("AILogic")); // list AI logic for which filtering is taken care of elsewhere
CardCollection hand = new CardCollection(player.getCardsIn(ZoneType.Hand));
hand.removeAll(exclude);
if ((uTypes != null) && (sa != null)) {
if ((uTypes != null) && (sa != null) && !noFiltering) {
hand = CardLists.getValidCards(hand, uTypes, sa.getActivatingPlayer(), sa.getHostCard(), sa);
}
return getCardsToDiscard(numDiscard, numDiscard, hand, sa);
@@ -1064,6 +1065,14 @@ public class AiController {
min = 1;
} else if ("VolrathsShapeshifter".equals(sa.getParam("AILogic"))) {
return SpecialCardAi.VolrathsShapeshifter.targetBestCreature(player, sa);
} else if ("DiscardCMCX".equals(sa.getParam("AILogic"))) {
final int CMC = Integer.parseInt(sourceCard.getSVar("PayX"));
CardCollection discards = CardLists.filter(player.getCardsIn(ZoneType.Hand), CardPredicates.hasCMC(CMC));
if (discards.isEmpty()) {
return null;
} else {
return new CardCollection(ComputerUtilCard.getWorstAI(discards));
}
}
if (sa.hasParam("AnyNumber")) {

View File

@@ -299,6 +299,11 @@ public class DamageDealAi extends DamageAiBase {
}
}
if ("DiscardCMCX".equals(sa.getParam("AILogic"))) {
final int CMC = Integer.parseInt(source.getSVar("PayX"));
return !CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.hasCMC(CMC)).isEmpty();
}
return true;
}

View File

@@ -1,8 +1,7 @@
Name:Knollspine Invocation
ManaCost:1 R R
Types:Enchantment
A:AB$ DealDamage | Announce$ X | Cost$ X Discard<1/Card.cmcEQX/card with converted mana cost X> | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | NumDmg$ X | References$ X | SpellDescription$ CARDNAME deals X damage to any target.
A:AB$ DealDamage | Announce$ X | Cost$ X Discard<1/Card.cmcEQX/card with converted mana cost X> | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | NumDmg$ X | References$ X | AILogic$ DiscardCMCX | SpellDescription$ CARDNAME deals X damage to any target.
SVar:X:Count$xPaid
AI:RemoveDeck:All
SVar:Picture:http://www.wizards.com/global/images/magic/general/knollspine_invocation.jpg
Oracle:{X}, Discard a card with converted mana cost X: Knollspine Invocation deals X damage to any target.