mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- The AI will now try to avoid letting the human discard cards like Loxodon Smiter.
This commit is contained in:
@@ -25,6 +25,8 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
|
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
@@ -1433,23 +1435,37 @@ public class AbilityFactoryZoneAffecting {
|
|||||||
// discard human cards
|
// discard human cards
|
||||||
for (int i = 0; i < numCards; i++) {
|
for (int i = 0; i < numCards; i++) {
|
||||||
if (dPChHand.size() > 0) {
|
if (dPChHand.size() > 0) {
|
||||||
|
List<Card> goodChoices = CardLists.filter(dPChHand, new Predicate<Card>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(final Card c) {
|
||||||
|
if (c.hasKeyword("If a spell or ability an opponent controls causes you to discard CARDNAME," +
|
||||||
|
" put it onto the battlefield instead of putting it into your graveyard.")
|
||||||
|
|| !c.getSVar("DiscardMe").equals("")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (goodChoices.isEmpty()) {
|
||||||
|
goodChoices = dPChHand;
|
||||||
|
}
|
||||||
final List<Card> dChoices = new ArrayList<Card>();
|
final List<Card> dChoices = new ArrayList<Card>();
|
||||||
if (params.containsKey("DiscardValid")) {
|
if (params.containsKey("DiscardValid")) {
|
||||||
final String validString = params.get("DiscardValid");
|
final String validString = params.get("DiscardValid");
|
||||||
if (validString.contains("Creature") && !validString.contains("nonCreature")) {
|
if (validString.contains("Creature") && !validString.contains("nonCreature")) {
|
||||||
final Card c = CardFactoryUtil.getBestCreatureAI(dPChHand);
|
final Card c = CardFactoryUtil.getBestCreatureAI(goodChoices);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
dChoices.add(CardFactoryUtil.getBestCreatureAI(dPChHand));
|
dChoices.add(CardFactoryUtil.getBestCreatureAI(goodChoices));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(dPChHand, CardLists.TextLenReverseComparator);
|
Collections.sort(goodChoices, CardLists.TextLenReverseComparator);
|
||||||
|
|
||||||
CardLists.sortCMC(dPChHand);
|
CardLists.sortCMC(goodChoices);
|
||||||
dChoices.add(dPChHand.get(0));
|
dChoices.add(goodChoices.get(0));
|
||||||
|
|
||||||
final Card dC = dChoices.get(CardUtil.getRandomIndex(dChoices));
|
final Card dC = goodChoices.get(CardUtil.getRandomIndex(goodChoices));
|
||||||
dPChHand.remove(dC);
|
dPChHand.remove(dC);
|
||||||
|
|
||||||
if (mode.startsWith("Reveal")) {
|
if (mode.startsWith("Reveal")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user