mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48: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;
|
return worstLand;
|
||||||
} // end getWorstLand
|
} // 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>() {
|
public static final Predicate<Deck> AI_KNOWS_HOW_TO_PLAY_ALL_CARDS = new Predicate<Deck>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Deck d) {
|
public boolean apply(Deck d) {
|
||||||
|
|||||||
@@ -88,9 +88,14 @@ public abstract class CountersAi {
|
|||||||
* @return a {@link forge.game.card.Card} object.
|
* @return a {@link forge.game.card.Card} object.
|
||||||
*/
|
*/
|
||||||
public static Card chooseBoonTarget(final CardCollectionView list, final String type) {
|
public static Card chooseBoonTarget(final CardCollectionView list, final String type) {
|
||||||
Card choice;
|
Card choice = null;
|
||||||
if (type.equals("P1P1")) {
|
if (type.equals("P1P1")) {
|
||||||
choice = ComputerUtilCard.getBestCreatureAI(list);
|
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")) {
|
} else if (type.equals("DIVINITY")) {
|
||||||
final CardCollection boon = CardLists.filter(list, new Predicate<Card>() {
|
final CardCollection boon = CardLists.filter(list, new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -482,6 +482,9 @@ public class CountersPutAi extends SpellAbilityAi {
|
|||||||
if (isCurse) {
|
if (isCurse) {
|
||||||
if (preferred) {
|
if (preferred) {
|
||||||
choice = CountersAi.chooseCursedTarget(list, type, amount);
|
choice = CountersAi.chooseCursedTarget(list, type, amount);
|
||||||
|
if (choice == null && mandatory) {
|
||||||
|
choice = Aggregates.random(list);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (type.equals("M1M1")) {
|
if (type.equals("M1M1")) {
|
||||||
choice = ComputerUtilCard.getWorstCreatureAI(list);
|
choice = ComputerUtilCard.getWorstCreatureAI(list);
|
||||||
@@ -493,6 +496,9 @@ public class CountersPutAi extends SpellAbilityAi {
|
|||||||
if (preferred) {
|
if (preferred) {
|
||||||
list = ComputerUtil.getSafeTargets(ai, sa, list);
|
list = ComputerUtil.getSafeTargets(ai, sa, list);
|
||||||
choice = CountersAi.chooseBoonTarget(list, type);
|
choice = CountersAi.chooseBoonTarget(list, type);
|
||||||
|
if (choice == null && mandatory) {
|
||||||
|
choice = Aggregates.random(list);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (type.equals("P1P1")) {
|
if (type.equals("P1P1")) {
|
||||||
choice = ComputerUtilCard.getWorstCreatureAI(list);
|
choice = ComputerUtilCard.getWorstCreatureAI(list);
|
||||||
@@ -508,6 +514,9 @@ public class CountersPutAi extends SpellAbilityAi {
|
|||||||
if (choice != null) {
|
if (choice != null) {
|
||||||
sa.getTargets().add(choice);
|
sa.getTargets().add(choice);
|
||||||
list.remove(choice);
|
list.remove(choice);
|
||||||
|
} else {
|
||||||
|
// Didn't want to choose anything?
|
||||||
|
list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user