mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
- Now that the AI can target multiple things for Support, it's failing to actually target anything for the Animation triggers and getting stuck
This commit is contained in:
@@ -716,6 +716,25 @@ public class ComputerUtilCard {
|
||||
return worstLand;
|
||||
} // end getWorstLand
|
||||
|
||||
public static Card getBestLandToAnimate(final Iterable<Card> lands) {
|
||||
Card land = null;
|
||||
int maxScore = 0;
|
||||
// first, check for tapped, basic lands
|
||||
for (Card tmp : lands) {
|
||||
// TODO Improve this by choosing basic lands that I have plenty of mana in
|
||||
int score = tmp.isTapped() ? 0 : 2;
|
||||
score += tmp.isBasicLand() ? 2 : 0;
|
||||
score -= tmp.isCreature() ? 4 : 0;
|
||||
score -= 5 * tmp.getEnchantedBy(false).size();
|
||||
|
||||
if (score >= maxScore) {
|
||||
land = tmp;
|
||||
maxScore = score;
|
||||
}
|
||||
}
|
||||
return land;
|
||||
} // end getBestLandToAnimate
|
||||
|
||||
public static final Predicate<Deck> AI_KNOWS_HOW_TO_PLAY_ALL_CARDS = new Predicate<Deck>() {
|
||||
@Override
|
||||
public boolean apply(Deck d) {
|
||||
|
||||
@@ -88,9 +88,14 @@ public abstract class CountersAi {
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card chooseBoonTarget(final CardCollectionView list, final String type) {
|
||||
Card choice;
|
||||
Card choice = null;
|
||||
if (type.equals("P1P1")) {
|
||||
choice = ComputerUtilCard.getBestCreatureAI(list);
|
||||
|
||||
if (choice == null) {
|
||||
// We'd only get here if list isn't empty, maybe we're trying to animate a land?
|
||||
choice = ComputerUtilCard.getBestLandToAnimate(list);
|
||||
}
|
||||
} else if (type.equals("DIVINITY")) {
|
||||
final CardCollection boon = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
|
||||
@@ -482,6 +482,9 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
if (isCurse) {
|
||||
if (preferred) {
|
||||
choice = CountersAi.chooseCursedTarget(list, type, amount);
|
||||
if (choice == null && mandatory) {
|
||||
choice = Aggregates.random(list);
|
||||
}
|
||||
} else {
|
||||
if (type.equals("M1M1")) {
|
||||
choice = ComputerUtilCard.getWorstCreatureAI(list);
|
||||
@@ -493,6 +496,9 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
if (preferred) {
|
||||
list = ComputerUtil.getSafeTargets(ai, sa, list);
|
||||
choice = CountersAi.chooseBoonTarget(list, type);
|
||||
if (choice == null && mandatory) {
|
||||
choice = Aggregates.random(list);
|
||||
}
|
||||
} else {
|
||||
if (type.equals("P1P1")) {
|
||||
choice = ComputerUtilCard.getWorstCreatureAI(list);
|
||||
@@ -508,6 +514,9 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
if (choice != null) {
|
||||
sa.getTargets().add(choice);
|
||||
list.remove(choice);
|
||||
} else {
|
||||
// Didn't want to choose anything?
|
||||
list.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user